Difference between revisions of "Netcfg"

From ArchWiki
Jump to: navigation, search
(Added waitout option for ping)
(netcfg was deprecated in favour of netctl, just redirect there)
 
(113 intermediate revisions by 39 users not shown)
Line 1: Line 1:
{{Lowercase title}}
+
#REDIRECT [[Netctl]]
[[Category:Networking]]
+
[[fr:Netcfg]]
+
[[it:Netcfg]]
+
[[ro:Netcfg]]
+
[[ru:Netcfg]]
+
[[tr:netcfg]]
+
[[zh-CN:Netcfg]]
+
{{Out of date|1=requires adaptations for version 2.8.2, see [http://www.archlinux.org/news/netcfg-282-release/], [http://projects.archlinux.org/netcfg.git/tree/NEWS?id=2.8.2] and [http://www.archlinux.org/netcfg/].}}
+
{{Article summary start}}
+
{{Article summary text|A guide to installing and configuring netcfg – network configuration and profile scripts.}}
+
{{Article summary heading|Overview}}
+
{{Article summary text|{{Networking overview}}}}
+
{{Article summary heading|Resources}}
+
{{Article summary link|netcfg network scripts repository|https://projects.archlinux.org/netcfg.git/}}
+
{{Article summary end}}
+
 
+
From the [https://projects.archlinux.org/netcfg.git/tree/docs/netcfg.txt 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.
+
 
+
==Preparation==
+
In the simplest cases, users must at least know the name of their network interface(s) (e.g. {{ic|eth0}}, {{ic|wlan0}}). If configuring a static IP address, the IP addresses of the default gateway and name server(s) 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 {{Pkg|netcfg}} installed. Older versions have more bugs and may not work well with the latest drivers. The {{Pkg|netcfg}} package is available in the [[Official Repositories|official repositories]].
+
 
+
As of {{Pkg|netcfg}} version 2.5.x, optional dependencies include {{Pkg|wpa_actiond}} – required for automatic/roaming wireless connections – and {{Pkg|ifplugd}} – required for automatic Ethernet configuration. ([https://www.archlinux.org/news/487/ More information].)
+
 
+
If you want to have [[Bash]] completion support for netcfg, install the {{Pkg|bash-completion}} package from the official repositories.
+
 
+
==Configuration==
+
Network profiles are stored in the {{ic|/etc/network.d}} directory. To minimize the potential for errors, copy an example configuration from {{ic|/etc/network.d/examples/}} to {{ic|/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 {{ic|/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.
+
 
+
{| border="1"
+
! Connection type/security !! Example profile
+
|-
+
| Wireless; WEP hex key || {{ic|wireless-wep}}
+
|-
+
| Wireless; WEP string key || {{ic|wireless-wep-string-key}}
+
|-
+
| Wireless; WPA-Personal (passphrase/pre-shared key) || {{ic|wireless-wpa}}
+
|-
+
| Wireless; WPA-Enterprise || {{ic|wireless-wpa-config}} (wpa_supplicant configuration is external) <br /> {{ic|wireless-wpa-configsection}} (wpa_supplicant configuration stored as string)
+
|-
+
| Wired; DHCP || {{ic|ethernet-dhcp}}
+
|-
+
| Wired; static IP || {{ic|ethernet-static}}
+
|-
+
| Wired; iproute configuration || {{ic|ethernet-iproute}}
+
|}
+
 
+
Next, modify the new configuration file, {{ic|/etc/network.d/mynetwork}}:
+
 
+
* Set {{ic|INTERFACE}} to the correct wireless or Ethernet interface. This can be checked with {{ic|ip link}} and {{ic|iwconfig}}.
+
* Ensure the {{ic|ESSID}} and {{ic|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 {{ic|s:}} (e.g. {{ic|<nowiki>KEY="s:somepasskey"</nowiki>}}).
+
 
+
{{Note|netcfg configurations are valid Bash scripts. Any configuration involving special characters such as {{ic|$}} or {{ic|\}} 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. {{ic|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 as a plain text passkey.
+
Follow the procedure on the [[Wpa_supplicant#Classic_method:_.2Fetc.2Fwpa_supplicant.conf|WPA supplicant page's first example exercise]] to generate a hexadecimal string from you WPA passkey.<br />
+
Save the new hexadecimal string into your wireless WPA profile in {{ic|/etc/network.d/mynetwork}} as the value of the {{ic|KEY}} variable (make sure this will be the only {{ic|KEY}} variable enabled), to look similar to this (replace the string with your one):
+
KEY<nowiki>=</nowiki>'7b271c9a7c8a6ac07d12403a1f0792d7d92b5957ff8dfd56481ced43ec6a6515'
+
That should do it, without the need to reveal the passkey.<br />
+
}}
+
 
+
==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==
+
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 {{ic|/etc/network.d}} directory ''first'' (see [[#Configuration]]).
+
 
+
{{Tip|If enabling one of the following daemons and nothing is configured within the {{ic|INTERFACES}} array in {{ic|/etc/rc.conf}}, you may remove the {{ic|network}} daemon from the {{ic|DAEMONS}} array. If you mount [[NFS]] shares during boot, ensure the {{ic|netfs}} daemon remains listed, though (otherwise the network will be dropped before unmounting shares during shutdown).}}
+
 
+
===net-profiles===
+
'''{{ic|net-profiles}} allows users to connect profiles during boot.'''
+
 
+
To enable this feature, users must add {{ic|net-profiles}} to the {{ic|DAEMONS}} array in {{ic|/etc/[[rc.conf]]}} and specify profiles to try in the {{ic|NETWORKS}} array in {{ic|/etc/conf.d/netcfg}}:
+
 
+
{{hc|/etc/rc.conf|<nowiki>
+
DAEMONS=(... net-profiles ...)
+
</nowiki>}}
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
NETWORKS=(mynetwork yournetwork)
+
</nowiki>}}
+
A network profile can also be started in the background by prefixing it with a {{ic|@}} in the {{ic|NETWORKS}} array. Note that you should only do this if the backgrounded profiles configure separate interfaces, otherwise race condiditions may occur.
+
 
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
NETWORKS=(@mynetwork @yournetwork)
+
</nowiki>}}
+
 
+
Alternatively, {{ic|net-profiles}} can be configured to restore the profiles that were active at last shutdown by setting the {{ic|NETWORKS}} array to {{ic|last}}, as described below.
+
 
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
NETWORKS=(last)
+
</nowiki>}}
+
 
+
Finally, {{ic|net-profiles}} can be configured to display a menu &ndash; allowing users to choose a desired profile &ndash; by setting the contents of the {{ic|NETWORKS}} array to {{ic|menu}}:
+
 
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
NETWORKS=(menu)
+
</nowiki>}}
+
 
+
Additionally, the {{Pkg|dialog}} package is required.
+
 
+
{{Tip|Access the menu at any time by running {{ic|netcfg-menu}} in a terminal.}}
+
 
+
===net-auto-wireless===
+
'''{{ic|net-auto-wireless}} allows users to automatically connect to wireless networks with proper roaming support.'''
+
 
+
To enable this feature, users must add {{ic|net-auto-wireless}} to the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}:
+
{{hc|/etc/rc.conf|<nowiki>
+
DAEMONS=(... net-auto-wireless ...)
+
</nowiki>}}
+
 
+
And specify the desired wireless interface with the {{ic|WIRELESS_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}}:
+
 
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
WIRELESS_INTERFACE="wlan0"
+
</nowiki>}}
+
 
+
It is also possible to define a list of wireless networks that should be automatically connected with the {{ic|AUTO_PROFILES}} variable in  {{ic|/etc/conf.d/netcfg}}. If {{ic|AUTO_PROFILES}} is not set, all wireless networks will be tried.
+
 
+
Additionally, the {{Pkg|wpa_actiond}} package is required. Note that {{ic|wireless-wpa-config}} profiles do not work with {{ic|net-auto-wireless}}. Convert them to {{ic|wireless-wpa-configsection}} instead.
+
 
+
===net-auto-wired===
+
'''{{ic|net-auto-wired}} allows users to automatically connect to wired networks.'''
+
 
+
To enable this feature, users must [[pacman|install]] {{Pkg|ifplugd}}, then add {{ic|net-auto-wired}} to the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}} and specify the desired wired interface with the {{ic|WIRED_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}}:
+
 
+
{{hc|/etc/rc.conf|<nowiki>
+
DAEMONS=(... net-auto-wired ...)
+
</nowiki>}}
+
{{hc|/etc/conf.d/netcfg|<nowiki>
+
WIRED_INTERFACE="eth0"
+
</nowiki>}}
+
 
+
The daemon starts an {{ic|ifplugd}} process which runs {{ic|/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 {{ic|CONNECTION <nowiki>=</nowiki> "ethernet"}} or {{ic|"ethernet-iproute"}} and {{ic|INTERFACE <nowiki>=</nowiki> WIRED_INTERFACE}} until one of them succeeds.
+
 
+
{{Note|DHCP profiles are tried before static ones, which could lead to undesired results in some cases. However, one can tell netcfg to prefer a particular interface by adding {{ic|1=AUTO_WIRED=1}} to the desired profile.}}
+
 
+
{{Note|The {{ic|net-auto-wired}} daemon cannot start multiple ifplugd processes for multiple interfaces (unlike ifplugd's own {{ic|/etc/rc.d/ifplugd}} which can).}}
+
 
+
 
+
===systemd support===
+
Since version 2.8.2 {{Pkg|netcfg}} provides systemd unit files. The service files {{ic|net-auto-wireless.service}} and {{ic|net-auto-wired.service}} correspond to the {{Pkg|initscripts}} daemons {{ic|/etc/rc.d/net-auto-wireless}} and {{ic|/etc/rc.d/net-auto-wired}}. To connect to multiple profiles at boot you can use {{ic|netcfg.service}} which is equivalent to {{ic|/etc/rc.d/net-profiles}} and starts all profiles specified in the {{ic|NETWORKS}} array in {{ic|/etc/conf.d/netcfg}}. These service files can be enabled and started with {{ic|systemctl}} as usual.
+
 
+
Alternatively you can use the template service file {{ic|netcfg@.service}} that allows you to connect to a single profile on boot without having to specify it in {{ic|/etc/conf.d/netcfg}}. To specify the desired profile, create a corresponding symlink to {{ic|/etc/systemd/system/multi-user.target.wants}}:
+
# ln -s /usr/lib/systemd/system/netcfg@.service /etc/systemd/system/multi-user.target.wants/netcfg@<profile-name>.service
+
 
+
==Tips and tricks==
+
 
+
===Passing arguments to iwconfig before connecting===
+
Simply add the following to a profile:
+
 
+
IWCONFIG="<arguments>"
+
 
+
Where {{ic|<arguments>}} can be any valid {{ic|iwconfig}} argument. The script then runs {{ic|iwconfig $INTERFACE $IWCONFIG}}.
+
 
+
For example, force the card to register to a specific access point given by MAC address:
+
IWCONFIG="ap 12:34:56:78:90:12"
+
 
+
This supersedes the {{ic|IWOPTS}} and {{ic|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 ({{ic|/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 {{ic|/sys}} is not linked to the interface and the {{ic|RFKILL_NAME}} variable needs to be set to the contents of the matching {{ic|/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'
+
 
+
{{Note|The {{ic|net-auto-wireless}} daemon requires an interface level configuration of rfkill or it will not start.}}
+
 
+
{{Warning|Some devices (at least few SiS cards) can create {{Ic|/sys/class/rfkill/rfkill#}} entries with different names on every switch. Something like this will work in such cases (wifi-only solution!):
+
{{hc|/etc/network.d/interfaces/wlan0|<nowiki>
+
RFKILL=hard
+
RFKILL_NAME=`cat /sys/class/rfkill/rfkill*/name 2> /dev/null || echo ""`</nowiki>}}}}
+
 
+
===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 {{ic|PRE_UP}}, {{ic|POST_UP}}, {{ic|PRE_DOWN}}, and {{ic|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 {{ic|exit 0}} at the end. Alternatively you can add {{ic|<nowiki>|| true</nowiki>}} 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:
+
 
+
{{hc|/usr/local/bin/netcfgd|<nowiki>
+
#!/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 -c1 -w10 $host && continue
+
 
+
                log "trying to reassociate"
+
                wpa_cli reassociate
+
                ping -c1 -w10 $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
+
 
+
</nowiki>}}
+
 
+
===Per-interface configuration===
+
Configuration options that apply to all profiles using an interface can be set using {{ic|/etc/network.d/interfaces/$INTERFACE}}. For example:
+
 
+
/etc/network.d/interfaces/wlan0
+
 
+
This is useful for {{ic|wpa_supplicant}} options, rfkill switch support, pre/post up/down scripts and {{ic|net-auto-wireless}}. These options are loaded ''before'' profiles so that any profile-based options will take priority.
+
 
+
{{ic|/etc/network.d/interfaces/$INTERFACE}} may contain any valid profile option, though you are likely to use {{ic|PRE_UP}}/{{ic|DOWN}} and {{ic|POST_UP}}/{{ic|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!
+
 
+
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|{{ic|POST_UP}}/{{ic|POST_DOWN}} require the {{Pkg|wpa_actiond}} package.}}
+
 
+
===Output hooks===
+
netcfg has limited support to load hooks that handle output. By default it loads the {{ic|arch}} hook which provides the familiar output that you see. A syslog logging hook is also included. These can be found at {{ic|/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 system tray icon. Automatic wireless detection is also available. This tool is particularly useful for laptop users.
+
 
+
Links:
+
 
+
* {{AUR|archassistant}} in the [[Arch User Repository|AUR]]
+
* [http://www.kde-apps.org/content/show.php/ArchAssistant?content=76760 archassistant on kde-apps.org]
+
 
+
There is also a relatively new GUI for netcfg on qt-apps.org that does only network configuration. You can find it [http://www.qt-apps.org/content/show.php/netcfgGUI?content=99523 here].
+
 
+
===wifi-select===
+
 
+
There is a console tool for selecting wireless networks in "real-time" (in [[NetworkManager]] fashion) called {{Pkg|wifi-select}}. The tool is convenient for use in Internet cafés 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 run {{ic|wifi-select wlan0}} as root and choose the desired network.
+
 
+
The tool is currently packaged as {{Pkg|wifi-select}} and is available in the [[Official Repositories|official repositories]].
+
 
+
{{Pkg|wifi-select}} does the following:
+
* parses {{ic|iwlist scan}} results and presents a list of networks along with their security settings (WPA/WEP/none) using {{Pkg|dialog}}
+
* if user selects network with existing profile -- just use this profile to connect with {{Pkg|netcfg}}
+
* if user selects a new network (for example, a Wi-Fi hotspot), {{Pkg|wifi-select}} automatically generates a new profile with corresponding {{ic|$SECURITY}} and asks for the key (if needed). It uses DHCP as {{ic|$IP}} by default
+
* then, if the connection succeeds, the profile is saved for later usage
+
* if the connection fails, the user is asked if he or she wants to keep generated profile for further usage (for example to change {{ic|$IP}} to static or adjust some additional options)
+
 
+
Links:
+
 
+
* [https://bbs.archlinux.org/viewtopic.php?id=63973 Forum thread] related to development of {{Pkg|wifi-select}}
+
* [http://hg.horna.org.ua/wifi-select/ wifi-select Mercurial repository]
+
* [https://github.com/sphynx/wifi-select wifi-select on GitHub]
+
 
+
{{Note|Latest version of netcfg will provide '''wifi-menu''' with functionality equal to that of wifi-select.}}
+
 
+
===Passing arguments to dhcpcd===
+
 
+
For example, add
+
DHCP_OPTIONS='-C resolv.conf -G'
+
to the desired profile. The above example prevents {{Pkg|dhcpcd}} from writing to {{ic|/etc/resolv.conf}} and setting any default routes.
+
 
+
====Speed up DHCP with dhcpcd====
+
 
+
By default, {{ic|dhcpcd}} confirms that the assigned IP address is not already taken via ARP. If you are confident that it will not be, e.g. in your home network, you can speed up the connection process by about 5 seconds by adding {{ic|--noarp}} to {{ic|DHCP_OPTIONS}}:
+
 
+
DHCP_OPTIONS="--noarp"
+
 
+
If you never want {{ic|dhcpcd}} to perform this check for any connection, you can globally configure this by adding the following line to {{ic|/etc/dhcpcd.conf}}:
+
 
+
noarp
+
 
+
===Using dhclient instead of dhcpcd===
+
 
+
To use {{Pkg|dhclient}} instead of {{Pkg|dhcpcd}}, simply add {{ic|DHCLIENT<nowiki>=</nowiki>yes}} to the desired profile.
+
 
+
===Configuring a bridge for use with virtual machines (VMs)===
+
To configure a bridge named br0 with a static IP:
+
{{hc|/etc/network.d/br0|<nowiki>
+
INTERFACE="br0"
+
CONNECTION="bridge"
+
DESCRIPTION="bridge br0 static"
+
BRIDGE_INTERFACES="eth0"
+
IP='static'
+
ADDR='10.0.0.10'
+
GATEWAY='10.0.0.1'
+
DNS='10.0.0.1'
+
</nowiki>}}
+
 
+
To configure a bridge named br0 with a dhcp IP:
+
{{hc|/etc/network.d/br0|<nowiki>
+
INTERFACE="br0"
+
CONNECTION="bridge"
+
DESCRIPTION="bridge br0 dhcp"
+
BRIDGE_INTERFACES="eth0"
+
IP='dhcp'
+
</nowiki>}}
+
 
+
Then add the corresponding bridge name to your {{ic|NETWORKS&#61;(...)}} in {{ic|/etc/conf.d/netcfg}}.
+
 
+
It can be brought up by calling it directly, or by restarting net-profiles.
+
 
+
netcfg br0
+
 
+
rc.d restart net-profiles
+
 
+
===Adding multiple IP addresses to one interface===
+
If you want to assign multiple IP addresses to 1 specific interface, this can be done by issuing the relevant {{ic|ip}} command in a {{ic|POST_UP}} statement (which as the name suggests will be executed after the interface has been brought up). Multiple statements can be separated with a {{ic|;}}. So if you for example would want to assign both 10.0.0.1 and 10.0.0.2 to interface eth0; the config would look something among the lines of:
+
 
+
{{hc|/etc/network.d/multiple_ip|<nowiki>
+
INTERFACE="eth0"
+
CONNECTION="ethernet"
+
IP='static'
+
ADDR='10.0.0.1'
+
POST_UP='ip addr add 10.0.0.2/24 dev eth0'
+
</nowiki>}}
+
 
+
===Adding static routes===
+
When wanting to configure static routes, this can be done by issuing the relevant {{ic|ip}} command in a {{ic|POSTUP}} statement (which as the name suggests will be executed after the interface has been brought up). Optionally, a {{ic|PRE_DOWN}} statement can be added to remove said routes when the interface is brought down. Multiple statements can be separated with a {{ic|;}}. In the below example we'll route 10.0.1.0/24 over interface eth1 and then remove the route when the interface is brought down.
+
 
+
{{hc|/etc/network.d/static_routes|<nowiki>
+
INTERFACE="eth1"
+
CONNECTION="ethernet"
+
IP='static'
+
POST_UP='ip route add 10.0.1.0/24 dev eth1'
+
PRE_DOWN='ip route del 10.0.1.0/24 dev eth1'
+
</nowiki>}}
+
 
+
==Troubleshooting==
+
 
+
===Debugging===
+
To run netcfg with debugging output, set the {{ic|NETCFG_DEBUG}} environment variable to {{ic|"yes"}}, for example:
+
 
+
# NETCFG_DEBUG="yes" netcfg <arguments>
+
 
+
Debugging information for wpa_supplicant can be logged using {{ic|WPA_OPTS}} within a profile, for example:
+
 
+
WPA_OPTS="-f/path/to/log"
+
 
+
Whatever is entered here will be added to the command when {{ic|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 {{ic|TIMEOUT}} variable in {{ic|/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 {{ic|DHCP_TIMEOUT}} variable in your network {{ic|/etc/network.d/profile}}.
+
 
+
===Not a valid connection, check spelling or look at examples===
+
You must set {{ic|CONNECTION}} to one of the connection types listed in the {{ic|/usr/lib/network/connections}} directory. Alternatively, use one of the provided configuration examples in {{ic|/etc/network.d/examples}}.
+
 
+
===No Connection===
+
If you get a set of debug messages similar to the following (remembering that profile names and interface names may be different), it could be that the process of bringing up the interface is taking too long.
+
 
+
  DEBUG: Loading profile eth0-dhcp
+
  DEBUG: Configuring interface eth0
+
  :: eth0-dhcp up
+
  DEBUG: status reported to profile_up as:
+
  DEBUG: Loading profile eth0-dhcp
+
  DEBUG: Configuring interface eth0
+
  DEBUG: ethernet_iproute_up ifup
+
    > No connection
+
  DEBUG: profile_up connect failed
+
  [FAIL]
+
 
+
The default is 2 seconds.
+
To lengthen the timeout, set the CARRIER_TIMEOUT variable before calling netcfg.
+
 
+
This thread shows one example of this issue:
+
https://bbs.archlinux.org/viewtopic.php?id=138615
+
 
+
===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.
+
 
+
; {{ic|prescan}}: Run {{ic|iwlist $INTERFACE scan}} before attempting to connect (Broadcom)
+
; {{ic|preessid}}: Run {{ic|iwconfig $INTERFACE essid $ESSID}} before attempting to connect (ipw3945, Broadcom and Intel PRO/Wireless 4965AGN)
+
; {{ic|wpaessid}}: Same as previous, run before starting {{ic|wpa_supplicant}}. Not supported anymore  - use {{ic|1=IWCONFIG="essid $ESSID"}} instead. (ath9k)
+
; {{ic|predown}}: Take interface down before association and then restore it after (madwifi)
+
; {{ic|postsleep}}: Sleep one second before checking if the association was successful
+
; {{ic|postscan}}: Run {{ic|iwlist scan}} after associating
+
 
+
Add the required quirks to the netcfg configuration file {{ic|/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 {{ic|iwpriv}} commands and put its path in {{ic|PRE_UP}}.
+
 
+
===find: "/var/run/network//suspend/":  No such file or directory===
+
If you get this error message, then do not bother because it is a known bug. Create the directory by hand.
+
 
+
===It still does not work, what do I do?===
+
If this article did not help solve your problem, the next best places to ask for help are the forums, the mailing list, and the #archlinux IRC channel.
+
 
+
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.
+
* '''{{ic|/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'''
+
* {{ic|lsmod}}
+
* {{ic|iwconfig}}
+
 
+
==FAQ==
+
{{FAQ
+
|question=Why doesn't netcfg do ''(some feature)''?
+
|answer=netcfg does not need to; it connects to networks. netcfg is modular and re-usable; see {{ic|/usr/lib/network}} for re-usable functions for custom scripts.}}
+
 
+
{{FAQ
+
|question=Why doesn't netcfg behave in ''this'' way?
+
|answer=netcfg does not enforce any rules; it connects to networks. netcfg does not impose any heuristics, like "disconnect from wireless if Ethernet is connected". If you want behavior like that, it should be simple to write a separate tool on top of netcfg. See the question above.}}
+
 
+
{{FAQ
+
|question=Do I still need ''(some thing)'' if I am using netcfg?
+
|answer=This question usually references {{ic|/etc/hosts}} and the {{ic|HOSTNAME}} variable in {{ic|/etc/rc.conf}}, which are both still required. You may remove {{ic|network}} from the {{ic|DAEMONS}} array if you have configured all of your networks with netcfg, though.}}
+

Latest revision as of 15:26, 16 July 2013

Redirect to: