Difference between revisions of "Netcfg"

From ArchWiki
Jump to: navigation, search
m (reordered)
(Automatic Operation: reordered)
Line 90: Line 90:
 
===Systemd Support (Recommended) ===
 
===Systemd Support (Recommended) ===
 
Since version 2.8.2 {{Pkg|netcfg}} provides systemd unit files.  Select from the following three features.
 
Since version 2.8.2 {{Pkg|netcfg}} provides systemd unit files.  Select from the following three features.
 
==== Net-Profiles ====
 
Use the template service file {{ic|netcfg@xxx.service}} that allows connection to a profile on boot without having to specify it in {{ic|/etc/conf.d/netcfg}}. To specify the desired profile, enable the template service and use the network profile name as the instance name.
 
 
Example:
 
# systemctl enable netcfg@<profile-name>.service
 
  
 
==== Net-Auto-Wireless ====
 
==== Net-Auto-Wireless ====
Line 120: Line 114:
  
 
{{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).}}
 
{{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).}}
 +
 +
==== Net-Profiles ====
 +
Use the template service file {{ic|netcfg@xxx.service}} that allows connection to a profile on boot without having to specify it in {{ic|/etc/conf.d/netcfg}}. To specify the desired profile, enable the template service and use the network profile name as the instance name.
 +
 +
Example:
 +
# systemctl enable netcfg@<profile-name>.service
  
 
=== SysV Support (Soon to be Depreciated/Legacy) ===
 
=== SysV Support (Soon to be Depreciated/Legacy) ===
 +
====Net-Auto-Wireless====
 +
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====
 +
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).}}
 
====Net-Profiles====
 
====Net-Profiles====
 
'''{{ic|net-profiles}} allows users to connect profiles during boot.'''
 
'''{{ic|net-profiles}} allows users to connect profiles during boot.'''
Line 154: Line 185:
  
 
{{Tip|Access the menu at any time by running {{ic|netcfg-menu}} in a terminal.}}
 
{{Tip|Access the menu at any time by running {{ic|netcfg-menu}} in a terminal.}}
 
====Net-Auto-Wireless====
 
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====
 
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).}}
 
  
 
==FAQ==
 
==FAQ==

Revision as of 01:07, 15 October 2012

Summary help replacing me
A guide to installing and configuring netcfg – network configuration and profile scripts.
Overview
Template:Networking overview
Resources
Netcfg_Tips - Tips and Tricks for netcfg.
Netcfg_Troubleshooting - Troubleshooting for netcfg.
Netcfg network scripts repository - Git repo for official package scripts.

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. Further it is useful for users seeking a simple and robust means of managing multiple network configurations (e.g. laptop users). With the push to drop support for initscripts/sysv, netcfg is one of several choices users have to managing their network connectivity under systemd.

Note: netcfg-2.8.9 drops deprecated rc.conf compatibility. Users of netcfg should configure all interfaces in /etc/conf.d/netcfg rather than /etc/rc.conf.

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, 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

The netcfg package is available in the official repositories.

As of netcfg version 2.5.x, optional dependencies include wpa_actiond – required for automatic/roaming wireless connections – and ifplugd – required for automatic Ethernet configuration. (More information.)

Users wanting Bash completion support for netcfg, install the bash-completion package from the official repositories.

Configuration

Network profiles are stored in /etc/network.d. 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.

Wireless Example

Warning: Be wary of examples found on the Internet as they often contain deprecated options that may cause problems!
Connection type/security Example profile
Wireless; WEP hex key wireless-wep
Wireless; WEP string key wireless-wep-string-key
Wireless; WPA-Personal (passphrase/pre-shared key) wireless-wpa
Wireless; WPA-Enterprise wireless-wpa-config (wpa_supplicant configuration is external)
wireless-wpa-configsection (wpa_supplicant configuration stored as string)
Wired; DHCP ethernet-dhcp
Wired; static IP ethernet-static
Wired; iproute configuration ethernet-iproute

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 as a plain text passkey.

Follow the procedure on the WPA supplicant page's first example exercise to generate a hexadecimal string for the WPA passkey.
Save the new hexadecimal string into the wireless WPA profile in /etc/network.d/mynetwork as the value of the KEY variable (make sure this will be the only KEY variable enabled), to look similar to this:

KEY='7b271c9a7c8a6ac07d12403a1f0792d7d92b5957ff8dfd56481ced43ec6a6515'

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

Manual Operation

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

Automatic Operation

Systemd Support (Recommended)

Since version 2.8.2 netcfg provides systemd unit files. Select from the following three features.

Net-Auto-Wireless

This allows users to automatically connect to wireless networks with proper roaming support. To use this feature, the wpa_actiond package is required. Note that wireless-wpa-config profiles do not work with net-auto-wireless. Convert them to wireless-wpa-configsection instead.

Specify the desired wireless interface with the WIRELESS_INTERFACE variable in /etc/conf.d/netcfg or define a list of wireless networks that should be automatically connected with the AUTO_PROFILES variable in /etc/conf.d/netcfg. Enable the net-auto-wireless.service so systemd manages it.

Note: If AUTO_PROFILES is not set, all wireless networks will be tried.

Example:

# systemctl enable net-auto-wireless.service

Net-Auto-Wired

This allows users to automatically connect to wired networks. To use this feature, the ifplugd is required.

Specify the desired wired interface with the WIRED_INTERFACE variable in /etc/conf.d/netcfg and enable the net-auto-wired.service so systemd manages it.

Example:

# systemctl enable net-auto-wired.service

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 "ethernet-iproute" 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. However, one can tell netcfg to prefer a particular interface by adding AUTO_WIRED=1 to the desired profile.
Note: The net-auto-wired daemon cannot start multiple ifplugd processes for multiple interfaces (unlike ifplugd's own /etc/rc.d/ifplugd which can).

Net-Profiles

Use the template service file netcfg@xxx.service that allows connection to a profile on boot without having to specify it in /etc/conf.d/netcfg. To specify the desired profile, enable the template service and use the network profile name as the instance name.

Example:

# systemctl enable netcfg@<profile-name>.service

SysV Support (Soon to be Depreciated/Legacy)

Net-Auto-Wireless

To enable this feature, users must add net-auto-wireless to the DAEMONS array in /etc/rc.conf:

/etc/rc.conf
DAEMONS=(... net-auto-wireless ...)

And specify the desired wireless interface with the WIRELESS_INTERFACE variable in /etc/conf.d/netcfg:

/etc/conf.d/netcfg
WIRELESS_INTERFACE="wlan0"

It is also possible to define a list of wireless networks that should be automatically connected with the AUTO_PROFILES variable in /etc/conf.d/netcfg. If AUTO_PROFILES is not set, all wireless networks will be tried.

Additionally, the wpa_actiond package is required. Note that wireless-wpa-config profiles do not work with net-auto-wireless. Convert them to wireless-wpa-configsection instead.

Net-Auto-Wired

To enable this feature, users must install ifplugd, then add net-auto-wired to the DAEMONS array in /etc/rc.conf and specify the desired wired interface with the WIRED_INTERFACE variable in /etc/conf.d/netcfg:

/etc/rc.conf
DAEMONS=(... net-auto-wired ...)
/etc/conf.d/netcfg
WIRED_INTERFACE="eth0"

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 "ethernet-iproute" 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. However, one can tell netcfg to prefer a particular interface by adding AUTO_WIRED=1 to the desired profile.
Note: The net-auto-wired daemon cannot start multiple ifplugd processes for multiple interfaces (unlike ifplugd's own /etc/rc.d/ifplugd which can).

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 /etc/rc.conf and specify profiles to try in the NETWORKS array in /etc/conf.d/netcfg:

/etc/rc.conf
DAEMONS=(... net-profiles ...)
/etc/conf.d/netcfg
NETWORKS=(mynetwork yournetwork)

A network profile can also be started in the background by prefixing it with a @ in the NETWORKS array. Note that one should only do this if the backgrounded profiles configure separate interfaces, otherwise race conditions may occur.

/etc/conf.d/netcfg
NETWORKS=(@mynetwork @yournetwork)

Alternatively, net-profiles can be configured to restore the profiles that were active at last shutdown by setting the NETWORKS array to last, as described below.

/etc/conf.d/netcfg
NETWORKS=(last)

Finally, 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:

/etc/conf.d/netcfg
NETWORKS=(menu)

Additionally, the dialog package is required.

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

FAQ

Template:FAQ

Template:FAQ

Template:FAQ