Difference between revisions of "Network configuration"

From ArchWiki
Jump to: navigation, search
(IP address aliasing: Add what IP address aliasing is.)
(major clean-up / various improvements. Updated /etc/hosts to match the one from the Beginners' Guide)
Line 23: Line 23:
 
{{Article summary end}}
 
{{Article summary end}}
  
==Check first==
+
== Check first ==
 +
 
 
Many times, the basic installation procedure has created a working network configuration.  To check if this is so, use the following command:
 
Many times, the basic installation procedure has created a working network configuration.  To check if this is so, use the following command:
{{hc|ping -c 3 www.google.com|<nowiki>
+
 
 +
{{hc|$ ping -c 3 www.google.com|2=
 
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.
 
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.
 
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms
 
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms
Line 33: Line 35:
 
--- www.l.google.com ping statistics ---
 
--- www.l.google.com ping statistics ---
 
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
 
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms
+
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms}}
</nowiki>}}
+
 
 
{{Tip| The {{ic|-c 3}} options instruct {{ic|ping}} to do so three times.  See {{ic|man ping}} for more information.}}
 
{{Tip| The {{ic|-c 3}} options instruct {{ic|ping}} to do so three times.  See {{ic|man ping}} for more information.}}
  
Line 40: Line 42:
  
 
If the previous command complains about unknown hosts, it means that your machine was unable to resolve this domain name. It might be related to your service provider or your router/gateway. You can try pinging a static IP address to prove that your machine has access to the Internet.
 
If the previous command complains about unknown hosts, it means that your machine was unable to resolve this domain name. It might be related to your service provider or your router/gateway. You can try pinging a static IP address to prove that your machine has access to the Internet.
{{hc |
+
 
ping -c 3 8.8.8.8 |
+
{{hc|$ ping -c 3 8.8.8.8|2=
<nowiki>PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
+
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
 
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms
 
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms
 
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms
 
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms
Line 49: Line 51:
 
--- 8.8.8.8 ping statistics ---
 
--- 8.8.8.8 ping statistics ---
 
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
 
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms</nowiki>}}
+
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms}}
  
 
{{Tip|8.8.8.8 is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.}}
 
{{Tip|8.8.8.8 is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.}}
Line 55: Line 57:
 
If you are able to ping this address, you may try [[Configuring_Network#For_Static_IP_Addresses|adding this nameserver to your resolv.conf file]].
 
If you are able to ping this address, you may try [[Configuring_Network#For_Static_IP_Addresses|adding this nameserver to your resolv.conf file]].
  
==Set the host name==
+
== Set the host name ==
A host name is a unique name created to identify a machine on a network. With Arch Linux, a machine's host name is set in {{ic|/etc/hostname}}.
+
 
Host names are restricted to alphanumeric characters. The hyphen ({{ic|-}}) can be used, but a host name cannot start or end with it. Length is restricted to 63 characters.  
+
A host name is a unique name created to identify a machine on a network. With Arch Linux, a machine's host name is set in {{ic|/etc/hostname}}. Host names are restricted to alphanumeric characters. The hyphen ({{ic|-}}) can be used, but a host name cannot start or end with it. Length is restricted to 63 characters.  
  
 
Simply put your host name in {{ic|/etc/hostname}}; do not put a domain name in {{ic|/etc/hostname}}. Create the file if it does not exist. In this example, {{ic|archlinux}} is the host name:
 
Simply put your host name in {{ic|/etc/hostname}}; do not put a domain name in {{ic|/etc/hostname}}. Create the file if it does not exist. In this example, {{ic|archlinux}} is the host name:
 +
 
{{hc|/etc/hostname|
 
{{hc|/etc/hostname|
archlinux
+
'''myhostname''' }}
}}
+
  
 
After setting a host name, it is important to include the same host name in {{ic|/etc/hosts}}.  This will help processes that refer to the computer by its host name to find its IP address, as well as programs that rely on the {{ic|gethostname()}} system call to determine the system's host name.
 
After setting a host name, it is important to include the same host name in {{ic|/etc/hosts}}.  This will help processes that refer to the computer by its host name to find its IP address, as well as programs that rely on the {{ic|gethostname()}} system call to determine the system's host name.
  
Edit {{ic|/etc/hosts}} and add the same HOSTNAME you entered in {{ic|/etc/hostname}}:
+
Edit {{ic|/etc/hosts}} and add the same name you entered in {{ic|/etc/hostname}}:
  127.0.0.1     archlinux.domain.org   localhost.localdomain      localhost   archlinux
+
 
 +
  127.0.0.1  '''myhostname''' localhost
 +
::1        '''myhostname''' localhost
  
 
{{Note|The fully qualified domain name (FQDN) should be '''the first item following the IP address'''. All of the names on the right side are just aliases for the left-most host/domain name. You can check if this has been properly configured by running {{ic|hostname --fqdn}}.}}
 
{{Note|The fully qualified domain name (FQDN) should be '''the first item following the IP address'''. All of the names on the right side are just aliases for the left-most host/domain name. You can check if this has been properly configured by running {{ic|hostname --fqdn}}.}}
  
 
To set the host name temporarily, until the next reboot, use the {{ic|hostname}} command from package {{Pkg|inetutils}} as root:
 
To set the host name temporarily, until the next reboot, use the {{ic|hostname}} command from package {{Pkg|inetutils}} as root:
{{bc|# hostname archlinux}}
+
 
 +
# hostname archlinux
  
 
== Device Driver ==
 
== Device Driver ==
  
 
=== Check Driver Status ===
 
=== Check Driver Status ===
 +
 
Udev should detect your network interface card (NIC) module and load it automatically at start up. Check the "Ethernet controller" entry in the output of {{ic|lspci -v}}. It should tell you which kernel module contains the driver of your network device. For example:
 
Udev should detect your network interface card (NIC) module and load it automatically at start up. Check the "Ethernet controller" entry in the output of {{ic|lspci -v}}. It should tell you which kernel module contains the driver of your network device. For example:
{{hc|lspci -v|<nowiki>
+
 
 +
{{hc|$ lspci -v|
 
  02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)
 
  02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)
 
  ...
 
  ...
 
  Kernel driver in use: atl1
 
  Kernel driver in use: atl1
  Kernel modules: atl1
+
  Kernel modules: atl1}}
</nowiki>}}
+
  
 
Next, check that the driver was loaded via ''dmesg | grep <module name>''. For example:
 
Next, check that the driver was loaded via ''dmesg | grep <module name>''. For example:
  dmesg |grep atl1
+
 
 +
  $ dmesg | grep atl1
 
     ...
 
     ...
 
     atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex
 
     atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex
Line 93: Line 100:
  
 
=== Load the device module ===
 
=== Load the device module ===
 +
 
Google for the right module/driver for the chip. Once you know which module to use, you can load it with:
 
Google for the right module/driver for the chip. Once you know which module to use, you can load it with:
 +
 
  # modprobe <modulename>
 
  # modprobe <modulename>
  
 
If [[udev]] is not detecting and loading the proper module automatically during bootup, you can add it into the {{ic|MODULES}} array in {{ic|/etc/rc.conf}} so you do not need to {{ic|modprobe}} it everytime you boot. For example, if {{ic|tg3}} is the network module:
 
If [[udev]] is not detecting and loading the proper module automatically during bootup, you can add it into the {{ic|MODULES}} array in {{ic|/etc/rc.conf}} so you do not need to {{ic|modprobe}} it everytime you boot. For example, if {{ic|tg3}} is the network module:
 +
 
  MODULES=(... tg3 snd-cmipci ...)
 
  MODULES=(... tg3 snd-cmipci ...)
  
Line 104: Line 114:
  
 
=== Persistent Device Names ===
 
=== Persistent Device Names ===
 +
 
For motherboards that have integrated NICs, it is important to know which one is considered the primary NIC (e.g., ''eth0'') and which is considered the secondary NIC (e.g., eth1). Many configuration issues are caused by users incorrectly configuring ''eth0'' in their {{ic|/etc/rc.conf}}, when in fact, they have their Ethernet cable plugged into ''eth1''.  
 
For motherboards that have integrated NICs, it is important to know which one is considered the primary NIC (e.g., ''eth0'') and which is considered the secondary NIC (e.g., eth1). Many configuration issues are caused by users incorrectly configuring ''eth0'' in their {{ic|/etc/rc.conf}}, when in fact, they have their Ethernet cable plugged into ''eth1''.  
  
Line 109: Line 120:
  
 
=== Get Current Device Names ===
 
=== Get Current Device Names ===
 +
 
Current NIC Names can be found with the ''ip'' tool.
 
Current NIC Names can be found with the ''ip'' tool.
{{hc|<nowiki>$ ip addr | sed '/^[0-9]/!d;s/: <.*$//'</nowiki>|
+
 
 +
{{hc|<nowiki># ip addr | sed '/^[0-9]/!d;s/: <.*$//'</nowiki>|
 
1: lo
 
1: lo
 
2: eth1
 
2: eth1
Line 117: Line 130:
  
 
=== Enable/disable interface ===
 
=== Enable/disable interface ===
 +
 
You can activate or deactivate net interface:
 
You can activate or deactivate net interface:
  ip link set <interface> up/down
+
 
 +
  # ip link set <interface> up/down
  
 
Check the result with {{ic|ip addr show dev eth0}}. For example:
 
Check the result with {{ic|ip addr show dev eth0}}. For example:
{{hc|ip addr show dev eth0|<nowiki>
+
 
 +
{{hc|# ip addr show dev eth0|
 
   2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc vboxnetflt state UP qlen 1000
 
   2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc vboxnetflt state UP qlen 1000
   [...]
+
   [...]}}
</nowiki>}}
+
  
 
== Configure the IP address ==
 
== Configure the IP address ==
 +
 
You have two options: a dynamically assigned address using DHCP or an unchanging "static" address. See [[Wikipedia:Dynamic Host Configuration Protocol|Wikipedia:DHCP]] for more information.
 
You have two options: a dynamically assigned address using DHCP or an unchanging "static" address. See [[Wikipedia:Dynamic Host Configuration Protocol|Wikipedia:DHCP]] for more information.
 
   
 
   
Line 133: Line 149:
 
==== Manually run DHCP Client Daemon ====
 
==== Manually run DHCP Client Daemon ====
  
Please note that dhcpcd is not dhcpd.
+
Please note that {{ic|dhcpcd}} is not {{ic|dhcpd}}.
  
{{hc|dhcpcd eth0|<nowiki>
+
{{hc|$ dhcpcd eth0|
 
  dhcpcd: version 5.1.1 starting
 
  dhcpcd: version 5.1.1 starting
 
  dhcpcd: eth0: broadcasting for a lease
 
  dhcpcd: eth0: broadcasting for a lease
 
  ...
 
  ...
  dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds
+
  dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds}}
</nowiki>}}
+
  
 
And now {{ic|ip addr show dev <interface>}} should show your inet address.
 
And now {{ic|ip addr show dev <interface>}} should show your inet address.
Line 149: Line 164:
  
 
For this option, you need the {{Pkg|dhcpcd}} package (already available on most installations). To make use of it, edit {{ic|[[Rc.conf#Networking|/etc/rc.conf]]}} like this:
 
For this option, you need the {{Pkg|dhcpcd}} package (already available on most installations). To make use of it, edit {{ic|[[Rc.conf#Networking|/etc/rc.conf]]}} like this:
 +
 
  interface="eth0"
 
  interface="eth0"
 
  address=
 
  address=
Line 157: Line 173:
  
 
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|/etc/dhcpcd.conf}}:
 
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|/etc/dhcpcd.conf}}:
 +
 
  nohook resolv.conf
 
  nohook resolv.conf
  
 
To prevent dhcpcd from adding domain name servers to {{ic|/etc/resolve.conf}} use the nooption option in {{ic|/etc/dhcpcd.conf}}:
 
To prevent dhcpcd from adding domain name servers to {{ic|/etc/resolve.conf}} use the nooption option in {{ic|/etc/dhcpcd.conf}}:
 +
 
  nooption domain_name_servers
 
  nooption domain_name_servers
  
Line 166: Line 184:
 
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g., {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.
 
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g., {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.
  
{{Note|1=It is possible to have a static IP address using {{Pkg|dhcpcd}}. Simply edit your {{ic|/etc/conf.d/dhcpcd}} file to look something like this (where x.x.x.x is your desired IP address):
+
{{Note|It is possible to have a static IP address using {{Pkg|dhcpcd}}. Simply edit your {{ic|/etc/conf.d/dhcpcd}} file to look something like this (where {{ic|x.x.x.x}} is your desired IP address):
DHCPCD_ARGS="-q -s x.x.x.x"}}
+
{{bc|1=DHCPCD_ARGS="-q -s x.x.x.x"}}}}
  
 
=== Static IP address ===
 
=== Static IP address ===
 +
 
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability.  Or you may not want the dhcp daemon running all the time.  
 
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability.  Or you may not want the dhcp daemon running all the time.  
  
Line 175: Line 194:
  
 
You need:
 
You need:
 +
 
* Static IP address,
 
* Static IP address,
 
* Subnet mask,
 
* Subnet mask,
Line 183: Line 203:
  
 
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a netmask of 255.255.255.0 and a broadcast address of 192.168.*.255. Unless your network has a router, the gateway IP address does not matter.  Edit {{ic|/etc/rc.conf}} like this, substituting your own values for the IP address, netmask, broadcast, and gateway:
 
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a netmask of 255.255.255.0 and a broadcast address of 192.168.*.255. Unless your network has a router, the gateway IP address does not matter.  Edit {{ic|/etc/rc.conf}} like this, substituting your own values for the IP address, netmask, broadcast, and gateway:
 +
 
  interface=eth0
 
  interface=eth0
 
  address=192.168.0.2
 
  address=192.168.0.2
Line 190: Line 211:
  
 
Edit your {{ic|/etc/resolv.conf}} like this, substituting your name servers' IP addresses and your local domain name:
 
Edit your {{ic|/etc/resolv.conf}} like this, substituting your name servers' IP addresses and your local domain name:
 +
 
  nameserver 61.23.173.5
 
  nameserver 61.23.173.5
 
  nameserver 61.95.849.8
 
  nameserver 61.95.849.8
Line 195: Line 217:
  
 
{{Note|Currently, you may include a maximum of 3 {{ic|nameserver}} lines.}}
 
{{Note|Currently, you may include a maximum of 3 {{ic|nameserver}} lines.}}
 +
 
{{Note|For those looking to optimize/benchmark their resolver selection, give [https://www.grc.com/dns/benchmark.htm GRC's DNS Benchmark] a look.}}
 
{{Note|For those looking to optimize/benchmark their resolver selection, give [https://www.grc.com/dns/benchmark.htm GRC's DNS Benchmark] a look.}}
  
====Manual assignment====
+
==== Manual assignment ====
 +
 
 
You can assign a static IP address in the console:
 
You can assign a static IP address in the console:
 +
 
  # ip addr add <ip address>/<netmask> dev <interface>
 
  # ip addr add <ip address>/<netmask> dev <interface>
 +
 
For example:
 
For example:
 +
 
  # ip addr add 192.168.1.2/24 dev eth0
 
  # ip addr add 192.168.1.2/24 dev eth0
  
For more options, see: {{ic|man ip}}
+
For more options, see {{ic|man ip}}.
  
 
Add your gateway like so:
 
Add your gateway like so:
 +
 
  # ip route add default via <ip address>
 
  # ip route add default via <ip address>
 +
 
(Substitute your own gateway's IP address)
 
(Substitute your own gateway's IP address)
  
 
For example:
 
For example:
 +
 
  # ip route add default via 192.168.1.1
 
  # ip route add default via 192.168.1.1
  
If you the get the error "No such process", it means you have to run {{Ic|# ip link set dev eth0 up}}.
+
If you the get the error "No such process", it means you have to run {{ic|# ip link set dev eth0 up}}.
  
 
==== Calculating Addresses ====
 
==== Calculating Addresses ====
You can use ''ipcalc'' provided by the ipcalc package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations.  For example, I use ethernet over firewire to connect a windows machine to arch.  For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it.  To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.
+
 
 +
You can use {{ic|ipcalc}} provided by the ipcalc package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations.  For example, I use ethernet over firewire to connect a windows machine to arch.  For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it.  To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.
  
 
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=
 
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=
Line 227: Line 258:
 
Hosts/Net: 2                    Class A, Private Internet}}
 
Hosts/Net: 2                    Class A, Private Internet}}
  
==Load configuration==
+
== Load configuration ==
 +
 
 
To test your settings either reboot the computer, or as root:
 
To test your settings either reboot the computer, or as root:
{{bc|rc.d restart network}}
+
 
 +
# rc.d restart network
  
 
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:
 
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:
{{bc|ping -c 3 www.google.com}}
 
  
==Additional settings==
+
$ ping -c 3 www.google.com
 +
 
 +
== Additional settings ==
  
 
=== ifplugd for laptops ===
 
=== ifplugd for laptops ===
 +
 
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.
 
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.
  
Line 245: Line 280:
 
Alternatively with systemd, enabling {{ic|net-auto-wired.service}} should start ifplugd on bootup if you have {{Pkg|netcfg}} installed, otherwise you can use {{ic|ifplugd@eth0.service}}.
 
Alternatively with systemd, enabling {{ic|net-auto-wired.service}} should start ifplugd on bootup if you have {{Pkg|netcfg}} installed, otherwise you can use {{ic|ifplugd@eth0.service}}.
  
===Bonding or LAG===
+
=== Bonding or LAG ===
 +
 
 
You will need {{Pkg|netcfg}} from the [[Official Repositories]], as well as the {{AUR|netcfg-bonding}} package from the [[AUR]].
 
You will need {{Pkg|netcfg}} from the [[Official Repositories]], as well as the {{AUR|netcfg-bonding}} package from the [[AUR]].
  
 
Edit/create the following files:
 
Edit/create the following files:
{{hc
+
 
|/etc/network.d/bonded
+
{{hc|/etc/network.d/bonded|2=
|<nowiki>
+
 
  CONNECTION="bonding"
 
  CONNECTION="bonding"
 
  INTERFACE="bond0"
 
  INTERFACE="bond0"
 
  SLAVES="eth0 eth1"
 
  SLAVES="eth0 eth1"
 
  IP="dhcp"
 
  IP="dhcp"
  DHCP_TIMEOUT=10
+
  DHCP_TIMEOUT=10}}
</nowiki>}}
+
  
{{hc
+
{{hc|/etc/rc.conf|2=
|/etc/rc.conf
+
|<nowiki>
+
 
  MODULES=(... bonding ...)
 
  MODULES=(... bonding ...)
 
...
 
...
Line 268: Line 300:
 
  NETWORKS=(... bonded ...)
 
  NETWORKS=(... bonded ...)
 
...
 
...
  DAEMONS=(... net-profiles ...) #replace network  
+
  DAEMONS=(... net-profiles ...) #Replace "network".}}
</nowiki>}}
+
  
 
{{Note|To change the bonding mode (default is round robin) to, e.g, dynamic link aggregation:
 
{{Note|To change the bonding mode (default is round robin) to, e.g, dynamic link aggregation:
  
 
Create {{ic|/etc/modprobe.d/bonding.conf}}:
 
Create {{ic|/etc/modprobe.d/bonding.conf}}:
{{hc
+
 
|/etc/modprobe.d/bonding.conf
+
{{hc|/etc/modprobe.d/bonding.conf|2=
|<nowiki>
+
 
options bonding mode=4
 
options bonding mode=4
options bonding miimon=100
+
options bonding miimon=100}}
</nowiki>}}
+
  
 
For more information about the different bonding policies (and other driver settings) see the [http://sourceforge.net/projects/bonding/files/Documentation/ Linux Ethernet Bonding Driver HOWTO].}}
 
For more information about the different bonding policies (and other driver settings) see the [http://sourceforge.net/projects/bonding/files/Documentation/ Linux Ethernet Bonding Driver HOWTO].}}
Line 291: Line 320:
 
To check the status and bonding mode:
 
To check the status and bonding mode:
  
  cat /proc/net/bonding/bond0
+
  $ cat /proc/net/bonding/bond0
 +
 
 +
=== IP address aliasing ===
  
===IP address aliasing===
 
 
IP aliasing is the process of adding more than one IP address to a network interface.  With this, one node on a network can have multiple connections to a network, each serving a different purpose.
 
IP aliasing is the process of adding more than one IP address to a network interface.  With this, one node on a network can have multiple connections to a network, each serving a different purpose.
  
 
To use IP aliasing from [[netcfg]], change {{ic|POST_UP}} and {{ic|PRE_DOWN}} commands in your network profile to set up the additional IP addresses manually. See [https://bbs.archlinux.org/viewtopic.php?pid=1036395#p1036395 here] for details.
 
To use IP aliasing from [[netcfg]], change {{ic|POST_UP}} and {{ic|PRE_DOWN}} commands in your network profile to set up the additional IP addresses manually. See [https://bbs.archlinux.org/viewtopic.php?pid=1036395#p1036395 here] for details.
  
====Example====
+
==== Example ====
 +
 
 
You will need {{Pkg|netcfg}} from the [[Official Repositories]].
 
You will need {{Pkg|netcfg}} from the [[Official Repositories]].
  
Prepare configuration
+
Prepare the configuration:
  
{{hc
+
{{hc|/etc/network.d/mynetwork|2=
|/etc/network.d/mynetwork
+
|<nowiki>
+
  
 
CONNECTION='ethernet'
 
CONNECTION='ethernet'
Line 316: Line 345:
 
DOMAIN=''
 
DOMAIN=''
 
POST_UP='x=0; for i in 11 12 13 14; do ip addr add 192.168.1.$i/24 brd 192.168.1.255 dev eth0 label eth0:$((x++)); done'
 
POST_UP='x=0; for i in 11 12 13 14; do ip addr add 192.168.1.$i/24 brd 192.168.1.255 dev eth0 label eth0:$((x++)); done'
PRE_DOWN='for i in 11 12 13 14; do ip addr del 192.168.1.$i/24 dev eth0; done'
+
PRE_DOWN='for i in 11 12 13 14; do ip addr del 192.168.1.$i/24 dev eth0; done'}}
  
</nowiki>}}
+
{{hc|/etc/rc.conf|2=
 
+
{{hc
+
|/etc/rc.conf
+
|<nowiki>
+
 
NETWORKS=(mynetwork)
 
NETWORKS=(mynetwork)
  
 
...
 
...
  
DAEMONS=(... net-profiles ...)
+
DAEMONS=(... net-profiles ...)}}
</nowiki>}}
+
 
 +
=== Change MAC/hardware address ===
  
===Change MAC/hardware address===
 
 
Changing your MAC address is not possible anymore via {{ic|/etc/rc.conf}}. See [[MAC Address Spoofing]] for details.
 
Changing your MAC address is not possible anymore via {{ic|/etc/rc.conf}}. See [[MAC Address Spoofing]] for details.
  
==Troubleshooting==
+
== Troubleshooting ==
 +
 
 +
=== Swapping computers on the cable modem ===
  
===Swapping computers on the cable modem===
 
 
Most domestic cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.
 
Most domestic cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.
  
 
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].
 
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].
  
===The TCP window scaling issue===
+
=== The TCP window scaling issue ===
 +
 
 
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.
 
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.
  
Line 353: Line 380:
 
The resulting connection is at best very slow or broken.
 
The resulting connection is at best very slow or broken.
  
====How to diagnose the problem====
+
==== How to diagnose the problem ====
 +
 
 
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).
 
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).
  
Line 362: Line 390:
 
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).
 
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).
  
====How to fix it (The bad way)====
+
==== How to fix it (The bad way) ====
 +
 
 
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.
 
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.
  
  echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem
+
  # echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem
 +
 
 +
==== How to fix it (The good way) ====
  
====How to fix it (The good way)====
 
 
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.conf}} (see also [[sysctl]])
 
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.conf}} (see also [[sysctl]])
  
 
  net.ipv4.tcp_window_scaling = 0
 
  net.ipv4.tcp_window_scaling = 0
  
====How to fix it (The best way)====
+
==== How to fix it (The best way) ====
 +
 
 
This issue is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.
 
This issue is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.
  
====More about it====
+
==== More about it ====
 +
 
 
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].
 
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].
  
 
There are also several relevant threads on the LKML.
 
There are also several relevant threads on the LKML.
  
===Realtek no link / WOL issue===
+
=== Realtek no link / WOL issue ===
 +
 
 
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice an issue where the NIC seems to be disabled on boot and has no Link light.  This can usually be found on a dual boot system where Windows is also installed.  It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause.  These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots.  You will be able to notice if this issue is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off.  Normal operation should be that the link light is always on as long as the system is on, even during POST.  This issue will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this issue:
 
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice an issue where the NIC seems to be disabled on boot and has no Link light.  This can usually be found on a dual boot system where Windows is also installed.  It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause.  These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots.  You will be able to notice if this issue is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off.  Normal operation should be that the link light is always on as long as the system is on, even during POST.  This issue will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this issue:
  
====Method 1 - Rollback/change Windows driver====
+
==== Method 1 - Rollback/change Windows driver ====
 +
 
 
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).
 
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).
  
====Method 2 - Enable WOL in Windows driver====
+
==== Method 2 - Enable WOL in Windows driver ====
 +
 
 
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems).  In Windows, under Device Manager, find your Realtek network adapter and double-click it.  Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.
 
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems).  In Windows, under Device Manager, find your Realtek network adapter and double-click it.  Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.
 +
 
  In Windows XP (example)
 
  In Windows XP (example)
 
  Right click my computer
 
  Right click my computer
Line 400: Line 436:
 
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}
 
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}
  
====Method 3 - Newer Realtek Linux driver====
+
==== Method 3 - Newer Realtek Linux driver ====
 +
 
 
Any newer driver for these Realtek cards can be found for Linux on the realtek site.  (untested but believed to also solve the problem).
 
Any newer driver for these Realtek cards can be found for Linux on the realtek site.  (untested but believed to also solve the problem).
  
====Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS====
+
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====
 +
 
 
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.
 
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.
 
<br><small>This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.</small>
 
<br><small>This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.</small>
  
===DLink G604T/DLink G502T DNS issue===
+
=== DLink G604T/DLink G502T DNS issue ===
 +
 
 
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have issues with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error
 
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have issues with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error
  
====How to diagnose the problem====
+
==== How to diagnose the problem ====
 +
 
 
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.
 
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.
  
Line 421: Line 461:
  
 
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),
 
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),
  <nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki>                                                          
+
 
             <nowiki>=> `/var/lib/pacman/community.db.tar.gz.part'</nowiki>
+
  <nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki>
 +
             => '/var/lib/pacman/community.db.tar.gz.part'
 
  Resolving mirror.pacific.net.au... 1.0.0.0
 
  Resolving mirror.pacific.net.au... 1.0.0.0
 +
 
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.
 
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.
  
====How to fix it====
+
==== How to fix it ====
 +
 
 
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.
 
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.
  
 
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:
 
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:
 +
 
  DHCPCD_ARGS="-t 30 -h $HOSTNAME"
 
  DHCPCD_ARGS="-t 30 -h $HOSTNAME"
 +
 
Add the -R flag to the arguments, e.g.,
 
Add the -R flag to the arguments, e.g.,
 +
 
  DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
 
  DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
  
Line 438: Line 484:
 
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.
 
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.
  
E.g., {{ic|/etc/resolv.conf}} should look something along the lines of
+
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:
 +
 
 
  nameserver 10.1.1.1
 
  nameserver 10.1.1.1
  
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to
+
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:
 +
 
 
  nameserver 211.29.132.12
 
  nameserver 211.29.132.12
 
  nameserver 10.1.1.1
 
  nameserver 10.1.1.1
Line 447: Line 495:
 
Now restart the network daemon by doing {{ic|rc.d restart network}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.
 
Now restart the network daemon by doing {{ic|rc.d restart network}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.
  
====More about it====
+
==== More about it ====
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem
+
 
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html
+
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:
 +
 
 +
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html
  
 
=== Check DHCP problem by releasing IP first ===
 
=== Check DHCP problem by releasing IP first ===
  
 
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:
 
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:
 +
 
  # dhcpcd -k
 
  # dhcpcd -k
  
 
Then request a new one:
 
Then request a new one:
 +
 
  # dhcpcd
 
  # dhcpcd
  
 
Maybe you had to run those two commands many times.
 
Maybe you had to run those two commands many times.

Revision as of 12:07, 6 October 2012

zh-CN:Configuring Network 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 wiki Template:Article summary wiki Template:Article summary end

Check first

Many times, the basic installation procedure has created a working network configuration. To check if this is so, use the following command:

$ ping -c 3 www.google.com
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms

--- www.l.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms
Tip: The -c 3 options instruct ping to do so three times. See man ping for more information.

If it works, then you may only wish to personalize your settings from the options below.

If the previous command complains about unknown hosts, it means that your machine was unable to resolve this domain name. It might be related to your service provider or your router/gateway. You can try pinging a static IP address to prove that your machine has access to the Internet.

$ ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms
Tip: 8.8.8.8 is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.

If you are able to ping this address, you may try adding this nameserver to your resolv.conf file.

Set the host name

A host name is a unique name created to identify a machine on a network. With Arch Linux, a machine's host name is set in /etc/hostname. Host names are restricted to alphanumeric characters. The hyphen (-) can be used, but a host name cannot start or end with it. Length is restricted to 63 characters.

Simply put your host name in /etc/hostname; do not put a domain name in /etc/hostname. Create the file if it does not exist. In this example, archlinux is the host name:

/etc/hostname
myhostname 

After setting a host name, it is important to include the same host name in /etc/hosts. This will help processes that refer to the computer by its host name to find its IP address, as well as programs that rely on the gethostname() system call to determine the system's host name.

Edit /etc/hosts and add the same name you entered in /etc/hostname:

127.0.0.1   myhostname localhost
::1         myhostname localhost
Note: The fully qualified domain name (FQDN) should be the first item following the IP address. All of the names on the right side are just aliases for the left-most host/domain name. You can check if this has been properly configured by running hostname --fqdn.

To set the host name temporarily, until the next reboot, use the hostname command from package inetutils as root:

# hostname archlinux

Device Driver

Check Driver Status

Udev should detect your network interface card (NIC) module and load it automatically at start up. Check the "Ethernet controller" entry in the output of lspci -v. It should tell you which kernel module contains the driver of your network device. For example:

$ lspci -v
 02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)
 	...
 	Kernel driver in use: atl1
 	Kernel modules: atl1

Next, check that the driver was loaded via dmesg | grep <module name>. For example:

$ dmesg | grep atl1
   ...
   atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex

If driver loads success, skip this section. Otherwise, you will need to know which module is needed for your particular model.

Load the device module

Google for the right module/driver for the chip. Once you know which module to use, you can load it with:

# modprobe <modulename>

If udev is not detecting and loading the proper module automatically during bootup, you can add it into the MODULES array in /etc/rc.conf so you do not need to modprobe it everytime you boot. For example, if tg3 is the network module:

MODULES=(... tg3 snd-cmipci ...)

Other common modules are 8139too for cards with the Realtek chipset or sis900 for SiS cards.

Network Interfaces

Persistent Device Names

For motherboards that have integrated NICs, it is important to know which one is considered the primary NIC (e.g., eth0) and which is considered the secondary NIC (e.g., eth1). Many configuration issues are caused by users incorrectly configuring eth0 in their /etc/rc.conf, when in fact, they have their Ethernet cable plugged into eth1.

Udev is responsible for which device gets which name. With Udev and modular network drivers, the network interface numbering is not persistent across reboots by default, because the drivers are loaded in parallel and, thus, in random order. Configuring your network connection is hard if you do not know if your card will be called eth0 or eth1. You can fix this using ifrename, see Rename network interfaces. It is also possible to manually create udev rules that assign interface names based on the interface's MAC address. See Persistent Device Names.

Get Current Device Names

Current NIC Names can be found with the ip tool.

# ip addr | sed '/^[0-9]/!d;s/: <.*$//'
1: lo
2: eth1
3: eth0
4: firewire0

Enable/disable interface

You can activate or deactivate net interface:

# ip link set <interface> up/down

Check the result with ip addr show dev eth0. For example:

# ip addr show dev eth0
   2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc vboxnetflt state UP qlen 1000
   [...]

Configure the IP address

You have two options: a dynamically assigned address using DHCP or an unchanging "static" address. See Wikipedia:DHCP for more information.

Dynamic IP address

Manually run DHCP Client Daemon

Please note that dhcpcd is not dhcpd.

$ dhcpcd eth0
 dhcpcd: version 5.1.1 starting
 dhcpcd: eth0: broadcasting for a lease
 ...
 dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds

And now ip addr show dev <interface> should show your inet address.

For some people, the dhclient package (available in [extra]) works where dhcpcd fails.

Run DHCP at booting

For this option, you need the dhcpcd package (already available on most installations). To make use of it, edit /etc/rc.conf like this:

interface="eth0"
address=
netmask=
gateway=

Only the interface has to be defined, as leaving the other options blank will set network to DHCP.

If you use DHCP and you do not want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of /etc/dhcpcd.conf:

nohook resolv.conf

To prevent dhcpcd from adding domain name servers to /etc/resolve.conf use the nooption option in /etc/dhcpcd.conf:

nooption domain_name_servers

Then add your own DNS name server to /etc/resolv.conf.

You may use the openresolv package if several different processes want to control /etc/resolv.conf (e.g., dhcpcd and a VPN client). No additional configuration for dhcpcd is needed to use openresolv.

Note: It is possible to have a static IP address using dhcpcd. Simply edit your /etc/conf.d/dhcpcd file to look something like this (where x.x.x.x is your desired IP address):
DHCPCD_ARGS="-q -s x.x.x.x"

Static IP address

There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability. Or you may not want the dhcp daemon running all the time.

Note: If you share your Internet connection from a Windows box without a router, be sure to use static IP addresses on both computers to avoid LAN issues.

You need:

  • Static IP address,
  • Subnet mask,
  • Broadcast address,
  • Gateway's IP address,
  • Name servers' IP addresses,
  • Domain name (unless a local LAN, in which case you can make it up).

If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a netmask of 255.255.255.0 and a broadcast address of 192.168.*.255. Unless your network has a router, the gateway IP address does not matter. Edit /etc/rc.conf like this, substituting your own values for the IP address, netmask, broadcast, and gateway:

interface=eth0
address=192.168.0.2
netmask=255.255.255.0
broadcast=192.168.1.255
gateway=192.168.22.1

Edit your /etc/resolv.conf like this, substituting your name servers' IP addresses and your local domain name:

nameserver 61.23.173.5
nameserver 61.95.849.8
search example.com
Note: Currently, you may include a maximum of 3 nameserver lines.
Note: For those looking to optimize/benchmark their resolver selection, give GRC's DNS Benchmark a look.

Manual assignment

You can assign a static IP address in the console:

# ip addr add <ip address>/<netmask> dev <interface>

For example:

# ip addr add 192.168.1.2/24 dev eth0

For more options, see man ip.

Add your gateway like so:

# ip route add default via <ip address>

(Substitute your own gateway's IP address)

For example:

# ip route add default via 192.168.1.1

If you the get the error "No such process", it means you have to run # ip link set dev eth0 up.

Calculating Addresses

You can use ipcalc provided by the ipcalc package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.

$ ipcalc -nb 10.66.66.1 -s 1
Address:   10.66.66.1

Netmask:   255.255.255.252 = 30
Network:   10.66.66.0/30
HostMin:   10.66.66.1
HostMax:   10.66.66.2
Broadcast: 10.66.66.3
Hosts/Net: 2                     Class A, Private Internet

Load configuration

To test your settings either reboot the computer, or as root:

# rc.d restart network

Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:

$ ping -c 3 www.google.com

Additional settings

ifplugd for laptops

ifplugd in Official Repositories is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.

By default it is configured to work for the eth0 device. This and other settings like delays can be configured in /etc/ifplugd/ifplugd.conf.

Start the ifplugd daemon and add ifplugd to your DAEMONS array so it starts automatically on boot.

Alternatively with systemd, enabling net-auto-wired.service should start ifplugd on bootup if you have netcfg installed, otherwise you can use ifplugd@eth0.service.

Bonding or LAG

You will need netcfg from the Official Repositories, as well as the netcfg-bondingAUR package from the AUR.

Edit/create the following files:

/etc/network.d/bonded
CONNECTION="bonding"
 INTERFACE="bond0"
 SLAVES="eth0 eth1"
 IP="dhcp"
 DHCP_TIMEOUT=10
/etc/rc.conf
MODULES=(... bonding ...)
...
 interface=bond0 #comment other lines (address,netmask,gateway,...)
...
 NETWORKS=(... bonded ...)
...
 DAEMONS=(... net-profiles ...) #Replace "network".
Note: To change the bonding mode (default is round robin) to, e.g, dynamic link aggregation:

Create /etc/modprobe.d/bonding.conf:

/etc/modprobe.d/bonding.conf
options bonding mode=4
options bonding miimon=100
For more information about the different bonding policies (and other driver settings) see the Linux Ethernet Bonding Driver HOWTO.

To activate the new bonded ports modprobe bonding, stop network and start the net-profiles service:

# modprobe bonding
# rc.d stop network
# rc.d start net-profiles

To check the status and bonding mode:

$ cat /proc/net/bonding/bond0

IP address aliasing

IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose.

To use IP aliasing from netcfg, change POST_UP and PRE_DOWN commands in your network profile to set up the additional IP addresses manually. See here for details.

Example

You will need netcfg from the Official Repositories.

Prepare the configuration:

/etc/network.d/mynetwork
CONNECTION='ethernet'
DESCRIPTION='Five different addresses on the same NIC.'
INTERFACE='eth0'
IP='static'
ADDR='192.168.1.10'
GATEWAY='192.168.1.1'
DNS=('192.168.1.1')
DOMAIN=
POST_UP='x=0; for i in 11 12 13 14; do ip addr add 192.168.1.$i/24 brd 192.168.1.255 dev eth0 label eth0:$((x++)); done'
PRE_DOWN='for i in 11 12 13 14; do ip addr del 192.168.1.$i/24 dev eth0; done'
/etc/rc.conf
NETWORKS=(mynetwork)

...

DAEMONS=(... net-profiles ...)

Change MAC/hardware address

Changing your MAC address is not possible anymore via /etc/rc.conf. See MAC Address Spoofing for details.

Troubleshooting

Swapping computers on the cable modem

Most domestic cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.

If this method does not work, you will need to clone the MAC address of the original machine. See also Change MAC/hardware address.

The TCP window scaling issue

TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.

Back in 1992, as more and more memory became available, RFC 1323 was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.

That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.

It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.

The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.

The resulting connection is at best very slow or broken.

How to diagnose the problem

First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).

When you have this problem, the dmesg's output is OK, logs are clean and ip addr will report normal status... and actually everything appears normal.

If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this issue: ping uses ICMP and is not affected by TCP issues.

You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).

How to fix it (The bad way)

To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.

# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem

How to fix it (The good way)

Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to /etc/sysctl.conf (see also sysctl)

net.ipv4.tcp_window_scaling = 0

How to fix it (The best way)

This issue is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.

More about it

This section is based on the LWN article TCP window scaling and broken routers and a Kernel Trap article: Window Scaling on the Internet.

There are also several relevant threads on the LKML.

Realtek no link / WOL issue

Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice an issue where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this issue is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This issue will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this issue:

Method 1 - Rollback/change Windows driver

You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).

Method 2 - Enable WOL in Windows driver

Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.

In Windows XP (example)
Right click my computer
--> Hardware tab
  --> Device Manager
    --> Network Adapters
      --> "double click" Realtek ...
        --> Advanced tab
          --> Wake-On-Lan After Shutdown
            --> Enable
Note: Newer Realtek Windows drivers (tested with Realtek 8111/8169 LAN Driver v5.708.1030.2008, dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like Shutdown Wake-On-LAN --> Enable. It seems that switching it to Disable has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.

Method 3 - Newer Realtek Linux driver

Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).

Method 4 - Enable LAN Boot ROM in BIOS/CMOS

It appears that setting Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.
This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.

DLink G604T/DLink G502T DNS issue

Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have issues with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error

How to diagnose the problem

The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing links through the live CD.

Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages) Open /etc/pacman.conf with your favourite editor and uncomment the following line (remove the # if it is there)

XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u

While you are editing /etc/pacman.conf, check the default mirror that pacman uses to download packages.

Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do pacman -Syy (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),

ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz
           => '/var/lib/pacman/community.db.tar.gz.part'
Resolving mirror.pacific.net.au... 1.0.0.0

then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to /etc/resolv.conf.

How to fix it

Basically what we need to do is to manually add the DNS servers to our /etc/resolv.conf file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit /etc/conf.d/dhcpcd and change the flags to stop DHCP from doing this.

When you open /etc/conf.d/dhcpcd, you should see something close to the following:

DHCPCD_ARGS="-t 30 -h $HOSTNAME"

Add the -R flag to the arguments, e.g.,

DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
Note: If you are using dhcpcd >= 4.0.2, the -R flag has been deprecated. Please see the #For DHCP assigned IP address section for information on how to use a custom /etc/resolv.conf file.

Save and close the file; now open /etc/resolv.conf. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver ABOVE the current gateway one.

For example, /etc/resolv.conf should look something along the lines of:

nameserver 10.1.1.1

If my primary DNS server is 211.29.132.12, then change /etc/resolv.conf to:

nameserver 211.29.132.12
nameserver 10.1.1.1

Now restart the network daemon by doing rc.d restart network and do pacman -Syy. If it syncs correctly with the server, then the problem is solved.

More about it

This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:

http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html

Check DHCP problem by releasing IP first

Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:

# dhcpcd -k

Then request a new one:

# dhcpcd

Maybe you had to run those two commands many times.