You are on page 1of 7

Home

Packages

Forums

Wiki

Bugs

AUR

Download

Log in / create account

navigation
Main page Getting Involved Wiki News Recent changes Random page Help

page

discussion

view source

history

Netcfg
i18n Dansk English Espaol Franais Indonesia Italiano Lietuvikai Magyar Nederlands Portugus Romn Slovensk Suomi Svenska Trke esky

search
Go Search

From the netcfg man page : netcfg is used to configure and manage network connections via profiles. It has pluggable support for a range of connection types, such as wireless, ethernet, ppp. It is also capable of starting/stopping many to one connections, that is, multiple connections within the same profile, optionally with bonding. netcfg is useful for users seeking a simple and robust means of managing multiple network configurations (e.g. laptop users). For systems connecting to a single network, the network daemon may be more appropriate.
Contents [hide] 1 Preparation 2 Installation 3 Configuration 4 Usage 5 Connecting automatically 5.1 net-profiles 5.2 net-auto-wireless 5.3 net-auto-wired 6 Tips and tricks 6.1 Passing arguments to iwconfig before connecting 6.2 rfkill (enable/disable radio power) 6.3 Execute commands before/after interface up/down 6.4 Intermittent Connection Failure 6.5 Per-interface configuration 6.6 Output hooks 6.7 ArchAssistant (GUI) 6.8 wifi-select 6.9 Using dhclient instead of dhcpcd 7 Troubleshooting 7.1 Debugging 7.2 Network unavailable 7.3 Wireless association failed 7.4 Unable to get IP address with DHCP 7.5 Not a valid connection, check spelling or look at examples 7.6 Driver quirks 7.7 Ralink legacy drivers rt2500, rt2400 that use iwpriv 7.8 find: "/var/run/network//suspend/": No such file or directory 7.9 It still doesn't work, what do I do? 8 FAQ 8.1 Q: Why doesn't netcfg do (some feature)? 8.2 Q: Why doesn't netcfg behave in this way? 8.3 Q: Do I still need (some thing) if I'm using netcfg?

Summary A guide to installing and configuring netcfg network configuration and profile scripts. Overview Arch Linux provides two network management options: network and netcfg. The network daemon is a simple and straightforward solution for wired desktops and servers. Wireless networking requires additional configuration. The netcfg script provides roaming support for mobile users and facilitates management of network profiles; NetworkManager and Wicd are popular alternatives. Resources netcfg network scripts repository

toolbox
What links here Related changes Special pages Printable version Permanent link

in other languages
Franais

Preparation
In the simplest cases, users must at least know the name of their network interface(s) (e.g. eth0, wlan0). If configuring a static IP address, gateway and name server addresses must also be known. If connecting to a wireless network, have some basic information ready. For a wireless network this includes what type of security is used, the network name (ESSID), and any password or encryption keys. Additionally, ensure the proper drivers and firmware are installed for the wireless device, as described in Wireless Setup.

Installation
Ensure you have the latest version of netcfg installed. Older versions have more bugs and may not work well with the latest drivers. The netcfg package is available in core:
# pacman -S netcfg

converted by Web2PDFConvert.com

As of version 2.5.x, optional dependencies include wpa_actiond required for automatic/roaming wireless connection and ifplugd required for automatic ethernet configuration. (More information .)
# pacman -S wpa_actiond ifplugd

If you want to have bash completion support for netcfg:


# pacman -S bash-completion

Configuration
Network profiles are stored in the /etc/network.d directory. To minimize the potential for errors, copy an example configuration from /etc/network.d/examples/ to /etc/network.d/mynetwork. The file name is the name of the network profile ("mynetwork" is used as an example throughout this article). The name is not a network setting and does not need to match the wireless network name (SSID). Depending on the connection type and security, use one of the following examples from /etc/network.d/examples as a base. Be wary of examples found on the Internet as they often contain deprecated options that may cause problems. Connection type/security Wireless; WEP hex key Wireless; WEP string key Wireless; WPA personal (passphrase) Wireless; WPA enterprise Wired; DHCP Wired; static IP Wired; iproute configuration Example profile
wireless-wep wireless-wep-string-key wireless-wpa wireless-wpa-config

wireless-wpa-configsection

(wpa_supplicant configuration is external) (wpa_supplicant configuration stored as

string)
ethernet-dhcp ethernet-static ethernet-iproute

Next, modify the new configuration file, /etc/network.d/mynetwork: Set INTERFACE to the correct wireless or ethernet interface. This can be checked with ip link and iwconfig. Ensure the ESSID and KEY (passphrase) are set correctly for wireless connections. Typos in these fields are common errors. Note that WEP string keys (not hex keys) must be specified with a leading s: (e.g. KEY="s:somepasskey"). Note: Netcfg configurations are valid Bash scripts. Any configuration involving special characters such as $ or \ needs to be quoted correctly otherwise it will be interpreted by Bash. To avoid interpretation, use single quotes or backslash escape characters where appropriate. Note: Network information (e.g. wireless passkey) will be stored in plain text format, so users may want to change the permissions on the newly created profile (e.g. chmod 0600 /etc/network.d/mynetwork to make it readable by root only). Note: For WPA personal, it is also possible to use WPA passkey encoded into a hexadecimal string, instead of plain text passkey. Follow the procedure on the WPA supplicant page's 1st example exercise to generate a hexadecimal string from you WPA passkey. Save the new hexadecimal string into your wireless WPA profile in /etc/network.d/mynetwork as the value of KEY variable (make sure this will be the only KEY variable enabled), to look similar to this (replace the string with your one):
KEY='7b271c9a7c8a6ac07d12403a1f0792d7d92b5957ff8dfd56481ced43ec6a6515'

That should do it, without the need to reveal the passkey.

Usage
To connect a profile:
# netcfg mynetwork

To disconnect a profile:
# netcfg down <profile-name>

If successful, users can configure netcfg to connect automatically or during boot. If the connection fails, see #Troubleshooting for solutions and how to get help. For other functions, see:
$ netcfg help

Connecting automatically
converted by Web2PDFConvert.com

Several methods are available to users wanting to automatically connect network profiles (e.g. during boot or whilst roaming). Note that a network profile must be properly configured within the /etc/network.d directory first (see #Configuration). Tip: If enabling one of the following daemons and nothing is configured within the INTERFACES array in rc.conf, you may remove the network daemon from the DAEMONS array. If you mount NFS shares during boot, ensure the netfs daemon remains listed, though (otherwise the network will be dropped before unmounting shares during shutdown).

net-profiles
net-profiles allows users to connect profiles during boot.

To enable this feature, users must add net-profiles to the DAEMONS array in rc.conf and specify profiles to try in the NETWORKS array: File: /etc/rc.conf
NETWORKS=(mynetwork yournetwork) ... DAEMONS=(... net-profiles ...)

Alternatively, net-profiles can be configured to display a menu allowing users to choose a desired profile by setting the contents of the NETWORKS array to menu: File: /etc/rc.conf
NETWORKS=(menu) ... DAEMONS=(... net-profiles ...)

Additionally, the dialog

package is required.

Tip: Access the menu at any time by running netcfg-menu in a terminal.

net-auto-wireless
net-auto-wireless allows users to automatically connect to wireless networks with proper roaming support.

To enable this feature, users must add net-auto-wireless to the DAEMONS array in rc.conf and specify the desired wireless interface with the WIRELESS_INTERFACE variable: File: /etc/rc.conf
WIRELESS_INTERFACE="wlan0" ... DAEMONS=(... net-auto-wireless ...)

Additionally, the wpa_actiond wpa-configsection instead.

package is required. Note that wpa-config profiles does not work with net-auto-wireless. Convert them to

net-auto-wired
net-auto-wired allows users to automatically connect to wired networks.

To enable this feature, users must install ifplugd


# pacman -S ifplugd

and add net-auto-wired to the DAEMONS array in rc.conf and specify the desired wired interface with the WIRED_INTERFACE variable: File: /etc/rc.conf
WIRED_INTERFACE="eth0" ... DAEMONS=(... net-auto-wired ...)

The daemon starts an ifplugd process which runs /etc/ifplugd/netcfg.action when the status of the wired interface changes (e.g. a cable is plugged in or unplugged). On plugging in a cable, attempts are made to start any profiles with CONNECTION = "ethernet" or "ethernetiproute" and INTERFACE = WIRED_INTERFACE until one of them succeeds. Note: DHCP profiles are tried before static ones, which could lead to undesired results in some cases. Note2: The net-auto-wired daemon cannot start multiple ifplugd processes for multiple interfaces (unlike ifplugd's own /etc/rc.d/ifplugd which can).

Tips and tricks


Passing arguments to iwconfig before connecting
Simply add the following to a profile:
IWCONFIG="<arguments>"

Where <arguments> can be any valid iwconfig argument. The script then runs iwconfig

$INTERFACE $IWCONFIG.

For example, force the card to register to a specific access point given by MAC address:

converted by Web2PDFConvert.com

IWCONFIG="ap 12:34:56:78:90:12"

This supersedes the IWOPTS and WEP_OPTS options which were incompletely implemented.

rfkill (enable/disable radio power)


netcfg can enable/disable radio for wireless cards equipped with software control of radio. For wireless cards with hardware switches, netcfg can detect disabled hardware switches and fail accordingly. To enable rfkill support, you need to specify what sort of switch the wireless interface has; hardware or software. This can be set within a profile or at the interface level (/etc/network.d/interfaces/$INTERFACE; see #Per-interface configuration).
RFKILL=soft # can be either 'hard' or 'soft'

For some kill switches the rfkill entry in /sys is not linked to the interface and the RFKILL_NAME variable needs to be set to the contents of the matching /sys/class/rfkill/rfkill#/name. For example, on an Eee PC:
RFKILL=soft RFKILL_NAME='eeepc-wlan'

On a mid-2011 Thinkpad:
RFKILL=hard RFKILL_NAME='phy0'

Execute commands before/after interface up/down


If your interface requires special actions prior/after the establishment/closure of a connection, you may use the PRE_UP, POST_UP, PRE_DOWN, and POST_DOWN variables. For example, if you want to configure your wireless card to operate in ad-hoc mode but you can only change modes when the interface is down, you could use something like this:
PRE_UP="ip link set wlan0 down; iwconfig wlan0 mode ad-hoc"

Or if you want to mount your network shares after a successful connection, you could use:
POST_UP="sleep 5; mount /mnt/shares/nexus/utorrent 2>/dev/null"

Sometimes you may want to run something from netcfg with another user:
POST_UP="su -c '/you/own/command' username"

Note: If the commands specified in these properties return anything other than 0 (success), netcfg aborts the current operation. So if you want to mount a certain network share that might not be available at the time of connection (thus returning an error), you could create a separate Bash script with the mount commands and a exit 0 at the end. Alternatively you can add || true to the end of the command that may fail.

Intermittent Connection Failure


Some driver+hardware combinations drop associations sometimes. Use the pre and post commands to add/remove the driver and use a script like the following to fix the current connection: File: /usr/local/bin/netcfgd
#!/bin/bash log() { logger -t "$( basename $0 )" "$*" ; } main() { local host while sleep 1; do [[ "$( netcfg current )" = "" ]] && continue host=$( route -n | awk '/^0.0.0.0/ { print $2 }' ) ping -c 1 $host && continue log "trying to reassociate" wpa_cli reassociate ping -c 1 $host && continue log "reassociate failed, reconfiguring network" netcfg -r $( netcfg current ) done } exec 1>/dev/null [[ $EUID != 0 ]] && { log "must be root"; exit 1; } for cmd in wpa_cli ping netcfg; do ! which $cmd && { log "can't find command ${cmd}, exiting..." exit 1 } done log 'starting...' main

converted by Web2PDFConvert.com

Per-interface configuration
Configuration options that apply to all profiles using an interface can be set using /etc/network.d/interfaces/$INTERFACE. For example:
/etc/network.d/interfaces/wlan0

This is useful for wpa_supplicant options, rfkill switch support, pre/post up/down scripts and net-auto-wireless. These options are loaded before profiles so that any profile-based options will take priority. may contain any valid profile option, though you are likely to use PRE_UP/DOWN and POST_UP/DOWN (described in the previous section) or one of the options listed below. Remember that these options are set for all profiles using the interface; you probably do not want to connect to your work VPN here, for instance, as it will try to connect on every wireless network!
/etc/network.d/interfaces/$INTERFACE WPA_GROUP - Setting the group of the wpa_ctrl interface WPA_COUNTRY - Enforces local regulatory limitations and allows use of more channels WPA_DRIVER - Defaults to wext, may want nl80211 for mac80211 devices

Note: POST_UP/POST_DOWN require the wpa_actiond

package.

Output hooks
netcfg has limited support to load hooks that handle output. By default it loads the arch hook which provides the familiar output that you see. A syslog logging hook is also included. These can be found at /usr/lib/network/hooks.

ArchAssistant (GUI)
A Qt-based netcfg front-end called ArchAssistant exists. It proposes to manage and connect/disconnect profiles from a systray icon. Automatic wireless detection is also available. This tool is particularly useful for laptop users. Links: archassistant in the AUR archassistant on kde-apps.org There is also a relatively new GUI for netcfg2 on qt-apps.org that does only network configuration. You can find it here .

wifi-select
There is a console tool for selecting wireless networks in "real-time" (in NetworkManager manner) called wifi-select. The tool is convenient for use in Internet cafs or other places you are visiting for the first (and maybe the last) time. With this tool, you do not need to create a profile for a new network, just type sudo wifi-select wlan0 and choose the network you need. The tool is currently packaged and available in [community] repository. To install:
# pacman -S wifi-select wifi-select

does the following:

parses iwlist scan results and presents list of networks along with its security settings (WPA/WEP/none) using dialog if user selects network with existing profile -- just use this profile to connect with netcfg if user selects a new network (for example, WiFi hotspot), wifi-select automatically generates new profile with corresponding $SECURITY and asks for the key (if needed). It uses DHCP as $IP by default then, if connection succeeds, profile is saved for later usage if connection fails, user is asked if he/she wants to keep generated profile for further usage (for example to change $IP to static or adjust some additional options) Links: Forum thread related to development of wifi-select wifi-select Mercurial repository wifi-select on GitHub

Using dhclient instead of dhcpcd


Simply add
DHCLIENT=yes

in the desired profile.

Troubleshooting
Debugging
To run netcfg with debugging output, set the NETCFG_DEBUG environment variable to "yes", for example:
# NETCFG_DEBUG="yes" netcfg <arguments>

Debugging information for wpa_supplicant can be logged using WPA_OPTS within a profile, for example:
WPA_OPTS="-f/path/to/log"

converted by Web2PDFConvert.com

Whatever is entered here will be added to the command when wpa_supplicant is called.

Network unavailable
This error is typically due to: Out of range; or Driver issue.

Wireless association failed


This error is typically due to: Out of range/reception; Incorrect configuration; Invalid key; Driver problem; or Trying to connect to a hidden network. If the connection problem is due to poor reception, increase the TIMEOUT variable in /etc/network.d/mynetwork, such as:
TIMEOUT=60

If an AP with a hidden SSID is used, try:


PRE_UP='iwconfig $INTERFACE essid $ESSID'

Unable to get IP address with DHCP


This error is typically due to: Out of range/reception Try increasing DHCP_TIMEOUT variable in your network /etc/network.d/profile.

Not a valid connection, check spelling or look at examples


You must set CONNECTION to one of the connection types listed in the /usr/lib/network/connections directory. Alternatively, use one of the provided configuration examples in /etc/network.d/examples.

Driver quirks
Note: You most likely do not need quirks; ensure your configuration is correct before considering them. Quirks are intended for a small range of drivers with unusual issues, many of them older versions. These are workarounds, not solutions. Some drivers behave oddly and need workarounds to connect. Quirks must be enabled manually. They are best determined by reading the forums, seeing what others have used, and, if that fails, trial and error. Quirks can be combined.
prescan

Run iwlist
preessid

$INTERFACE scan

before attempting to connect (broadcom) before attempting to connect (ipw3945, broadcom and Intel PRO/Wireless 4965AGN)

Run iwconfig
wpaessid

$INTERFACE essid $ESSID

Same as previous, run before starting wpa_supplicant. Not supported anymore - use
IWCONFIG="essid $ESSID"

instead. (ath9k)
predown

Take interface down before association and then restore it after (madwifi)
postsleep

Sleep one second before checking if the association was successful


postscan

Run iwlist

scan

after associating

Add the required quirks to the netcfg configuration file /etc/network.d/mynetwork, for example:
QUIRKS=(prescan preessid)

If you receive "Wireless network not found", "Association failed" errors and have tried the above, or if an AP with a hidden SSID is used, see the above section #Wireless association failed.

Ralink legacy drivers rt2500, rt2400 that use iwpriv


There is no plans to add WPA support to these drivers. 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 its path in PRE_UP.

find: "/var/run/network//suspend/": No such file or directory


If you get this error message then don't bother because it is a known bug. Create the directory by hand.
converted by Web2PDFConvert.com

It still doesn't work, what do I do?


If this article did not help solve your problem, the next best place to ask for help is the forums or the mailing list. To be able to determine the problem, we need information. When you ask, provide the following output: ALL OUTPUT FROM netcfg This is absolutely crucial to be able determine what went wrong. The message might be short or non-existent, but it can mean a great deal. /etc/network.d network profiles This is also crucial as many problems are simple configuration issues. Feel free to censor your wireless key. netcfg version
lsmod iwconfig

FAQ
Q: Why doesn't netcfg do (some feature)?

A:

netcfg doesn't need to; it connects to networks. netcfg is modular and re-usable; see /usr/lib/network for reusable functions for custom scripts.

Q: Why doesn't netcfg behave in this way?

A:

netcfg doesn't enforce any rules; it connects to networks. It doesn't impose any heuristics, like "disconnect from wireless if ethernet is connected". If you want behaviour like that, it should be simple to write a separate tool over netcfg. See the question above.

Q: Do I still need (some thing) if I'm using netcfg?

A:

This question usually references /etc/hosts and the HOSTNAME variable in /etc/rc.conf, which are both still required. You may remove network from the DAEMONS array if you've configured all your networks with netcfg, though.

Category: Networking (English)

This page was last modified on 14 June 2011, at 16:13. Documentation License 1.2.

This page has been accessed 224,306 times. Content is available under GNU Free Privacy policy About ArchWiki Disclaimers

converted by Web2PDFConvert.com

You might also like