Difference between revisions of "Network configuration"

From ArchWiki
Jump to: navigation, search
m (Manually run DHCP Client Daemon: dhcpcd will not work correctly unless run as root)
(simplification and beautification of wikilinks, fixing whitespace, capitalization and section fragments (https://github.com/lahwaacz/wiki-scripts/blob/master/link-checker.py (interactive)))
 
(387 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
[[Category:Networking]]
+
[[Category:Network configuration]]
[[Category:Getting and installing Arch]]
+
[[cs:Network configuration]]
[[cs:Configuring Network]]
+
[[el:Network configuration]]
[[es:Configuring Network]]
+
[[es:Network configuration]]
 
[[fr:Connexions reseau]]
 
[[fr:Connexions reseau]]
[[it:Configuring Network]]
+
[[it:Network configuration]]
[[nl:Configuring Network]]
+
[[ja:ネットワーク設定]]
[[pt:Configuring Network]]
+
[[nl:Network configuration]]
 +
[[pt:Network configuration]]
 
[[ro:Configurare retea]]
 
[[ro:Configurare retea]]
[[ru:Configuring Network]]
+
[[ru:Network configuration]]
[[sk:Configuring Network]]
+
[[sk:Network configuration]]
[[tr:Ağ_Yapılandırması]]
+
[[tr:Ağ Yapılandırması]]
[[zh-CN:Configuring Network]]
+
[[zh-cn:Network configuration]]
{{Article summary start}}
+
[[zh-tw:Network configuration]]
{{Article summary text|A simple guide for setting up and troubleshooting network.}}
+
{{Related articles start}}
{{Article summary heading|Overview}}
+
{{Related|Jumbo frames}}
{{Article summary text|{{Networking overview}}}}
+
{{Related|Firewalls}}
{{Article summary heading|Related}}
+
{{Related|Wireless network configuration}}
{{Article summary wiki|Jumbo Frames}}
+
{{Related|Network bridge}}
{{Article summary wiki|Firewalls}}
+
{{Related|List of applications/Internet#Network managers}}
{{Article summary wiki|Samba}}
+
{{Related articles end}}
{{Article summary wiki|Wireless Setup}}
+
 
{{Article summary end}}
+
This page explains how to set up a '''wired''' connection to a network. If you need to set up '''wireless''' networking see the [[Wireless network configuration]] page.
  
 
== Check the connection ==
 
== Check the connection ==
  
Many times, the basic installation procedure has created a working network configuration. To check if this is so, use the following command:
+
The basic installation procedure typically has a functional network configuration. Use ''ping'' to check the connection:
  
{{Note|The {{ic|-c 3}} option calls it three times. See {{ic|man ping}} for more information.}}
+
{{hc|$ ping www.google.com|2=
 +
PING www.l.google.com (74.125.132.105) 56(84) bytes of data.
 +
64 bytes from wb-in-f105.1e100.net (74.125.132.105): icmp_req=1 ttl=50 time=17.0 ms
 +
...
 +
}}
  
{{hc|$ ping -c 3 www.google.com|2=
+
If the ping is successful (you see 64 bytes messages as above), then the network is configured. Press {{ic|Control-C}} to stop the ping.
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 ---
+
If the ping failed with an ''Unknown hosts'' error, it  means that your machine was unable to resolve this domain name. It may be related to your service provider or your router/gateway. Try pinging a static IP address to prove that your machine has access to the Internet:
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
+
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms}}
+
  
If it works, then you may only wish to personalize your settings from the options below.
+
{{hc|$ ping 8.8.8.8|<nowiki>
 
+
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|2=
+
 
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=3 ttl=53 time=70.6 ms
+
</nowiki>}}
  
--- 8.8.8.8 ping statistics ---
+
If you are able to ping {{ic|8.8.8.8}} but not {{ic|www.google.com}}, check your DNS configuration. See [[resolv.conf]] for details. The {{ic|hosts}} line in {{ic|/etc/nsswitch.conf}} is another place you can check.
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
+
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms}}
+
  
{{Note|{{ic|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 not, check for cable issues before diagnosing further.
  
If you are able to ping this address, you may try adding this nameserver to your {{ic|/etc/resolv.conf}} file.
+
{{Note|
 +
* If you receive an error like {{ic|ping: icmp open socket: Operation not permitted}} when executing ''ping'', try to re-install the {{Pkg|iputils}} package.
 +
* The {{ic|-c ''num''}} option can be used to make exactly {{ic|''num''}} pings, otherwise it pings infinitely and has to be terminated manually. See {{ic|man ping}} for more information.
 +
* {{ic|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.
 +
}}
  
 
== Set the hostname ==
 
== Set the hostname ==
  
A [[Wikipedia:Hostname|hostname]] is a unique name created to identify a machine on a network. To set the hostname:  
+
A [[Wikipedia:Hostname|hostname]] is a unique name created to identify a machine on a network: it is configured in {{ic|/etc/hostname}}. The file can contain the system's domain name, if any. To set the hostname, do:
# hostnamectl set-hostname '''myhostname'''
+
  
{{Note|You no longer need to edit {{ic|/etc/hosts}}, {{pkg|nss-myhostname}} will provide host name resolution, and is installed on all systems by default.}}
+
# hostnamectl set-hostname ''myhostname''
  
To set the hostname temporarily (until a reboot), use the {{ic|hostname}} command from {{Pkg|inetutils}}:
+
This will put {{ic|''myhostname''}} into {{ic|/etc/hostname}}. See {{ic|man 5 hostname}} and {{ic|man 1 hostnamectl}} for details.
 +
 
 +
It is recommended to also set the hostname in {{ic|/etc/hosts}}:
 +
 
 +
{{hc|/etc/hosts|2=
 +
#
 +
# /etc/hosts: static lookup table for host names
 +
#
 +
 
 +
#<ip-address> <hostname.domain.org> <hostname>
 +
127.0.0.1 localhost.localdomain localhost ''myhostname''
 +
::1 localhost.localdomain localhost ''myhostname''
 +
}}
 +
 
 +
{{Note|{{Pkg|systemd}} provides hostname resolution via the {{ic|myhostname}} nss module (enabled by default in {{ic|/etc/nsswitch.conf}}), which means that changing hostnames in {{ic|/etc/hosts}} is normally not necessary. However several users have reported bugs such as delays in network-based applications when the hostname was not set correctly in {{ic|/etc/hosts}}. See [[#Local network hostname resolution]] for details.}}
 +
 
 +
To temporarily set the hostname (until reboot), use ''hostname'' from {{Pkg|inetutils}}:
  
 
  # hostname ''myhostname''
 
  # hostname ''myhostname''
  
== Device Driver ==
+
To set the "pretty" hostname and other machine metadata, see the manpage for {{ic|machine-info}}.
 +
 
 +
== Device driver ==
  
=== Check the driver status ===
+
=== Check the status ===
  
Udev should detect your network interface card ([[Wikipedia:Network_interface_controller|NIC]]) and automatically load the necessary module at start up. Check the "Ethernet controller" entry (or similar) from the {{ic|lspci -v}} output. It should tell you which kernel module contains the driver for your network device. For example:
+
[[udev]] should detect your network interface card (see [[Wikipedia:Network interface controller]]) and automatically load the necessary module at start up. Check the "Ethernet controller" entry (or similar) from the {{ic|lspci -v}} output. It should tell you which kernel module contains the driver for your network device. For example:
  
 
{{hc|$ lspci -v|
 
{{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
 +
}}
  
 
Next, check that the driver was loaded via {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}}. For example:
 
Next, check that the driver was loaded via {{ic|dmesg <nowiki>|</nowiki> 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
  
 
Skip the next section if the driver was loaded successfully. Otherwise, you will need to know which module is needed for your particular model.
 
Skip the next section if the driver was loaded successfully. Otherwise, you will need to know which module is needed for your particular model.
  
=== Load the device module ===
+
=== Load the module ===
  
Google for the right module/driver for the chipset. Once you know which module to use, you can [[Kernel modules#Loading|load it]] with:
+
Search in the Internet for the right module/driver for the chipset. Some common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset. Once you know which module to use, try to [[Kernel modules#Manual module handling|load it manually]]. If you get an error saying that the module was not found, it's possible that the driver is not included in Arch kernel. You may search the [[AUR]] for the module name.
  
# modprobe ''module_name''
+
If udev is not detecting and loading the proper module automatically during bootup, see [[Kernel modules#Loading]].
  
If udev is not detecting and loading the proper module automatically during bootup, you can add it to a {{ic|*.conf}} file from the {{ic|/etc/modules-load.d/}} folder so that you do not need to {{ic|modprobe}} it every time you boot. For example, if {{ic|tg3}} is the network module:
+
== Network interfaces ==
  
# tee /etc/modules-load.d/tg3.conf <<< "tg3"
+
=== Device names ===
  
Other common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset.
+
For computers with multiple NICs, it is important to have fixed device names. Many configuration problems are caused by interface name changing.
  
== Network Interfaces ==
+
[[udev]] is responsible for which device gets which name. Systemd v197 introduced [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names], which automatically assigns static names to network devices. Interfaces are now prefixed with {{ic|en}} (ethernet), {{ic|wl}} (WLAN), or {{ic|ww}} (WWAN) followed by an automatically generated identifier, creating an entry such as {{ic|enp0s25}}. This behavior may be disabled by adding {{ic|1=net.ifnames=0}} to the [[kernel parameters]].
  
=== Persistent device names ===
+
{{Note|When changing the interface naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change. Specifically, if you have [[netctl#Basic method|netctl static profiles]] enabled, run {{ic|netctl reenable ''profile''}} to update the generated service file.}}
  
For motherboards that have integrated NICs, it is important to know which one is considered the primary NIC (e.g. {{ic|eth0}}) and which is considered the secondary NIC (e.g. {{ic|eth1}}). Many configuration issues are caused by users incorrectly configuring the network settings for {{ic|eth0}}, when in fact, they have their Ethernet cable plugged into {{ic|eth1}}.
+
==== Get current device names ====
  
[[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 {{ic|eth0}} or {{ic|eth1}}. You can fix this using {{ic|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 [[Udev#Network device]].
+
Current NIC names can be found via {{ic|sysfs}} or {{ic|ip link}}. For example:
  
=== Get current device names ===
+
{{hc|$ ls /sys/class/net|
 +
lo enp0s3
 +
}}
  
Current NIC names can be found using the {{ic|ip}} tool:
+
{{hc|$ ip link|
 +
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
 +
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 +
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
 +
    link/ether 08:00:27:23:6f:3a brd ff:ff:ff:ff:ff:ff
 +
}}
  
{{hc|$ ip addr <nowiki>|</nowiki> sed '/^[0-9]/!d;s/: <.*$//'|
+
Wireless device names can also be retrieved using {{ic|iw dev}}. See [[Wireless network configuration#Getting some useful information]] for details.
1: lo
+
2: eth1
+
3: eth0
+
4: firewire0}}
+
  
=== Enabling and disabling network interfaces ===
+
==== Change device name ====
  
You can activate or deactivate network interfaces using:
+
You can change the device name by defining the name manually with an udev-rule. For example:
  
# ip link set eth0 up
+
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki>
# ip link set eth0 down
+
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"
 +
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"
 +
</nowiki>}}
  
To check the result:
+
These rules will be applied automatically at boot.
  
{{hc|$ ip addr show dev eth0|
+
A couple of things to note:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
+
[...]}}
+
  
== Configure the IP address ==
+
* To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/''device_name''/address}}
 +
* Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.
  
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.
+
If the network card has a dynamic MAC, you can use {{ic|DEVPATH}}, for example:
+
=== Dynamic IP address ===
+
  
==== Manually run DHCP Client Daemon ====
+
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki>
 +
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"
 +
SUBSYSTEM=="net", DEVPATH=="/devices/pci*/*1c.0/*/net/*", NAME="en"
 +
</nowiki>}}
  
Please note that {{ic|dhcpcd}} is not {{ic|dhcpd}}.
+
The device path should match both the new and old device name, since the rule may be executed more than once on bootup. For example, in the second rule, {{ic|"/devices/pci*/*1c.0/*/net/enp*"}} would be wrong since it will stop matching once the name is changed to {{ic|en}}. Only the system-default rule will fire the second time around, causing the name to be changed back to e.g. {{ic|enp1s0}}.
  
{{hc|# dhcpcd eth0|
+
To [[Udev#Testing_rules_before_loading|test]] your rules, they can be triggered directly from userspace, e.g. with {{ic|udevadm --debug test /sys/''DEVPATH''}}. Remember to first take down the interface you are trying to rename (e.g. {{ic|ip link set enp1s0 down}}).
dhcpcd: version 5.1.1 starting
+
dhcpcd: eth0: broadcasting for a lease
+
...
+
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds}}
+
  
And now, {{ic|ip addr show dev eth0}} should show your inet address.
+
{{Note|When choosing the static names '''it should be avoided to use names in the format of "eth''X''" and "wlan''X''"''', because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: {{ic|net0}}, {{ic|net1}}, {{ic|wifi0}}, {{ic|wifi1}}. For further details please see the [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] documentation.}}
  
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.
+
==== Reverting to traditional device names ====
  
==== Run DHCP at boot ====
+
If you would prefer to retain traditional interface names such as eth0,  [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names] can be disabled with the following:
  
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).
+
  # ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
  
To enable DHCP for {{ic|eth0}}, simply use:
+
=== Set device MTU and queue length ===
  
# systemctl start dhcpcd@eth0
+
You can change the device MTU and queue length by defining manually with an udev-rule. For example:
  
You can enable the service to automatically start at boot with:
+
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki>
 +
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"
 +
</nowiki>}}
  
# systemctl enable dhcpcd@eth0
+
=== Enabling and disabling network interfaces ===
  
If the dhcpd service starts before your network card module ({{bug|30235}}), manually add your network card to {{ic|/etc/modules-load.d/*.conf}}. For example, if your Realtek card needs {{ic|r8169}} to be loaded, create:
+
You can activate or deactivate network interfaces using:
  
{{hc|/etc/modules-load.d/realtek.conf|
+
# ip link set eth0 up
r8169}}
+
# ip link set eth0 down
  
{{Tip|To find out which modules are used by your network card, use {{ic|lspci -k}}.}}
+
To check the result:
  
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|dhcpcd.conf}}:
+
{{hc|$ ip link show dev eth0|
 +
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000
 +
...
 +
}}
  
{{hc|/etc/dhcpcd.conf|
+
{{Note| If your default route is through interface {{ic|eth0}}, taking it down will also remove the route, and bringing it back up will not automatically reestablish the default route.  See [[#Manual assignment]] for reestablishing it.}}
nohook resolv.conf}}
+
  
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolve.conf}}, use the {{ic|nooption}} option:
+
== Configure the IP address ==
  
{{hc|/etc/dhcpcd.conf|
+
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.
nooption domain_name_servers}}
+
  
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.
+
{{Tip| In addition to the methods described below one can also use a [[List of applications#Network managers|network manager]]. Network managers are especially useful for dynamic network connections and wifi networking.}}
 +
 +
=== Dynamic IP address ===
  
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}}.
+
==== systemd-networkd ====
  
{{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):
+
An easy way to setup DHCP for simple requirements is to use [[systemd-networkd]] service provided by systemd. See [[systemd-networkd#Basic DHCP network]].  
  
{{bc|1=DHCPCD_ARGS="-q -s x.x.x.x"}}}}
+
==== dhcpcd ====
  
=== Static IP address ===
+
[[dhcpcd]] is the default client in Arch Linux to setup DHCP on the installation ISO. It is a powerful tool with many configurable DHCP client options. See [[dhcpcd#Running]] on how to activate it for an interface.
  
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 with unchanging addresses, or you may not have a DHCP server available.
+
==== netctl ====
  
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN issues.}}
+
[[netctl]] is a CLI-based tool for configuring and managing network connections through user-created profiles. Create a profile as shown in [[netctl#Example profiles]], then enable it as described in [[netctl#Basic method]].
 +
 
 +
=== Static IP address ===
  
You need:
+
A static IP address can be configured with most standard Arch Linux networking tools. Independent of the tool you choose, you will probably need to be prepared with the following information:
  
 
* Static IP address
 
* Static IP address
* [[Wikipedia:Subnetwork|Subnet mask]]
+
* Subnet mask, or possibly its [[wikipedia:Classless Inter-Domain Routing#CIDR notation|CIDR notation]], for example {{ic|/24}} is the CIDR notation of {{ic|255.255.255.0}} netmask.
 
* [[Wikipedia:Broadcast_address|Broadcast address]]
 
* [[Wikipedia:Broadcast_address|Broadcast address]]
 
* [[Wikipedia:Default_gateway|Gateway]]'s IP address
 
* [[Wikipedia:Default_gateway|Gateway]]'s IP address
 +
* Name server (DNS) IP addresses. See also [[resolv.conf]].
  
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.
+
If you are running a private network, it is safe to use IP addresses in {{ic|192.168.*.*}} for your IP addresses, with a subnet mask of {{ic|255.255.255.0}} and a broadcast address of {{ic|192.168.*.255}}. The gateway is usually {{ic|192.168.*.1}} or {{ic|192.168.*.254}}.
  
==== Manual assignment ====
+
{{Warning|
 +
* Make sure manually assigned IP addresses do not conflict with DHCP assigned ones. See [http://www.raspberrypi.org/forums/viewtopic.php?f&#61;28&t&#61;16797 this forum thread]
 +
* If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.
 +
}}
  
You can assign a static IP address in the console:
+
==== netctl ====
  
# ip addr add <IP address>/<subnet mask> dev <interface>
+
To create a [[netctl]] profile with a static IP, set the {{ic|1=IP=static}} option as well as {{ic|Address}}, {{ic|Gateway}}, and {{ic|DNS}}. See [[netctl#Wired]].
  
For example:
+
==== systemd-networkd ====
  
# ip addr add 192.168.1.2/24 dev eth0
+
The [[systemd-networkd]] service provided by systemd can set up a static IP using a simple configuration file. See [[systemd-networkd#Wired adapter using a static IP]].
  
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}
+
==== dhcpcd ====
  
For more options, see {{ic|man ip}}.
+
See [[dhcpcd#Static profile]].
  
Add your gateway like so:
+
==== Manual assignment ====
  
# ip route add default via <default gateway IP address>
+
It is possible to manually set up a static IP using only the {{pkg|iproute2}} package. This is a good way to test connection settings since the connection will not persist across reboots. First enable the [[#Network interfaces|network interface]]:
  
For example:
+
# ip link set ''interface'' up
  
# ip route add default via 192.168.1.1
+
Assign a static IP address in the console:
  
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.
+
# ip addr add ''IP_address''/''subnet_mask'' broadcast ''broadcast_address'' dev ''interface''
  
====Manual connection at boot using systemd====
+
Then add your gateway IP address:
This section details how to manually connect using [[systemd]].
+
  
=====Using [[dhcpcd]]=====
+
# ip route add default via ''default_gateway''
Create the file {{ic|/etc/systemd/system/network.service}} using your editor of choice. This example uses [[wpa_supplicant]].
+
{{hc|/etc/systemd/system/network.service|<nowiki>
+
[Unit]
+
Description=Network Connectivity
+
Wants=network.target
+
Before=network.target
+
  
[Service]
+
For example:
Type=oneshot
+
RemainAfterExit=yes
+
ExecStart=/sbin/ip link set dev wlan0 up
+
ExecStart=/usr/sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
+
ExecStart=/sbin/dhcpcd wlan0
+
  
[Install]
+
# ip link set eth0 up
WantedBy=multi-user.target
+
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0
</nowiki>}}
+
# ip route add default via 192.168.1.1
  
# systemctl enable network
+
To undo these steps (e.g. before switching to a dynamic IP), first remove any assigned IP address:
  
To test, reboot or stop all other network daemons and run as root:
+
  # ip addr flush dev ''interface''
  # systemctl start network
+
  
=====Using a static IP address=====
+
Then remove any assigned gateway:
Create the file {{ic|/etc/conf.d/network}} using your editor of choice. This file will store your interface and static IP address settings.
+
{{hc|/etc/conf.d/network|<nowiki>
+
interface=wlan0
+
address=192.168.0.10
+
netmask=24
+
broadcast=192.168.0.255
+
gateway=192.168.0.1
+
</nowiki>}}
+
  
Create the file {{ic|/etc/systemd/system/network.service}} using your editor of choice. This example uses a static IP address and [[wpa_supplicant]].
+
# ip route flush dev ''interface''
{{hc|/etc/systemd/system/network.service|<nowiki>
+
[Unit]
+
Description=Wireless Static IP Connectivity
+
Wants=network.target
+
Before=network.target
+
  
[Service]
+
And finally disable the interface:
Type=oneshot
+
RemainAfterExit=yes
+
EnvironmentFile=/etc/conf.d/network
+
ExecStart=/sbin/ip link set dev ${interface} up
+
ExecStart=/usr/sbin/wpa_supplicant -B -i ${interface} -c /etc/wpa_supplicant.conf # Remove this for wired connections
+
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
+
ExecStart=/sbin/ip route add default via ${gateway}
+
+
ExecStop=/sbin/ip addr flush dev ${interface}
+
ExecStop=/sbin/ip link set dev ${interface} down
+
  
[Install]
+
# ip link set ''interface'' down
WantedBy=multi-user.target
+
</nowiki>}}
+
  
Do not forget to enable it!
+
For more options, see the {{ic|ip(8)}} man page. These commands can be automated using scripts and [[systemd#Writing unit files|systemd units]].
# systemctl enable network
+
 
+
To test, reboot or make sure all other network daemons are stopped and then run as root
+
# systemctl start network
+
  
 
==== Calculating addresses ====
 
==== Calculating addresses ====
  
You can use {{ic|ipcalc}} provided by the {{Pkg|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 {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. An example is using Ethernet over Firewire to connect a Windows machine to Linux. To improve security and organization, both machines have their own network with the netmask and broadcast configured accordingly.  
 +
 
 +
Finding out the respective netmask and broadcast addresses is done with {{ic|ipcalc}}, by specifying the IP of the Linux NIC {{ic|10.66.66.1}} and the number of hosts (here two):
  
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=
+
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki>
 
Address:  10.66.66.1
 
Address:  10.66.66.1
  
Line 305: Line 292:
 
HostMax:  10.66.66.2
 
HostMax:  10.66.66.2
 
Broadcast: 10.66.66.3
 
Broadcast: 10.66.66.3
Hosts/Net: 2                    Class A, Private Internet}}
+
Hosts/Net: 2                    Class A, Private Internet
 +
</nowiki>}}
  
== Load configuration ==
+
== Additional settings ==
  
To test your settings either reboot the computer or reload the relevant systemd services:
+
=== ifplugd for laptops ===
  
# systemctl restart dhcpcd@eth0
+
{{Tip|[[dhcpcd]] provides the same feature out of the box.}}
  
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:
+
{{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.
  
$ ping -c 3 www.google.com
+
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.
  
== Additional settings ==
+
{{Note|[[netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. For example, [[enable]] {{ic|ifplugd@eth0.service}}.}}
  
=== ifplugd for laptops ===
+
=== Bonding or LAG ===
  
{{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.
+
See [[netctl#Bonding]] or [[Wireless bonding]].
  
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.
+
=== IP address aliasing ===
  
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}}.
+
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. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).
  
=== Bonding or LAG ===
+
==== Example ====
  
You will need {{Pkg|netcfg}} from the [[Official Repositories]], as well as the {{AUR|netcfg-bonding}} package from the [[AUR]].
+
To manually set an alias, for some NIC, use {{Pkg|iproute2}} to execute
  
Edit/create the following files:
+
# ip addr add 192.168.2.101/24 dev eth0 label eth0:1
  
{{hc|/etc/network.d/bonded|2=
+
To remove a given alias execute
CONNECTION="bonding"
+
INTERFACE="bond0"
+
SLAVES="eth0 eth1"
+
IP="dhcp"
+
DHCP_TIMEOUT=10}}
+
  
{{hc|/etc/modules-load.d/bonding.conf|
+
# ip addr del 192.168.2.101/24 dev eth0:1
bonding}}
+
  
Set up netcfg to use the bond0 interface.
+
Packets destined for a subnet will use the primary alias by default. If the destination IP is within a subnet of a secondary alias, then the source IP is set respectively. Consider the case where there is more than one NIC, the default routes can be listed with {{ic|ip route}}.
  
Start your network:
+
=== Change MAC/hardware address ===
$ systemctl enable netcfg@bonded
+
  
{{Note|To change the bonding mode (default is round robin) to, e.g, dynamic link aggregation:
+
See [[MAC address spoofing]].
  
Create {{ic|/etc/modprobe.d/bonding.conf}}:
+
=== Internet sharing ===
  
{{hc|/etc/modprobe.d/bonding.conf|2=
+
See [[Internet sharing]].
options bonding mode=4
+
options bonding miimon=100}}
+
  
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].}}
+
=== Router configuration ===
  
To activate the new bonded ports modprobe {{ic|bonding}}, stop {{ic|network}} and start the {{ic|net-profiles}} service:
+
See [[Router]].
+
# modprobe bonding
+
# systemctl stop network
+
# systemctl start net-profiles
+
  
To check the status and bonding mode:
+
=== Local network hostname resolution ===
  
$ cat /proc/net/bonding/bond0
+
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself:
  
=== IP address aliasing ===
+
{{hc|$ ping ''myhostname''|2=
 +
PING myhostname (192.168.1.2) 56(84) bytes of data.
 +
64 bytes from myhostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms}}
  
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 enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. With systemd the latter is done via the {{ic|myhostname}} nss module. However, not all network services (on the same system; examples: [https://bbs.archlinux.org/viewtopic.php?id=176761], [https://bbs.archlinux.org/viewtopic.php?id=186967]) or other clients with different operating systems use the same methods to try resolve the hostname.  
  
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.
+
A first work-around that can be tried is to add the following line to {{ic|/etc/hosts}}:
  
==== Example ====
+
127.0.1.1 ''myhostname''.localdomain ''myhostname''
  
You will need {{Pkg|netcfg}} from the [[Official Repositories]].
+
As a result the system resolves to both entries:
 +
$ getent hosts
 +
127.0.0.1      localhost
 +
127.0.1.1      myhostname.localdomain myhostname
  
Prepare the configuration:
+
For a system with a permanent IP address, that permanent IP address should be used instead of {{ic|127.0.1.1}}.
  
{{hc|/etc/network.d/mynetwork|2=
+
Another possibility is to set up a full DNS server such as [[BIND]] or [[Unbound]], but that is overkill and too complex for most systems. For small networks and dynamic flexibility with hosts joining and leaving the network [[Wikipedia:Zero-configuration_networking|zero-configuration networking]] services may be more applicable. There are two options available:
  
CONNECTION='ethernet'
+
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.
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'}}
+
  
The simply execute:  
+
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.
  
$ systemctl enable net-auto-wired.service
+
=== Promiscuous mode ===
  
=== Change MAC/hardware address ===
+
Toggling [[wikipedia:Promiscuous_mode|promiscuous mode]] will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and [[wikipedia:Packet_sniffing|packet sniffing]].
 +
 
 +
{{hc|/etc/systemd/system/promiscuous@.service|<nowiki>
 +
[Unit]
 +
Description=Set %i interface in promiscuous mode
 +
After=network.target
 +
 
 +
[Service]
 +
Type=oneshot
 +
ExecStart=/usr/bin/ip link set dev %i promisc on
 +
RemainAfterExit=yes
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 +
</nowiki>}}
  
See [[MAC Address Spoofing]].
+
If you want to enable promiscuous mode on interface {{ic|eth0}} run [[enable]] {{ic|promiscuous@eth0.service}}.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 405: Line 390:
 
=== 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.
+
Some 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 [[#Change MAC/hardware address]].
  
=== The TCP window scaling issue ===
+
=== The TCP window scaling problem ===
  
 
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.
  
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html 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.
+
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html 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.
  
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.
 
+
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.
 
The resulting connection is at best very slow or broken.
Line 429: Line 410:
 
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.
 
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|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.
+
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.
  
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) ====
+
==== Ways of fixing it ====
  
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.
+
===== Bad =====
 +
 
 +
To fix it the bad way, you can change the {{ic|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) ====
+
===== Good =====
  
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.d/99-disable_window_scaling.conf}} (see also [[sysctl]]):
  
 
  net.ipv4.tcp_window_scaling = 0
 
  net.ipv4.tcp_window_scaling = 0
  
==== How to fix it (The best way) ====
+
===== Best =====
  
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 problem 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 ====
Line 455: Line 438:
 
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 problem ===
 +
 
 +
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem 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 problem 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 problem will also affect other operating systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem.
 +
 
 +
==== Enable the NIC directly in Linux ====
  
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:
+
Follow [[#Enabling and disabling network interfaces]] to enable the interface.
  
==== Method 1 - Rollback/change Windows driver ====
+
==== 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 ====
+
==== 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 operating 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
+
 
  --> Hardware tab
+
  Right click my computer and choose "Properties"
 +
  --> "Hardware" tab
 
   --> Device Manager
 
   --> Device Manager
 
     --> Network Adapters
 
     --> Network Adapters
Line 479: Line 467:
 
{{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 ====
+
==== 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 ====
+
==== 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>
 
  
=== DLink G604T/DLink G502T DNS issue ===
+
{{Note|This was tested several times on a GIGABYTE GA-G31M-ES2L motherboard, BIOS version F8 released on 2009/02/05.}}
  
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
+
=== No interface with Atheros chipsets ===
  
==== How to diagnose the problem ====
+
Users of some Atheros ethernet chips are reporting it does not work out-of-the-box (with installation media of February 2014). The working solution for this is to install {{AUR|backports-patched}}.
  
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.
+
=== Broadcom BCM57780 ===
  
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)
+
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.
Open {{ic|/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
+
These steps should help if your computer has this chipset:
  
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.
+
* Find your NIC in ''lspci'' output:
  
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),
+
$ lspci | grep Ethernet
 +
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)
  
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki>
+
* If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following:
            => '/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 {{ic|/etc/resolv.conf}}.
+
# modprobe -r tg3
 +
# modprobe broadcom
 +
# modprobe tg3
  
==== How to fix it ====
+
* Plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:
  
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.
+
MODULES=".. broadcom tg3 .."
  
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:
+
* Rebuild the initramfs:
  
  DHCPCD_ARGS="-t 30 -h $HOSTNAME"
+
  # mkinitcpio -p linux
  
Add the {{ic|-R}} flag to the arguments, e.g.,
+
* Alternatively, you can create an {{ic|/etc/modprobe.d/broadcom.conf}}:
  
  DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
+
  softdep tg3 pre: broadcom
 
+
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#For DHCP assigned IP address]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}
+
 
+
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.
+
 
+
For example, {{ic|/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 {{ic|/etc/resolv.conf}} to:
+
 
+
nameserver 211.29.132.12
+
nameserver 10.1.1.1
+
 
+
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|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:
+
{{Note|These methods may work for other chipsets, such as BCM57760.}}
  
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html
+
=== Realtek RTL8111/8168B ===
  
=== Check DHCP problem by releasing IP first ===
+
{{hc|<nowiki># lspci | grep Ethernet</nowiki>|
 +
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
 +
}}
  
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:
+
The adapter should be recognized by the {{ic|r8169}} module. However, with some chip revisions the connection may go off and on all the time. The alternative {{Pkg|r8168}} can be found in the [[official repositories]] and should be used for a reliable connection in this case. [[Blacklist]] {{ic|r8169}}, if {{Pkg|r8168}} is not automatically loaded by [[udev]] add it to your list of user specified [[Kernel_modules#Loading|modules]].
  
# dhcpcd -k
+
{{Accuracy|"some revisions", no proof the driver is the cause, and not e.g poorly configured DNS servers}}
  
Then request a new one:
+
Another fault in the drivers for some revisions of this adapter is poor IPv6 support. [[IPv6#Disable functionality]] can be helpful if you encounter issues such as hanging webpages and slow speeds.
  
# dhcpcd
+
=== Gigabyte Motherboard with Realtek 8111/8168/8411 ===
 +
With motherboards such as the Gigabyte GA-990FXA-UD3, booting with IOMMU off (which can be the default) will cause the network interface to be unreliable, often failing to connect or connecting but allowing no throughput. This will apply not only to the onboard NIC, but any other pci-NIC you put in the box because the IOMMU setting affects the entire network interface on the board. Enabling IOMMU and booting with the install media will throw AMD I-10/xhci page faults for a second, but then boot normally, resulting in a fully functional onboard NIC (even with the r8169 module).
  
Maybe you had to run those two commands many times.
+
When configuring the boot process for your installation, add {{ic|1=iommu=soft}} as a [[kernel parameter]] to eliminate the error messages on boot and restore USB3.0 functionality.

Latest revision as of 09:04, 3 June 2016

This page explains how to set up a wired connection to a network. If you need to set up wireless networking see the Wireless network configuration page.

Check the connection

The basic installation procedure typically has a functional network configuration. Use ping to check the connection:

$ ping www.google.com
PING www.l.google.com (74.125.132.105) 56(84) bytes of data.
64 bytes from wb-in-f105.1e100.net (74.125.132.105): icmp_req=1 ttl=50 time=17.0 ms
...

If the ping is successful (you see 64 bytes messages as above), then the network is configured. Press Control-C to stop the ping.

If the ping failed with an Unknown hosts error, it means that your machine was unable to resolve this domain name. It may be related to your service provider or your router/gateway. Try pinging a static IP address to prove that your machine has access to the Internet:

$ ping 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
...

If you are able to ping 8.8.8.8 but not www.google.com, check your DNS configuration. See resolv.conf for details. The hosts line in /etc/nsswitch.conf is another place you can check.

If not, check for cable issues before diagnosing further.

Note:
  • If you receive an error like ping: icmp open socket: Operation not permitted when executing ping, try to re-install the iputils package.
  • The -c num option can be used to make exactly num pings, otherwise it pings infinitely and has to be terminated manually. See man ping for more information.
  • 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.

Set the hostname

A hostname is a unique name created to identify a machine on a network: it is configured in /etc/hostname. The file can contain the system's domain name, if any. To set the hostname, do:

# hostnamectl set-hostname myhostname

This will put myhostname into /etc/hostname. See man 5 hostname and man 1 hostnamectl for details.

It is recommended to also set the hostname in /etc/hosts:

/etc/hosts
#
# /etc/hosts: static lookup table for host names
#

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	localhost	 myhostname
::1		localhost.localdomain	localhost	 myhostname
Note: systemd provides hostname resolution via the myhostname nss module (enabled by default in /etc/nsswitch.conf), which means that changing hostnames in /etc/hosts is normally not necessary. However several users have reported bugs such as delays in network-based applications when the hostname was not set correctly in /etc/hosts. See #Local network hostname resolution for details.

To temporarily set the hostname (until reboot), use hostname from inetutils:

# hostname myhostname

To set the "pretty" hostname and other machine metadata, see the manpage for machine-info.

Device driver

Check the status

udev should detect your network interface card (see Wikipedia:Network interface controller) and automatically load the necessary module at start up. Check the "Ethernet controller" entry (or similar) from the lspci -v output. It should tell you which kernel module contains the driver for 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

Skip the next section if the driver was loaded successfully. Otherwise, you will need to know which module is needed for your particular model.

Load the module

Search in the Internet for the right module/driver for the chipset. Some common modules are 8139too for cards with a Realtek chipset, or sis900 for cards with a SiS chipset. Once you know which module to use, try to load it manually. If you get an error saying that the module was not found, it's possible that the driver is not included in Arch kernel. You may search the AUR for the module name.

If udev is not detecting and loading the proper module automatically during bootup, see Kernel modules#Loading.

Network interfaces

Device names

For computers with multiple NICs, it is important to have fixed device names. Many configuration problems are caused by interface name changing.

udev is responsible for which device gets which name. Systemd v197 introduced Predictable Network Interface Names, which automatically assigns static names to network devices. Interfaces are now prefixed with en (ethernet), wl (WLAN), or ww (WWAN) followed by an automatically generated identifier, creating an entry such as enp0s25. This behavior may be disabled by adding net.ifnames=0 to the kernel parameters.

Note: When changing the interface naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change. Specifically, if you have netctl static profiles enabled, run netctl reenable profile to update the generated service file.

Get current device names

Current NIC names can be found via sysfs or ip link. For example:

$ ls /sys/class/net
lo enp0s3
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:23:6f:3a brd ff:ff:ff:ff:ff:ff

Wireless device names can also be retrieved using iw dev. See Wireless network configuration#Getting some useful information for details.

Change device name

You can change the device name by defining the name manually with an udev-rule. For example:

/etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"

These rules will be applied automatically at boot.

A couple of things to note:

  • To get the MAC address of each card, use this command: cat /sys/class/net/device_name/address
  • Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.

If the network card has a dynamic MAC, you can use DEVPATH, for example:

/etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"
SUBSYSTEM=="net", DEVPATH=="/devices/pci*/*1c.0/*/net/*", NAME="en"

The device path should match both the new and old device name, since the rule may be executed more than once on bootup. For example, in the second rule, "/devices/pci*/*1c.0/*/net/enp*" would be wrong since it will stop matching once the name is changed to en. Only the system-default rule will fire the second time around, causing the name to be changed back to e.g. enp1s0.

To test your rules, they can be triggered directly from userspace, e.g. with udevadm --debug test /sys/DEVPATH. Remember to first take down the interface you are trying to rename (e.g. ip link set enp1s0 down).

Note: When choosing the static names it should be avoided to use names in the format of "ethX" and "wlanX", because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: net0, net1, wifi0, wifi1. For further details please see the systemd documentation.

Reverting to traditional device names

If you would prefer to retain traditional interface names such as eth0, Predictable Network Interface Names can be disabled with the following:

 # ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules

Set device MTU and queue length

You can change the device MTU and queue length by defining manually with an udev-rule. For example:

/etc/udev/rules.d/10-network.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"

Enabling and disabling network interfaces

You can activate or deactivate network interfaces using:

# ip link set eth0 up
# ip link set eth0 down

To check the result:

$ ip link show dev eth0
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000
...
Note: If your default route is through interface eth0, taking it down will also remove the route, and bringing it back up will not automatically reestablish the default route. See #Manual assignment for reestablishing it.

Configure the IP address

You have two options: a dynamically assigned address using DHCP, or an unchanging "static" address.

Tip: In addition to the methods described below one can also use a network manager. Network managers are especially useful for dynamic network connections and wifi networking.

Dynamic IP address

systemd-networkd

An easy way to setup DHCP for simple requirements is to use systemd-networkd service provided by systemd. See systemd-networkd#Basic DHCP network.

dhcpcd

dhcpcd is the default client in Arch Linux to setup DHCP on the installation ISO. It is a powerful tool with many configurable DHCP client options. See dhcpcd#Running on how to activate it for an interface.

netctl

netctl is a CLI-based tool for configuring and managing network connections through user-created profiles. Create a profile as shown in netctl#Example profiles, then enable it as described in netctl#Basic method.

Static IP address

A static IP address can be configured with most standard Arch Linux networking tools. Independent of the tool you choose, you will probably need to be prepared with the following information:

If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.

Warning:
  • Make sure manually assigned IP addresses do not conflict with DHCP assigned ones. See this forum thread
  • If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.

netctl

To create a netctl profile with a static IP, set the IP=static option as well as Address, Gateway, and DNS. See netctl#Wired.

systemd-networkd

The systemd-networkd service provided by systemd can set up a static IP using a simple configuration file. See systemd-networkd#Wired adapter using a static IP.

dhcpcd

See dhcpcd#Static profile.

Manual assignment

It is possible to manually set up a static IP using only the iproute2 package. This is a good way to test connection settings since the connection will not persist across reboots. First enable the network interface:

# ip link set interface up

Assign a static IP address in the console:

# ip addr add IP_address/subnet_mask broadcast broadcast_address dev interface

Then add your gateway IP address:

# ip route add default via default_gateway

For example:

# ip link set eth0 up
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0
# ip route add default via 192.168.1.1

To undo these steps (e.g. before switching to a dynamic IP), first remove any assigned IP address:

# ip addr flush dev interface

Then remove any assigned gateway:

# ip route flush dev interface

And finally disable the interface:

# ip link set interface down

For more options, see the ip(8) man page. These commands can be automated using scripts and systemd units.

Calculating addresses

You can use ipcalc provided by the ipcalc package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. An example is using Ethernet over Firewire to connect a Windows machine to Linux. To improve security and organization, both machines have their own network with the netmask and broadcast configured accordingly.

Finding out the respective netmask and broadcast addresses is done with ipcalc, by specifying the IP of the Linux NIC 10.66.66.1 and the number of hosts (here two):

$ 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

Additional settings

ifplugd for laptops

Tip: dhcpcd provides the same feature out of the box.

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.

Note: netctl package includes netctl-ifplugd@.service, otherwise you can use ifplugd@.service from ifplugd package. For example, enable ifplugd@eth0.service.

Bonding or LAG

See netctl#Bonding or Wireless bonding.

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. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).

Example

To manually set an alias, for some NIC, use iproute2 to execute

# ip addr add 192.168.2.101/24 dev eth0 label eth0:1

To remove a given alias execute

# ip addr del 192.168.2.101/24 dev eth0:1

Packets destined for a subnet will use the primary alias by default. If the destination IP is within a subnet of a secondary alias, then the source IP is set respectively. Consider the case where there is more than one NIC, the default routes can be listed with ip route.

Change MAC/hardware address

See MAC address spoofing.

Internet sharing

See Internet sharing.

Router configuration

See Router.

Local network hostname resolution

The pre-requisite is to #Set the hostname after which hostname resolution works on the local system itself:

$ ping myhostname
PING myhostname (192.168.1.2) 56(84) bytes of data.
64 bytes from myhostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms

To enable other machines to address the host by name, either a manual configuration of the respective /etc/hosts files or a service to propagate/resolve the name is required. With systemd the latter is done via the myhostname nss module. However, not all network services (on the same system; examples: [1], [2]) or other clients with different operating systems use the same methods to try resolve the hostname.

A first work-around that can be tried is to add the following line to /etc/hosts:

127.0.1.1	myhostname.localdomain	myhostname	

As a result the system resolves to both entries:

$ getent hosts 
127.0.0.1       localhost
127.0.1.1       myhostname.localdomain myhostname

For a system with a permanent IP address, that permanent IP address should be used instead of 127.0.1.1.

Another possibility is to set up a full DNS server such as BIND or Unbound, but that is overkill and too complex for most systems. For small networks and dynamic flexibility with hosts joining and leaving the network zero-configuration networking services may be more applicable. There are two options available:

  • Samba provides hostname resolution via Microsoft's NetBIOS. It only requires installation of samba and enabling of the nmbd.service service. Computers running Windows, OS X, or Linux with nmbd running, will be able to find your machine.
  • Avahi provides hostname resolution via zeroconf, also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see Avahi#Hostname resolution for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.

Promiscuous mode

Toggling promiscuous mode will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and packet sniffing.

/etc/systemd/system/promiscuous@.service
[Unit]
Description=Set %i interface in promiscuous mode
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set dev %i promisc on
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

If you want to enable promiscuous mode on interface eth0 run enable promiscuous@eth0.service.

Troubleshooting

Swapping computers on the cable modem

Some 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 problem

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 problem: ping uses ICMP and is not affected by TCP problems.

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

Ways of fixing it

Bad

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
Good

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.d/99-disable_window_scaling.conf (see also sysctl):

net.ipv4.tcp_window_scaling = 0
Best

This problem 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 problem

Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem 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 problem 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 problem will also affect other operating systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem.

Enable the NIC directly in Linux

Follow #Enabling and disabling network interfaces to enable the interface.

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).

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 operating 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 and choose "Properties"
--> "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.

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).

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.

Note: This was tested several times on a GIGABYTE GA-G31M-ES2L motherboard, BIOS version F8 released on 2009/02/05.

No interface with Atheros chipsets

Users of some Atheros ethernet chips are reporting it does not work out-of-the-box (with installation media of February 2014). The working solution for this is to install backports-patchedAUR.

Broadcom BCM57780

This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are broadcom and tg3, the former needing to be loaded first.

These steps should help if your computer has this chipset:

  • Find your NIC in lspci output:
$ lspci | grep Ethernet
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)
  • If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following:
# modprobe -r tg3
# modprobe broadcom
# modprobe tg3
  • Plug you network cable in. If this solves your problems you can make this permanent by adding broadcom and tg3 (in this order) to the MODULES array in /etc/mkinitcpio.conf:
MODULES=".. broadcom tg3 .."
  • Rebuild the initramfs:
# mkinitcpio -p linux
  • Alternatively, you can create an /etc/modprobe.d/broadcom.conf:
softdep tg3 pre: broadcom
Note: These methods may work for other chipsets, such as BCM57760.

Realtek RTL8111/8168B

# lspci | grep Ethernet
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)

The adapter should be recognized by the r8169 module. However, with some chip revisions the connection may go off and on all the time. The alternative r8168 can be found in the official repositories and should be used for a reliable connection in this case. Blacklist r8169, if r8168 is not automatically loaded by udev add it to your list of user specified modules.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: "some revisions", no proof the driver is the cause, and not e.g poorly configured DNS servers (Discuss in Talk:Network configuration#)

Another fault in the drivers for some revisions of this adapter is poor IPv6 support. IPv6#Disable functionality can be helpful if you encounter issues such as hanging webpages and slow speeds.

Gigabyte Motherboard with Realtek 8111/8168/8411

With motherboards such as the Gigabyte GA-990FXA-UD3, booting with IOMMU off (which can be the default) will cause the network interface to be unreliable, often failing to connect or connecting but allowing no throughput. This will apply not only to the onboard NIC, but any other pci-NIC you put in the box because the IOMMU setting affects the entire network interface on the board. Enabling IOMMU and booting with the install media will throw AMD I-10/xhci page faults for a second, but then boot normally, resulting in a fully functional onboard NIC (even with the r8169 module).

When configuring the boot process for your installation, add iommu=soft as a kernel parameter to eliminate the error messages on boot and restore USB3.0 functionality.