Network Profiles
From ArchWiki
| i18n |
|---|
| English |
| 简体中文 |
[edit] Install netcfg v2
pacman -Sy core/netcfg
For information relating to the latest developmental version of netcfg, see Network Profiles development
[edit] Connecting to a wireless network (short)
Copy one of the example profiles in /etc/network.d/examples to /etc/network.d/ and then adapt to your network.
Once adapted, you may connect with netcfg2 <profile name>
To have the network connected on boot, add it to the NETWORKS=() line in and add net-profiles to DAEMONS=() (in /etc/rc.conf)
[edit] Connecting to a wireless network (detailed)
[edit] Gather information
- Wireless network interface
- Can be found with
ifconfigor in/proc/net/wireless
- Can be found with
- Network Name/ESSID
- Check if the network is 'hidden' -- Does it appear when you run
iwlist scan?
- Check if the network is 'hidden' -- Does it appear when you run
- What security system is in use
- Supported security mechanisms: None, WPA, and WEP.
- What security key
- Only needed if there's security on the network
- IP settings, dhcp/static
- Most wireless networks use dhcp. If in doubt, use dhcp.
[edit] Create profile
In /etc/network.d/ and create a new network profile. A profile, is a single file in /etc/network.d. The file name will become the name of the profile, and can be anything you wish, it is not a setting involved in the connection.
The easiest way to create a new profile, is to copy an existing one such as by copying one of the example profiles from /etc/network.d/examples that use a similar security setup.
Edit the profile, to contain the information you gathered earlier. For now, leave the scan option set to 'on'
[edit] Example configurations
Below are some example connection files. These are also available in /etc/network.d/examples.
CONNECTION="wireless" DESCRIPTION="A simple WEP encrypted wireless connection" INTERFACE=wlan0 SCAN="yes" SECURITY="wep" ESSID=MyNetwork KEY="1234567890" IP="dhcp"
CONNECTION="wireless" INTERFACE=wlan0 SCAN="yes" SECURITY="wpa" ESSID=mynetwork KEY="SomePasskey" IP="dhcp" TIMEOUT=20
For detailed static configuration, and further options, see the wireless(8) and ethernet(8) manual pages.
[edit] Connect
Now that the configuration is set you can just run, netcfg2 profile-name to connect your network if it is available.
To have the network be connected on boot, add the profile-name to the NETWORKS=() line in rc.conf, eg:
NETWORKS=(home).
To connect to networks on boot ensure that net-profiles is in your rc.conf DAEMONS=() line.
If you cannot connect to the network, see if your problem is listed below. If you have further difficulties, follow the instructions below and seek help on the arch forums, IRC or mailing lists.
[edit] Automatic Detection
[edit] netcfg v2.1 and later
Automatic network detection has been included for wireless networks.
To enable this, add auto-wireless $interface to the AUTO_NETWORKS=() line in /etc/rc.conf. For example:
AUTO_NETWORKS=(auto-wireless ipw0)
To run after boot, run: /usr/bin/netcfg-auto-wireless $interface
[edit] Before netcfg v2.1
Add auto-wireless $interface to your NETWORKS=() line instead of AUTO_NETWORKS=(). For example:
NETWORKS=(auto-wireless ipw0 ethernet)
[edit] Troubleshooting
[edit] It doesn't work!! What's wrong?
See the last question in this trouble shooting section. To be able to determine what's wrong, we need information! But first, try reading the rest of the troubleshooting section or search the forum.
[edit] Driver Quirks (netcfg 2.1 and later)
Some drivers behave odd and need workarounds to connect. These have to be enabled manually. They're best determined by reading the forums, seeing what others have used, and if that fails trial and error. They can be combined.
- prescan - Run "iwlist $INTERFACE scan" before attempting to connect (Some broadcom)
- preessid - Run "iwconfig $INTERFACE essid $ESSID" before attempting to connect. (Some ipw3945 and Intel PRO/Wireless 4965AGN)
- wpaessid - Same as previous, run before starting wpa_supplicant
- predown - Take interface down before association and then restore it after. (madwifi)
- postsleep - Sleep 1 second before checking if the association was successful
- postscan - Run "iwlist scan" after associating
For example
QUIRKS=(prescan preessid)
If you are having problems with DNS and DHCP, try adding to your profile:
DHCLIENT=no
This will tell netcfg to use dhcpcd instead of dhclient
If you get "Wireless Network Not Found" or "Association Failed" and have tried the above, try:
SCAN=no
[edit] Pass arguments to iwconfig before connecting (netcfg 2.1 and later)
This one is very popular. Simply:
IWCONFIG="<arguments>"
Where <arguments can be any valid iwconfig argument. The script then runs "iwconfig $INTERFACE $IWCONFIG"
For example, setting bssid/ap mac:
IWCONFIG="ap 12:34:56:78:90:12"
This supercedes the IWOPTS option which was incompletely implemented.
[edit] Network unavailable
This is typically one of:
- Out of range
- Driver issue (See Driver Quirks above)
- Trying to connect to a hidden network
If you know your network is hidden, set
SCAN=no
[edit] Wireless Association failed
This is typically one of:
- Out of range/reception
- Incorrect configuration
- Invalid key
- Driver problem (See Driver Quirks above)
If it is a range problem, increasing TIMEOUT= can help.
[edit] Unable to get IP address with DHCP
This is typically one of:
- Out of range/reception
Try increasing DHCP_TIMEOUT
[edit] Not a valid connection, check spelling or look at examples
You must set CONNECTION= to "ethernet", "ppp", or "wireless".
[edit] Using a string WEP key
This is for a STRING WEP key, not a HEX WEP key, not a WPA key. KEY="s:Somepasskey"
[edit] Ralink legacy drivers rt2500, rt2400 that use iwpriv
I have no intention of supporting these. rt2x00 is supported however, and will replace these.
If you must use them, create a shell script that runs the needed iwpriv commands, and put it's path in PRE_UP=""
[edit] What do I do if this doesn't work?
Check through all the FAQs below. If they do not contain a solution, the next best place to go is the forums, or the mailing list.
When you post, make sure that you provide the following output:
- ALL OUTPUT FROM netcfg - this one is important, even if netcfg appears to succeed
- ifconfig -a
- iwconfig before attempting to connect
- the /etc/network.d/ profile file with the wireless key replaced by <censored>
- lsmod
Rather than scripting a long post/email, the best place to put all this is a pastebin. Pastie and rafb|Nopaste are two popular ones within the Arch community. There is also a cli frontend for rafb:
pacman -S nopaste
[edit] GUI
A Qt-based netcfg2 frontend called ArchAssistant exists. It proposes to manage & connect/disconnect profiles from a systray icon. Automatic wireless detection is also available. This tool is particularly useful for laptop users.
Links: archassistant on AUR | archassistant on kde-apps.org | archassistant package on archlinux.fr i686 and x86_64
[edit] FAQ
[edit] How do I get a menu at boot, like the old netcfg?
In rc.conf set NETWORKS=() to menu.
You can also access that menu any time by running netcfg-menu in a terminal
[edit] Why doesnt netcfg do x?
netcfg doesn't need to. It connects to networks.
But netcfg is super modular and re-usable. Have a look at /usr/lib/networks/ -- heaps of reusable functions for your own scripts.
[edit] Why doesn't netcfg behave in this way? It makes more sense
netcfg doesn't enforce any rules. It's task is to connect to networks. It doesn't impose any heuristics, like 'disconnect from wireless if ethernet is connected'.
If you want behaviour like that, it'd be really easy to write a separate tool over netcfg. See the question above.
[edit] Do I still need x when I'm using netcfg?
- /etc/hosts: Yes, you still need this, this is important. Don't remove your hostname from this otherwise you'll have some odd problems.
- HOSTNAME= in /etc/rc.conf: It's strongly recommended you keep this, otherwise no hostname will be set if a profile fails
- DAEMONS=(network) and INTERFACES=() in /etc/rc.conf: If you've setup all your networks with netcfg2 instead, yes, you can remove this. You can also safely remove lo, it's been moved into rc.sysinit.
- lo: This is now in rc.sysinit, you don't need to configure it anywhere.