Difference between revisions of "Netcfg"
m (undid edit by Zodiac es this is the English wiki...) |
m (→Configuration: Change route to ip route.) |
||
(27 intermediate revisions by 19 users not shown) | |||
Line 4: | Line 4: | ||
[[fr:Netcfg]] | [[fr:Netcfg]] | ||
[[it:Netcfg]] | [[it:Netcfg]] | ||
+ | [[ja:Netcfg]] | ||
[[ro:Netcfg]] | [[ro:Netcfg]] | ||
[[ru:Netcfg]] | [[ru:Netcfg]] | ||
Line 18: | Line 19: | ||
{{Article summary end}} | {{Article summary end}} | ||
− | 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 | + | 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 and [[Wikipedia:Point-to-point_protocol|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). |
− | |||
− | |||
== Preparation == | == Preparation == | ||
Line 35: | Line 34: | ||
== Configuration == | == Configuration == | ||
+ | {{Note|1={{Pkg|netcfg}} >= 2.8.9 drops deprecated {{ic|/etc/[[rc.conf]]}} compatibility. Netcfg users should configure all interfaces in {{ic|/etc/conf.d/netcfg}} instead of {{ic|/etc/rc.conf}}.}} | ||
Network profiles are stored in {{ic|/etc/network.d/}}. 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, and {{ic|mynetwork}} is used as an example throughout this article. | Network profiles are stored in {{ic|/etc/network.d/}}. 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, and {{ic|mynetwork}} is used as an example throughout this article. | ||
Line 50: | Line 50: | ||
| Static IP || {{ic|ethernet-static}} || | | Static IP || {{ic|ethernet-static}} || | ||
|- | |- | ||
− | | Routed || {{ic|ethernet-iproute}} || Can be checked with {{ic|route}} from the {{Pkg| | + | | Routed || {{ic|ethernet-iproute}} || Can be checked with {{ic|ip route}} from the {{Pkg|iproute2}} package. |
|- | |- | ||
| rowspan="3"| '''Wireless''' | | rowspan="3"| '''Wireless''' | ||
Line 67: | Line 67: | ||
* Ensure the {{ic|ESSID}} and {{ic|KEY}} (passphrase) are set correctly for wireless connections. Typos in these fields are common errors. | * 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|1=KEY="s:''somepasskey''"}}). | ** Note that WEP ''string'' keys (not ''hex'' keys) must be specified with a leading {{ic|s:}} (e.g. {{ic|1=KEY="s:''somepasskey''"}}). | ||
+ | |||
+ | {{Note|If you are using netcfg inside a VPS, please see [[Virtual_Private_Server#Moving_your_VPS_from_network_configuration_in_rc.conf_to_netcfg_.28tested_with_OpenVZ.29|the appropriate page]].}} | ||
{{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|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.}} | ||
Line 72: | Line 74: | ||
{{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|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 [[Wpa_supplicant#Classic_method:_.2Fetc.2Fwpa_supplicant.conf|encode the WPA passkey into a hexadecimal string]]. Save the new hexadecimal string into the 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: {{ic|1=KEY='7b271c9a7c8a6ac07d12403a1f0792d7d92b5957ff8dfd56481ced43ec6a6515'}}. | + | {{Note|For WPA-Personal, it is also possible to [[Wpa_supplicant#Classic_method:_.2Fetc.2Fwpa_supplicant.conf|encode the WPA passkey into a hexadecimal string]]. Save the new hexadecimal string into the 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: {{ic|1=KEY='7b271c9a7c8a6ac07d12403a1f0792d7d92b5957ff8dfd56481ced43ec6a6515'}}. However, this key can also be used by anyone to get on your network, and thus must be protected just as well as the cleartext key. The hexadecimal encoding is more convenient if you use special characters that are hard to express in scripts.}} |
+ | |||
+ | {{ | ||
+ | Note|1=By default netcfg uses dhcpcd for configuring network interfaces. An alternate to dhcpcd is dhclient. To use dhclient, set DHCLIENT='yes' in appropriate profile configuration. | ||
+ | }} | ||
== Manual Operation == | == Manual Operation == | ||
Line 85: | Line 91: | ||
If successful, users can configure netcfg to connect automatically or during boot. If the connection fails, see [[Netcfg Troubleshooting]] for solutions and for how to ask for help. | If successful, users can configure netcfg to connect automatically or during boot. If the connection fails, see [[Netcfg Troubleshooting]] for solutions and for how to ask for help. | ||
+ | |||
+ | It is also possible to use an interactive menu ({{Pkg|dialog}} package is required): | ||
+ | netcfg-menu | ||
Additionally, see: | Additionally, see: | ||
Line 91: | Line 100: | ||
== Automatic Operation == | == Automatic Operation == | ||
+ | |||
+ | === Just one profile === | ||
+ | |||
+ | In the simplest case, only one profile will be used and is always desired to start on boot: | ||
+ | |||
+ | # systemctl enable netcfg@myprofile | ||
=== Net-Profiles === | === Net-Profiles === | ||
− | Edit the {{ic|NETWORKS}} array in {{ic|/etc/conf.d/netcfg}} to refer to | + | Edit the {{ic|NETWORKS}} array in {{ic|/etc/conf.d/netcfg}} to refer to the network config file {{ic|/etc/network.d/mynetwork}}. |
{{hc|/etc/conf.d/netcfg|2= | {{hc|/etc/conf.d/netcfg|2= | ||
Line 101: | Line 116: | ||
Start the service on startup: | Start the service on startup: | ||
− | # systemctl enable netcfg | + | # systemctl enable netcfg |
Alternatively, the profiles that were active at last shutdown can be restored by setting the {{ic|NETWORKS}} array to {{ic|last}}. | Alternatively, the profiles that were active at last shutdown can be restored by setting the {{ic|NETWORKS}} array to {{ic|last}}. | ||
Line 108: | Line 123: | ||
NETWORKS=(last)}} | NETWORKS=(last)}} | ||
− | + | {{Note|For {{ic|1=NETWORKS=(last)}} to work, you will have to connect to your network manually first and then stop the daemon for Netcfg to remember the network. You can stop the Netcfg daemon by running {{ic|netcfg-daemon stop}} as root.}} | |
− | |||
− | |||
− | NETWORKS=( | ||
− | |||
− | |||
− | {{ | + | {{Note|The {{ic|1=NETWORKS=(menu)}} setting cannot be used anymore when switching to systemd. See {{bug|31377}} for details.}} |
=== Net-Auto-Wireless === | === Net-Auto-Wireless === | ||
− | This allows users to automatically connect to wireless networks with proper roaming support. To use this feature, 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. | + | This allows users to automatically connect to wireless networks with proper roaming support. To use this feature, 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}} or {{ic|wireless-wpa}} instead. |
Specify the desired wireless interface with the {{ic|WIRELESS_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}} or define a list of wireless networks that should be automatically connected with the {{ic|AUTO_PROFILES}} variable in {{ic|/etc/conf.d/netcfg}}. | Specify the desired wireless interface with the {{ic|WIRELESS_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}} or define a list of wireless networks that should be automatically connected with the {{ic|AUTO_PROFILES}} variable in {{ic|/etc/conf.d/netcfg}}. | ||
{{Note|If AUTO_PROFILES is not set, all wireless networks will be tried.}} | {{Note|If AUTO_PROFILES is not set, all wireless networks will be tried.}} | ||
+ | {{Note|1=By default, wpa_actiond sets dhcp timeout to 10 seconds (line 16 of /usr/bin/netcfg-wpa_actiond-action) which may be not enough for all users to always get an IP address successfully. To override this, for example with classic 30 seconds timeout, write DHCP_TIMEOUT=30 to /etc/conf.d/netcfg}} | ||
+ | Enable {{ic|net-auto-wireless}} so systemd manages it. | ||
− | + | # systemctl enable net-auto-wireless | |
− | |||
− | # systemctl enable net-auto-wireless | ||
=== Net-Auto-Wired === | === Net-Auto-Wired === | ||
Line 135: | Line 145: | ||
Specify the desired wired interface with the {{ic|WIRED_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}}. | Specify the desired wired interface with the {{ic|WIRED_INTERFACE}} variable in {{ic|/etc/conf.d/netcfg}}. | ||
− | Enable | + | Enable {{ic|net-auto-wired}} so systemd manages it. |
− | # systemctl enable net-auto-wired | + | # systemctl enable net-auto-wired |
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|1=CONNECTION = "ethernet"}} or {{ic|"ethernet-iproute"}} and {{ic|1=INTERFACE = WIRED_INTERFACE}} until one of them succeeds. | 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|1=CONNECTION = "ethernet"}} or {{ic|"ethernet-iproute"}} and {{ic|1=INTERFACE = WIRED_INTERFACE}} until one of them succeeds. | ||
Line 157: | Line 167: | ||
{{FAQ | {{FAQ | ||
|question=Do I need anything else if I'm using netcfg? | |question=Do I need anything else if I'm using netcfg? | ||
− | |answer=This question usually references | + | |answer=This question usually references {{ic|/etc/hostname}}, which still has to be set.}} |
Revision as of 04:54, 4 March 2013
zh-CN:Netcfg Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary link Template:Article summary end
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 and 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).
Contents
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 passphrase 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, which is required for automatic/roaming wireless connections, and ifplugd, which is required for automatic Ethernet configuration. See the announcement.
Users wanting Bash completion support for netcfg, install the bash-completion package from the official repositories.
Configuration
/etc/rc.conf
compatibility. Netcfg users should configure all interfaces in /etc/conf.d/netcfg
instead of /etc/rc.conf
.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, and mynetwork
is used as an example throughout this article.
Depending on the connection type and security, use one of the following examples from /etc/network.d/examples/
as a base.
Connection | Type | Example Profile | Information |
---|---|---|---|
Wired | Dynamic IP | ethernet-dhcp |
|
Static IP | ethernet-static |
||
Routed | ethernet-iproute |
Can be checked with ip route from the iproute2 package.
| |
Wireless | WPA-Personal | wireless-wpa |
Uses a passphrase/pre-shared key. |
WPA-Enterprise | wireless-wpa-config |
The wpa_supplicant configuration is external. | |
wireless-wpa-configsection |
The wpa_supplicant configuration is stored as a string. |
Modify the new configuration file, /etc/network.d/mynetwork
:
- Set
INTERFACE
to the correct wireless or Ethernet interface. This can be checked withip link
andiwconfig
. - Ensure the
ESSID
andKEY
(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 that WEP string keys (not hex keys) must be specified with a leading
$
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.chmod 0600 /etc/network.d/mynetwork
) to make it readable by root only./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'
. However, this key can also be used by anyone to get on your network, and thus must be protected just as well as the cleartext key. The hexadecimal encoding is more convenient if you use special characters that are hard to express in scripts.Manual Operation
To connect a profile:
# netcfg mynetwork
To disconnect a profile:
# netcfg down mynetwork
If successful, users can configure netcfg to connect automatically or during boot. If the connection fails, see Netcfg Troubleshooting for solutions and for how to ask for help.
It is also possible to use an interactive menu (dialog package is required):
netcfg-menu
Additionally, see:
$ netcfg help
Automatic Operation
Just one profile
In the simplest case, only one profile will be used and is always desired to start on boot:
# systemctl enable netcfg@myprofile
Net-Profiles
Edit the NETWORKS
array in /etc/conf.d/netcfg
to refer to the network config file /etc/network.d/mynetwork
.
/etc/conf.d/netcfg
NETWORKS=(mynetwork yournetwork)
Start the service on startup:
# systemctl enable netcfg
Alternatively, the profiles that were active at last shutdown can be restored by setting the NETWORKS
array to last
.
/etc/conf.d/netcfg
NETWORKS=(last)
NETWORKS=(last)
to work, you will have to connect to your network manually first and then stop the daemon for Netcfg to remember the network. You can stop the Netcfg daemon by running netcfg-daemon stop
as root.NETWORKS=(menu)
setting cannot be used anymore when switching to systemd. See FS#31377 for details.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
or wireless-wpa
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 net-auto-wireless
so systemd manages it.
# systemctl enable net-auto-wireless
Net-Auto-Wired
This allows users to automatically connect to wired networks. To use this feature, the ifplugd package is required.
Specify the desired wired interface with the WIRED_INTERFACE
variable in /etc/conf.d/netcfg
.
Enable net-auto-wired
so systemd manages it.
# systemctl enable 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 "ethernet-iproute"
and INTERFACE = WIRED_INTERFACE
until one of them succeeds.
AUTO_WIRED=1
to the desired profile.net-auto-wired
daemon cannot start multiple ifplugd processes for multiple interfaces (unlike ifplugd's own /etc/rc.d/ifplugd
which can).