Difference between revisions of "Network configuration"

From ArchWiki
Jump to: navigation, search
m (No eth0 with Atheros AR8161: use Note template)
m (Resolving domain names: update move template)
 
(580 intermediate revisions by 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]]
[[ja:Network Configuration]]
+
[[ja:ネットワーク設定]]
[[nl:Configuring Network]]
+
[[nl:Network configuration]]
[[pt:Configuring Network]]
+
[[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ı]]
+
[[zh-hans:Network configuration]]
[[zh-CN:Network Configuration]]
+
[[zh-hant:Network configuration]]
{{Article summary start}}
+
{{Related articles start}}
{{Article summary text|A simple guide for setting up and troubleshooting network.}}
+
{{Related|Network Debugging}}
{{Article summary heading|Overview}}
+
{{Related|Firewalls}}
{{Article summary text|{{Networking overview}}}}
+
{{Related|Jumbo frames}}
{{Article summary heading|Related}}
+
{{Related|Internet sharing}}
{{Article summary wiki|Jumbo Frames}}
+
{{Related|Router}}
{{Article summary wiki|Firewalls}}
+
{{Related articles end}}
{{Article summary wiki|Samba}}
+
This article explains how to configure a network connection.
{{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_Setup|Wireless Setup]] page.
 
  
 
== Check the connection ==
 
== Check the connection ==
{{Note|If you receive an error like {{ic|ping: icmp open socket: Operation not permitted}} when executing ping, try to re-install the {{ic|iputils}} package.}} 
 
 
Many times, the basic installation procedure has created a working network configuration. To check if this is so, use the following command:
 
 
{{Note|The {{ic|-c 3}} option calls it three times. See {{ic|man ping}} for more information.}}
 
 
{{hc|$ ping -c 3 www.google.com|2=
 
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}}
 
 
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.
 
  
{{hc|$ ping -c 3 8.8.8.8|2=
+
To troubleshoot a network connection, go through the following conditions and ensure that you meet them:
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 ---
+
# Your [[#Network interfaces|#network interface]] is listed and enabled.
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
+
# You are connected to the network. The cable is plugged in or you are [[Wireless network configuration|connected to the wireless LAN]].
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms}}
+
# Your network interface has an [[#IP addresses|#IP address]]
 +
# Your [[#Routing table|#routing table]] is correctly set up.
 +
# You can [[#Ping|#ping]] a local IP address (e.g. your default gateway).
 +
# You can [[#Ping|#ping]] a public IP address (e.g. {{ic|8.8.8.8}}), if you can't it may be related to your default gateway or your internet service provider.
 +
# You can resolve domain names (e.g. {{ic|archlinux.org}}), see [[#Resolving domain names]].
  
 
{{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.}}
 
{{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 you are able to ping this address, you may try adding this nameserver to your {{ic|/etc/resolv.conf}} file.
+
=== Ping ===
 
 
== 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:
+
{{Expansion|Add or link explanation of common ping errors like Unknown hosts / Network is unreachable.}}
  
# hostnamectl set-hostname '''myhostname'''
+
[[Wikipedia:Ping (networking utility)|ping]] is used to test if you can reach a host.
  
This will put '''myhostname''' in {{ic|/etc/hostname}}.
+
{{hc|$ ping www.example.com|2=
 +
PING www.example.com (93.184.216.34): 56(84) data bytes
 +
64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms
 +
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.726 ms
 +
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=10.683 ms
 +
...}}
  
See {{ic|man 5 hostname}} and {{ic|man 1 hostnamectl}} for details.
+
For every reply you receive ping prints a line like above. For more information see the {{man|8|ping}} manual.
  
{{Note|
+
Note that computers can be configured not to respond to ICMP echo requests.[https://unix.stackexchange.com/questions/412446/how-to-disable-ping-response-icmp-echo-in-linux-all-the-time]
*{{ic|hostnamectl}} supports FQDNs
 
*You no longer need to edit {{ic|/etc/hosts}}, {{pkg|systemd}} will provide host name resolution, and is installed on all systems by default.}}
 
  
To set the hostname temporarily (until a reboot), use the {{ic|hostname}} command from {{Pkg|inetutils}}:
+
When you receive no reply, you can use a [[Wikipedia:Traceroute|traceroute]] ({{man|8|traceroute}} or {{man|8|tracepath}}) to further diagnose the route to the host.
  
# hostname ''myhostname''
+
{{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.}}
  
== Device Driver ==
+
== 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 [[Wikipedia:Network interface controller|network interface controller]] (NIC) and automatically load the necessary [[kernel module]] at startup. 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 {{!}} grep ''module_name''}}. For example:
  
$ dmesg | grep atl1
+
{{hc|$ 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:
 
 
 
# modprobe ''module_name''
 
 
 
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:
 
 
 
# tee /etc/modules-load.d/tg3.conf <<< "tg3"
 
 
 
Other common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset.
 
  
== Network Interfaces ==
+
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 is possible that the driver is not included in Arch kernel. You may search the [[AUR]] for the module name.
  
=== Device names ===
+
If udev is not detecting and loading the proper module automatically during bootup, see [[Kernel module#Automatic module handling]].
  
For motherboards that have integrated NICs, it is important to have fixed device name. Many configuration problems are caused by interface name changing.
+
== Network management ==
  
[[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 en (ethernet), wl (WLAN), or ww (WWAN) followed by an automatically generated identifier, creating an entry such as {{ic|enp0s25}}.
+
To set up a network connection, go through the following steps:
  
This behavior may be disabled by adding a symlink:
+
# Ensure your [[#Network interfaces|#network interface]] is listed and enabled.
 +
# Connect to the network. Plug in the Ethernet cable or [[Wireless network configuration|connect to the wireless LAN]].
 +
# Configure your network connection:
 +
#* [[#Static IP address|#static IP address]]
 +
#* dynamic IP address: use [[#DHCP]]
  
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
+
{{Tip|[[#Network managers]] provide automatic network connection and configuration based on network profiles.}}
  
Users upgrading from an earlier systemd version will have a blank rules file created automatically. So if you want to use persistent device names, just delete the file.
+
The {{Pkg|iproute2}} package provides the {{man|8|ip}} command-line utility, used to manage [[#Network interfaces]], [[#IP addresses]] and the [[#Routing table]]. Be aware that configuration made using {{ic|ip}} will be lost after a reboot. You can automate ip commands using scripts and [[systemd#Writing unit files|systemd units]]. Also note that {{ic|ip}} commands can generally be abbreviated, for clarity they are however spelled out in this article.
  
==== Change device name ====
+
=== Network interfaces ===
You can change the device name by defining the name manually with an udev-rule. For example: 
 
{{hc|/etc/udev/rules.d/10-network.rules|2=
 
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"}}
 
A couple things to note:
 
  
* To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/'''device-name'''/address}}<!-- {{ic|<nowiki>udevadm info -a -p /sys/class/net/<yourdevice> | grep address | tr [A-Z] [a-z]</nowiki>}} -->
+
By default [[udev]] assigns names to your network interfaces using [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names], which prefixes interfaces names with {{ic|en}} (wired/[[w:Ethernet|Ethernet]]), {{ic|wl}} (wireless/WLAN), or {{ic|ww}} ([[w:Wireless WAN|WWAN]]).
* Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.
 
{{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.}}
 
  
=== Set device MTU and queue Length ===
+
{{Tip|To change interface names, see [[#Change interface name]] and [[#Revert to traditional interface names]].}}
You can change the device MTU and queue length by defining manually with an udev-rule. For example: 
 
{{hc|/etc/udev/rules.d/10-network.rules|2=
 
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"}}
 
  
=== Get current device names ===
+
==== Listing network interfaces ====
  
Current NIC names can be found via sysfs
+
Both wired and wireless interface names can be found via {{ic|ls /sys/class/net}} or {{ic|ip link}}. Note that {{ic|lo}} is the [[w:loop device|loop device]] and not used in making network connections.
  
{{hc|$ ls /sys/class/net|
+
Wireless device names can also be retrieved using {{ic|iw dev}}. See also [[Wireless network configuration#Get the name of the interface]].
lo eth0 eth1 firewire0}}
 
  
=== Enabling and disabling network interfaces ===
+
If your network interface is not listed, make sure your [[#Device driver]] was loaded successfully.
  
You can activate or deactivate network interfaces using:
+
==== Enabling and disabling network interfaces ====
  
# ip link set eth0 up
+
Network interfaces can be enabled / disabled using {{ic|ip link set ''interface'' up{{!}}down}}, see {{man|8|ip-link}}.
# ip link set eth0 down
 
  
To check the result:
+
To check the status of the interface {{ic|eth0}}:
  
 
{{hc|$ ip link show dev eth0|
 
{{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
+
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT qlen 1000
[...]}}
+
...
 +
}}
  
== Configure the IP address ==
+
The {{ic|UP}} in {{ic|<BROADCAST,MULTICAST,UP,LOWER_UP>}} is what indicates the interface is up, not the later {{ic|state DOWN}}.
  
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.
+
{{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 [[#Routing table]] for reestablishing it.}}
 
=== Dynamic IP address ===
 
  
==== Manually run DHCP Client Daemon ====
+
=== Static IP address ===
  
Please note that {{ic|dhcpcd}} is not {{ic|dhcpd}}.
+
A static IP address can be configured with most standard [[#Network managers|#network managers]] and also [[dhcpcd]].
  
{{hc|# dhcpcd eth0|
+
To manually configure a static IP address, add an IP address as described in [[#IP addresses]], set up your [[#Routing table]] and [[resolv.conf|configure your DNS servers]].
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.
+
=== IP addresses ===
  
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.
+
[[Wikipedia:IP address|IP addresses]] are managed using {{man|8|ip-address}}.
  
==== Run DHCP at boot ====
+
List IP addresses:
  
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).
+
$ ip address show
  
To start DHCP for {{ic|eth0}}, simply use:
+
Add an IP address to an interface:
  
  # systemctl start dhcpcd@eth0
+
  # ip address add ''address/prefix_len'' broadcast + dev ''interface''
  
You can enable the service to automatically start at boot with:
+
:Note that:
  
# systemctl enable dhcpcd@eth0
+
:* the address is given in [[Wikipedia:Classless Inter-Domain Routing#CIDR notation|CIDR notation]] to also supply a [[Wikipedia:Subnetwork|subnet mask]]
 +
:* {{ic|+}} is a special symbol that makes {{ic|ip}} derive the [[Wikipedia:Broadcast address|broadcast address]] from the IP address and the subnet mask
  
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:
+
:{{Note|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].
 +
}}
  
{{hc|/etc/modules-load.d/realtek.conf|
+
Delete an IP address from an interface:
r8169}}
 
  
{{Tip|To find out which modules are used by your network card, use {{ic|lspci -k}}.}}
+
$ ip address del ''address/prefix_len'' dev ''interface''
  
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}}:
+
Delete all addresses matching a criteria, e.g. of a specific interface:
  
{{hc|/etc/dhcpcd.conf|
+
$ ip address flush dev ''interface''
nohook resolv.conf}}
 
  
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:
+
{{Tip|IP addresses can be calculated with [http://jodies.de/ipcalc ipcalc] ({{Pkg|ipcalc}}).}}
  
{{hc|/etc/dhcpcd.conf|
+
=== Routing table ===
nooption domain_name_servers}}
 
  
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.
+
The [[Wikipedia:Routing table|routing table]] is used to determine if you can reach an IP address directly or what gateway (router) you should use. If no other route matches the IP address, the [[Wikipedia:Default gateway|default gateway]] is used.
  
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}}.
+
The routing table is managed using {{man|8|ip-route}}.
  
=== Static IP address ===
+
''PREFIX'' is either a CIDR notation or {{ic|default}} for the default gateway.
  
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.
+
List routes:
  
{{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 problems.}}
+
$ ip route show
  
You need:
+
Add a route:
  
* Static IP address
+
# ip route add ''PREFIX'' via ''address'' dev ''interface''
* [[Wikipedia:Subnetwork|Subnet mask]]
 
* [[Wikipedia:Broadcast_address|Broadcast address]]
 
* [[Wikipedia:Default_gateway|Gateway]]'s IP address
 
  
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.
+
Delete a route:
  
==== Manual assignment ====
+
# ip route del ''PREFIX'' via ''address'' dev ''interface''
  
You can assign a static IP address in the console:
+
=== DHCP ===
  
# ip addr add <IP address>/<subnet mask> dev <interface>
+
A [[Wikipedia:DHCP|DHCP]] server provides clients with a dynamic IP address, the subnet mask, the default gateway IP address and optionally also with DNS name servers.
  
For example:
+
{{Note|You should not run two DHCP clients simultaneously.}}
  
# ip addr add 192.168.1.2/24 dev eth0
+
To use DHCP you need a DHCP server in your network and a DHCP client:
  
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}
+
{| class="wikitable"
 +
! Client !! Package !! [[Archiso]] !! Note !! Systemd units
 +
|-
 +
| [[dhcpcd]] || {{Pkg|dhcpcd}} || {{Yes}} || DHCP, DHCPv6, ZeroConf, static IP || {{ic|dhcpcd.service}}, {{ic|dhcpcd@''interface''.service}}
 +
|-
 +
| [https://www.isc.org/downloads/dhcp/ ISC DHCP] || {{Pkg|dhclient}} || {{Yes}} || DHCP, BOOTP, static IP || {{ic|dhclient@''interface''.service}}
 +
|-
 +
| [https://packages.debian.org/wheezy/pump pump] || {{AUR|pump}} || {{no}} || DHCP, BOOTP || ?
 +
|}
  
For more options, see {{ic|man ip}}.
+
Note that instead of directly using a DHCP client you can also use a [[#Network managers|#network manager]].
  
Add your gateway like so:
+
=== Network managers ===
 +
A network manager lets you manage network connection settings in so called network profiles to facilitate switching networks.
  
# ip route add default via <default gateway IP address>
+
{{Note|There are many solutions to choose from, but remember that all of them are mutually exclusive; you should not run two daemons simultaneously.}}
  
For example:
+
{{Style|[[Wifi Radar]] does not fit into the table - let's move it to [[Wireless network configuration#Utilities]] and then remove the "handles wired connections" column.}}
  
# ip route add default via 192.168.1.1
+
{| class="wikitable"
 +
! Network manager || handles wired<br>connections || GUI || [[Archiso]] [https://git.archlinux.org/archiso.git/tree/configs/releng/packages.both] || CLI tools || [[Wikipedia:Point-to-Point Protocol|PPP]] support <br>(e.g. 3G modem) || [[#DHCP]] client || Systemd units
 +
|-
 +
| [[ConnMan]] || {{Yes}} || {{Y|8 unofficial}} || {{No}} || {{G|{{man|1|connmanctl}}}} || {{Yes}} || internal || {{ic|connman.service}}
 +
|-
 +
| [[netctl]] || {{Yes}} || {{Y|2 unofficial}} || {{Yes}} ({{grp|base}}) || {{G|{{man|1|netctl}}, wifi-menu}} || {{Yes}} || [[dhcpcd]] or {{Pkg|dhclient}} || {{ic|netctl-ifplugd@''interface''.service}}, {{ic|netctl-auto@''interface''.service}}
 +
|-
 +
| [[NetworkManager]] || {{Yes}} || {{Yes}} || {{No}} || {{G|{{man|1|nmcli}}, {{man|1|nmtui}}}} || {{Yes}} || internal, [[dhcpcd]] or {{Pkg|dhclient}} || {{ic|NetworkManager.service}}
 +
|-
 +
| [[systemd-networkd]] || {{Yes}} || {{No}} || {{Yes}} ({{grp|base}}) || {{No}} || ? || internal || {{ic|systemd-networkd.service}}, {{ic|systemd-resolved.service}}
 +
|-
 +
| [[Wicd]] || {{Yes}} || {{Yes}} || {{No}} || {{G|{{man|8|wicd-cli}}, {{man|8|wicd-curses}}}} || {{No}} || [[dhcpcd]] || {{ic|wicd.service}}
 +
|-
 +
| [[Wifi Radar]] || {{No}} || {{Yes}} || {{No}} || {{No}} || {{No}}|| any (just runs command)
 +
|}
  
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.
+
See also [[List of applications#Network managers]].
  
====Manual connection at boot using systemd====
+
== Resolving domain names ==
This section details how to manually connect using [[systemd]].
+
{{Move|Domain name resolution||Talk:Domain name resolution#Rewrite}}
  
{{Note|We use {{ic|net0}} as the interface name in these examples, you have to replace all occurrences (including those in the {{ic|BindsTo}} and {{ic|After}} values) with the name of the interface you are configuring.}}
+
To resolve a [[Wikipedia:Domain name|domain name]] using your system configuration, run:
  
=====Using [[dhcpcd]]=====
+
$ getent hosts ''domain_name''
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
 
BindsTo=sys-subsystem-net-devices-net0.device
 
After=sys-subsystem-net-devices-net0.device
 
  
[Service]
+
For more fine-grained DNS queries use a dedicated DNS lookup utility, like {{man|1|dig}} (provided by {{Pkg|bind-tools}}) or {{man|1|drill}} (provided by {{Pkg|ldns}}).
Type=oneshot
 
RemainAfterExit=yes
 
ExecStart=/usr/bin/ip link set dev net0 up
 
ExecStart=/usr/bin/wpa_supplicant -B -i net0 -c /etc/wpa_supplicant.conf # Remove this for wired connections
 
ExecStart=/usr/bin/dhcpcd net0
 
  
ExecStop=/usr/bin/dhcpcd -k net0
+
If you cannot resolve domain names but you are connected to the internet, see [[resolv.conf]] and check the {{ic|hosts}} line in {{man|5|nsswitch.conf}}.
ExecStop=/usr/bin/ip addr flush dev net0
 
ExecStop=/usr/bin/ip link set dev net0 down
 
  
[Install]
+
== Set the hostname ==
WantedBy=multi-user.target
 
</nowiki>}}
 
  
# systemctl enable network
+
A [[Wikipedia:Hostname|hostname]] is a unique name created to identify a machine on a network, configured in {{ic|/etc/hostname}}—see {{man|5|hostname}} and {{man|7|hostname}} for details. The file can contain the system's domain name, if any. To set the hostname, [[textedit|edit]] {{ic|/etc/hostname}} to include a single line with {{ic|''myhostname''}}:
  
To test, reboot or stop all other network daemons and run as root:
+
{{hc|/etc/hostname|
# systemctl start network
+
''myhostname''
 +
}}
  
=====Using a static IP address=====
+
{{Tip|For advice on choosing a hostname, see [https://tools.ietf.org/html/rfc1178 RFC 1178].}}
Create the file {{ic|/etc/systemd/system/network.service}} using your editor of choice. This example uses a static IP address and [[wpa_supplicant]].
 
{{hc|/etc/systemd/system/network.service|<nowiki>
 
[Unit]
 
Description=Wireless Static IP Connectivity
 
Wants=network.target
 
Before=network.target
 
BindsTo=sys-subsystem-net-devices-net0.device
 
After=sys-subsystem-net-devices-net0.device
 
  
[Service]
+
Alternatively, using {{man|1|hostnamectl}}:
Type=oneshot
 
RemainAfterExit=yes
 
ExecStart=/usr/bin/ip link set dev net0 up
 
ExecStart=/usr/bin/wpa_supplicant -B -i net0 -c /etc/wpa_supplicant.conf # Remove this for wired connections
 
ExecStart=/usr/bin/ip addr add 192.168.0.10/24 dev net0
 
ExecStart=/usr/bin/ip route add default via 192.168.0.1
 
  
ExecStop=/usr/bin/ip addr flush dev net0
+
# hostnamectl set-hostname ''myhostname''
ExecStop=/usr/bin/ip link set dev net0 down
 
  
[Install]
+
To temporarily set the hostname (until reboot), use {{man|1|hostname}} from {{Pkg|inetutils}}:
WantedBy=multi-user.target
 
</nowiki>}}
 
  
Do not forget to enable it!
+
  # hostname ''myhostname''
  # systemctl enable network
 
  
To test, reboot or make sure all other network daemons are stopped and then run as root
+
To set the "pretty" hostname and other machine metadata, see {{man|5|machine-info|https://www.freedesktop.org/software/systemd/man/machine-info.html}}.
# systemctl start network
 
  
==== Calculating addresses ====
+
=== Local network hostname resolution ===
 +
{{Move|Domain name resolution||Talk:Domain name resolution#Rewrite}}
  
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.
+
The pre-requisite is to [[#Set the hostname]], after which hostname resolution works on the local system itself:
  
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=
+
{{hc|$ ping ''myhostname''|2=
Address:  10.66.66.1
+
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
 +
}}
  
Netmask:  255.255.255.252 = 30
+
To allow other machines to address the host by name, it is necessary to either:
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 ==
+
* Configure the {{man|5|hosts}} file, or
 +
* Enable a service which resolves the hostname.
  
To test your settings either reboot the computer or reload the relevant systemd services:
+
{{Note|1={{Pkg|systemd}} provides hostname resolution via the {{ic|myhostname}} nss module, enabled by default in {{ic|/etc/nsswitch.conf}}. However, clients may still rely on {{ic|/etc/hosts}}, see [https://lists.debian.org/debian-devel/2013/07/msg00809.html] [https://bugzilla.mozilla.org/show_bug.cgi?id=87717#c55] for examples.}}
  
# systemctl restart dhcpcd@eth0
+
To configure the hosts file, add the following line to {{ic|/etc/hosts}}:
  
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:
+
127.0.1.1 ''myhostname''.localdomain ''myhostname''
  
$ ping -c 3 www.google.com
+
{{Note|The order of hostnames/aliases that follow the IP address in {{ic|/etc/hosts}} is significant. The first string is considered the canonical hostname and may be appended with parent domains, where domain components are separated by a dot (ie. {{ic|.localdomain}} above). All following strings on the same line are considered aliases. See {{man|5|hosts}} for more info.}}
  
== Additional settings ==
+
As a result the system resolves to both entries:
  
=== ifplugd for laptops ===
+
{{hc|$ getent hosts|
 +
127.0.0.1      localhost
 +
127.0.1.1      ''myhostname''.localdomain ''myhostname''
 +
}}
  
{{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.
+
For a system with a permanent IP address, that permanent IP address should be used instead of {{ic|127.0.1.1}}.  
  
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}}.
+
{{Note|1=Another option 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:
 +
* [[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, macOS, or Linux with {{ic|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 macOS, 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.
 +
}}
  
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}
+
== Tips and tricks ==
  
=== Bonding or LAG ===
+
=== Change interface name ===
  
 +
{{Note|When changing the naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change.}}
  
You will need {{Pkg|netctl}} from the [[Official Repositories]].
+
You can change the device name by defining the name manually with an udev-rule. For example:
  
copy {{ic|/etc/netctl/examples/bonding}} to {{ic|/etc/netctl/bonding}} and edit it, for example, to be the following:  
+
{{hc|/etc/udev/rules.d/10-network.rules|2=
 +
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"
 +
}}
  
{{hc|/etc/netctl/bonding|2=
+
These rules will be applied automatically at boot.
Description='Bond Interface'
 
Interface='bond0'
 
Connection=bond
 
BindsToInterfaces=('eth0' 'eth1')
 
IP=dhcp
 
IP6=stateless}}
 
  
Now you can disable and stop your old configuration and  set bonding to be automaticly started:
+
A couple of things to note:
  
Disable your old configuration:
+
* To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/''device_name''/address}}
# netctl stop ethernet
+
* Make sure to use the lower-case hex values in your udev rules. It does not like upper-case.
# netctl disable ethernet
 
Enable and start bonding:
 
# netctl start bonding
 
# netctl enable bonding
 
  
{{Note|To change the bonding mode (default is round robin) to, e.g, active backup:
+
If the network card has a dynamic MAC, you can use {{ic|DEVPATH}}, for example:
  
Create {{ic|/etc/modprobe.d/bonding.conf}}:
+
{{hc|/etc/udev/rules.d/10-network.rules|2=
 +
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"
 +
SUBSYSTEM=="net", DEVPATH=="/devices/pci*/*1c.0/*/net/*", NAME="en"
 +
}}
  
{{hc|/etc/modprobe.d/bonding.conf|2=
+
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}}.
options bonding mode=active-backup
 
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] and [http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding The Linux Foundation: bonding].}}
+
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}}).
  
To check the status and bonding mode:
+
{{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.}}
  
$ cat /proc/net/bonding/bond0
+
=== Revert to traditional interface names ===
  
==== Wired -> Wireless Failover ====
+
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 by masking the udev rule:
  
Using {{ic|bonding}} to fallback to wireless when the wired ethernet goes down, this also detects the presence of either network connection and starts dhcpcd when either or both are connected.
+
# ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
  
You'll need {{Pkg|netctl}}, {{Pkg|ifplugd}}, {{Pkg|ifenslave}}, and {{Pkg|wpa_supplicant}} from the official repositories.
+
Alternatively, add {{ic|1=net.ifnames=0}} to the [[kernel parameters]].
  
First configure the bonding driver to use active-backup:
+
=== Set device MTU and queue length ===
  
{{hc|/etc/modprobe.d/bonding.conf|2=
+
You can change the device [[wikipedia:Maximum transmission unit|MTU]] and queue length by defining manually with an udev-rule. For example:
options bonding mode=active-backup
 
options bonding miimon=100
 
options bonding primary=eth0
 
options bonding max_bonds=0}}
 
  
The `max-bonds` line avoids getting the "Interface bond0 already exists" error.
+
{{hc|/etc/udev/rules.d/10-network.rules|2=
 +
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1500", ATTR{tx_queue_len}="2000"
 +
}}
  
Next, configure a {{Pkg|netctl}} profile to enslave the two hardware interfaces:
+
{{Note|
 +
* {{ic|mtu}}: For PPPoE, the MTU should be no larger than 1492. You can also set MTU via {{man|5|systemd.netdev}}.
 +
* {{ic|tx_queue_len}}: Small value for slower devices with a high latency like modem links and ISDN. High value is recommend for server connected over the high-speed Internet connections that perform large data transfers.
 +
}}
  
{{hc|/etc/netctl/failover|2=
+
=== ifplugd for laptops ===
Description='A wired connection with failover to wireless'
 
Interface='bond0'
 
Connection=bond
 
BindsToInterfaces=('eth0' 'wlan0')
 
IP='no'
 
SkipNoCarrier='no'}}
 
  
Enable the profile on startup.
+
{{Tip|[[dhcpcd]] provides the same feature out of the box.}}
  
# netctl enable failover
+
{{Pkg|ifplugd}} 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.
  
Configure wpa_supplicant to associate with known networks. This can be done with a netctl profile (remember to use IP='no'), a wpa_supplicant service running constantly, or on-demand with wpa_cli. Ways to do this are covered on the [[wpa_supplicant]] page.
+
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}}.
  
Create an {{Pkg|ifplugd}} action for automatic DHCP assignment on the bonded interface:
+
{{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}}.}}
  
{{hc|/etc/ifplugd/bond_dhcp.action|2=
+
=== Bonding or LAG ===
#!/bin/sh
 
 
 
case "$2" in
 
  up)
 
    systemctl start "dhcpcd@$1.service" && exit 0
 
    ;;
 
  down)
 
    systemctl stop "dhcpcd@$1.service" && exit 0
 
    ;;
 
  *)
 
    echo "Wrong arguments" > /dev/stderr
 
    ;;
 
esac
 
exit 1}}
 
 
 
and make it executable
 
 
 
# chmod +x /etc/ifplugd/bond_dhcp.action
 
 
 
Then create the [[systemd]] service which starts ifplugd for bond0:
 
 
 
{{hc|/etc/systemd/system/net-auto-bonded@.service|2=
 
[Unit]
 
Description=Provides automatic dhcp resolution for bonded failover connection
 
Requires=netctl@failover.service
 
After=netctl@failover.service
 
 
 
[Service]
 
ExecStart=/usr/bin/ifplugd -i %i -r /etc/ifplugd/bond_dhcp.action -fIns
 
 
 
[Install]
 
WantedBy=multi-user.target}}
 
 
 
Enable the net-auto-bonded service and reboot:
 
 
 
# systemctl enable net-auto-bonded@bond0.service
 
# reboot
 
  
If you have a wired and wireless connection to the same network, you can probably now disconnect and reconnect the wired connection without losing connectivity. In most cases, even streaming music won't skip!
+
See [[netctl#Bonding]] or [[Wireless bonding]].
  
 
=== 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. 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).
 
 
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|netctl}} from the [[Official Repositories]].
+
To manually set an alias, for some NIC, use {{Pkg|iproute2}} to execute
  
Prepare the configuration:
+
# ip addr add 192.168.2.101/24 dev eth0 label eth0:1
  
{{hc|/etc/netctl/mynetwork|2=
+
To remove a given alias execute
  
Connection='ethernet'
+
# ip addr del 192.168.2.101/24 dev eth0:1
Description='Five different addresses on the same NIC.'
 
Interface='eth0'
 
IP='static'
 
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')
 
Gateway='192.168.1.1'
 
DNS=('192.168.1.1')
 
Donain=''
 
}}
 
Then simply execute:
 
  
$ netctl start mynetwork
+
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}}.
  
=== Change MAC/hardware address ===
+
=== Promiscuous mode ===
  
See [[MAC Address Spoofing]].
+
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]].
  
=== Internet Share ===
+
{{hc|/etc/systemd/system/promiscuous@.service|<nowiki>
 +
[Unit]
 +
Description=Set %i interface in promiscuous mode
 +
After=network.target
  
See [[Internet Share]].
+
[Service]
 +
Type=oneshot
 +
ExecStart=/usr/bin/ip link set dev %i promisc on
 +
RemainAfterExit=yes
  
=== Router Configuration ===
+
[Install]
 +
WantedBy=multi-user.target
 +
</nowiki>}}
  
See [[Router]].
+
If you want to enable promiscuous mode on interface {{ic|eth0}} run [[enable]] {{ic|promiscuous@eth0.service}}.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 509: Line 405:
 
=== 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 (Vidéotron 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 [[MAC address spoofing]].
  
 
=== The TCP window scaling problem ===
 
=== The TCP window scaling problem ===
Line 517: Line 413:
 
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 529: Line 421:
 
==== 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 us 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 {{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 problem: ping uses ICMP and is not affected by TCP problems.
+
If you cannot browse any website, but you can ping some random hosts, chances are great that you are 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).
+
==== Ways of fixing it ====
  
==== How to fix it (The bad way) ====
+
===== 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.
+
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 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.
+
This problem is caused by broken routers/firewalls, so let us change them. Some users have reported that the broken router was their very own DSL router.
  
 
==== More about it ====
 
==== More about it ====
Line 561: Line 455:
 
=== Realtek no link / WOL problem ===
 
=== 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 operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this 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 official 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.
  
==== 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 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".
  
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 and choose "Properties"
  Right click my computer
+
  --> "Hardware" tab
  --> Hardware tab
 
 
   --> Device Manager
 
   --> Device Manager
 
     --> Network Adapters
 
     --> Network Adapters
Line 581: Line 480:
 
             --> Enable
 
             --> 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 {{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 problem ===
+
{{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 problems 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),
+
{{hc|$ 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, unplug your cable then do 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 your network cable back in and check whether the module succeeded with:
  
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.
+
$ dmesg | greg tg3
  
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:
+
* If this procedure solved the issue you can make it permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array:
 +
{{hc|/etc/mkinitcpio.conf|2=MODULES=(.. broadcom tg3 ..)}}
  
DHCPCD_ARGS="-t 30 -h $HOSTNAME"
+
* [[Regenerate the initramfs]]
 +
* Alternatively, you can create an {{ic|/etc/modprobe.d/broadcom.conf}}:
  
Add the {{ic|-R}} flag to the arguments, e.g.,
+
softdep tg3 pre: broadcom
  
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
+
{{Note|These methods may work for other chipsets, such as BCM57760.}}
  
{{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.}}
+
=== Realtek RTL8111/8168B ===
  
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.
+
{{hc|# lspci {{!}} grep Ethernet|
 
+
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
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:
 
 
 
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.
 
 
 
 
 
=== No eth0 with Atheros AR8161 ===
 
 
 
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}
 
 
 
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.
 
 
 
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.
 
  $ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2
 
  $ tar xjf compat*
 
  $ cd compat*
 
  $ ./scripts/driver-select alx
 
  $ make
 
  $ sudo make install
 
  $ sudo modprobe alx
 
 
 
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.
 
 
 
The driver must be built and installed after every kernel change.
 
 
 
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.
 
 
 
=== No eth0 with Atheros AR9485 ===
 
 
 
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.
 
 
 
=== Connection problems with Atheros AR9485 Wireless Network Adapter ===
 
 
 
You may experience connection problems with the Atheros AR9485 Wireless Network Adapter, which is caused by incorrect power management functioning. You can notice the problem if you're experiencing random disconnections in [[Wikipedia:Instant messaging|IM]] or other software that keeps connection alive for a long time.
 
 
 
In case you're using laptop, first you must disable battery power-over-perfomance feature: '''Settings / Power Manager / On Battery / Prefer power savings over perfomance'''
 
 
 
Next thing to do is switch off power management for adapter. You should add {{bc|iwconfig wlan0 power off}} (assuming wlan0 is your AR9485 adapter) anywhere it can be executed on system init (or simply run it once, to fix the problem for current session) and that should do it.
 
 
 
=== No carrier / no connection after suspend ===
 
After suspend to RAM no connection is found although the network cable is plugged in.
 
This may be caused by PCI power management. What is the output of
 
 
 
# ip link show eth0
 
 
 
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by
 
 
 
# lspci
 
 
 
This should look similar to this:
 
 
 
...
 
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)
 
...
 
 
 
So the address is 00:19.0.
 
Now check the PM status of the device by issuing
 
  
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"
+
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}} should be used for a reliable connection in this case. [[Blacklist]] {{ic|r8169}}, if {{Pkg|r8168}} is not automatically loaded by [[udev]], see [[Kernel modules#Automatic module handling]].
  
substituting 00:19.0 with the address obtained from lspci.
+
{{Accuracy|"some revisions", no proof the driver is the cause, and not e.g poorly configured DNS servers}}
If the output reads "auto", you can try to bring the device out of suspend by
 
  
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"
+
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.
  
Don't forget to substitute the address again.
+
=== Gigabyte Motherboard with Realtek 8111/8168/8411 ===
  
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}
+
With motherboards such as the ''Gigabyte GA-990FXA-UD3'', booting with [[PCI passthrough via OVMF#Setting up IOMMU|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 to the onboard NIC and to any other pci-NIC 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 boots normally, resulting in a fully functional onboard NIC (even with the r8169 module).
  
=== PC Pingable by IP but not by hostname? ===
+
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.
This issue hunted me for months! Turns out to be a very simple fix IF you are using samba as well. Usually people only start smbd which is enough for network access to work, but does not advocate the pc's name to the router. nmbd is doing that so you should always have:
 
systemctl enable smbd.service
 
systemctl enable nmbd.service
 
  
Which makes them run at startup. If you don't want to restart then you can start then right away with:
+
== See also ==
systemctl start smbd.service
 
systemctl start nmbd.service
 
  
And that makes the computer available by name on the network.
+
* [https://www.debian.org/doc/manuals/debian-reference/ch05.en.html Debian Reference: Network setup]
 +
* [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ RHEL7: Networking Guide]
 +
* [http://www.linuxhomenetworking.com/wiki/ Linux Home Networking]
 +
* [https://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/ Monitoring and tuning the Linux Networking Stack: Receiving data]
 +
* [https://blog.packagecloud.io/eng/2017/02/06/monitoring-tuning-linux-networking-stack-sending-data/ Monitoring and tuning the Linux Networking Stack: Sending data]
 +
* [http://blog.yadutaf.fr/2017/07/28/tracing-a-packet-journey-using-linux-tracepoints-perf-ebpf/ Tracing a packet journey using tracepoints, perf and eBPF]

Latest revision as of 08:15, 23 May 2018

This article explains how to configure a network connection.

Check the connection

To troubleshoot a network connection, go through the following conditions and ensure that you meet them:

  1. Your #network interface is listed and enabled.
  2. You are connected to the network. The cable is plugged in or you are connected to the wireless LAN.
  3. Your network interface has an #IP address
  4. Your #routing table is correctly set up.
  5. You can #ping a local IP address (e.g. your default gateway).
  6. You can #ping a public IP address (e.g. 8.8.8.8), if you can't it may be related to your default gateway or your internet service provider.
  7. You can resolve domain names (e.g. archlinux.org), see #Resolving domain names.
Note: 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.

Ping

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Add or link explanation of common ping errors like Unknown hosts / Network is unreachable. (Discuss in Talk:Network configuration#)
ping is used to test if you can reach a host.
$ ping www.example.com
PING www.example.com (93.184.216.34): 56(84) data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=11.726 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=10.683 ms
...

For every reply you receive ping prints a line like above. For more information see the ping(8) manual.

Note that computers can be configured not to respond to ICMP echo requests.[1]

When you receive no reply, you can use a traceroute (traceroute(8) or tracepath(8)) to further diagnose the route to the host.

Note: If you receive an error like ping: icmp open socket: Operation not permitted when executing ping, try to re-install the iputils package.

Device driver

Check the status

udev should detect your network interface controller (NIC) and automatically load the necessary kernel module at startup. 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 is 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 module#Automatic module handling.

Network management

To set up a network connection, go through the following steps:

  1. Ensure your #network interface is listed and enabled.
  2. Connect to the network. Plug in the Ethernet cable or connect to the wireless LAN.
  3. Configure your network connection:
Tip: #Network managers provide automatic network connection and configuration based on network profiles.

The iproute2 package provides the ip(8) command-line utility, used to manage #Network interfaces, #IP addresses and the #Routing table. Be aware that configuration made using ip will be lost after a reboot. You can automate ip commands using scripts and systemd units. Also note that ip commands can generally be abbreviated, for clarity they are however spelled out in this article.

Network interfaces

By default udev assigns names to your network interfaces using Predictable Network Interface Names, which prefixes interfaces names with en (wired/Ethernet), wl (wireless/WLAN), or ww (WWAN).

Tip: To change interface names, see #Change interface name and #Revert to traditional interface names.

Listing network interfaces

Both wired and wireless interface names can be found via ls /sys/class/net or ip link. Note that lo is the loop device and not used in making network connections.

Wireless device names can also be retrieved using iw dev. See also Wireless network configuration#Get the name of the interface.

If your network interface is not listed, make sure your #Device driver was loaded successfully.

Enabling and disabling network interfaces

Network interfaces can be enabled / disabled using ip link set interface up|down, see ip-link(8).

To check the status of the interface eth0:

$ ip link show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT qlen 1000
...

The UP in <BROADCAST,MULTICAST,UP,LOWER_UP> is what indicates the interface is up, not the later state DOWN.

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 #Routing table for reestablishing it.

Static IP address

A static IP address can be configured with most standard #network managers and also dhcpcd.

To manually configure a static IP address, add an IP address as described in #IP addresses, set up your #Routing table and configure your DNS servers.

IP addresses

IP addresses are managed using ip-address(8).

List IP addresses:

$ ip address show

Add an IP address to an interface:

# ip address add address/prefix_len broadcast + dev interface
Note that:
Note: Make sure manually assigned IP addresses do not conflict with DHCP assigned ones. See this forum thread.

Delete an IP address from an interface:

$ ip address del address/prefix_len dev interface

Delete all addresses matching a criteria, e.g. of a specific interface:

$ ip address flush dev interface
Tip: IP addresses can be calculated with ipcalc (ipcalc).

Routing table

The routing table is used to determine if you can reach an IP address directly or what gateway (router) you should use. If no other route matches the IP address, the default gateway is used.

The routing table is managed using ip-route(8).

PREFIX is either a CIDR notation or default for the default gateway.

List routes:

$ ip route show

Add a route:

# ip route add PREFIX via address dev interface

Delete a route:

# ip route del PREFIX via address dev interface

DHCP

A DHCP server provides clients with a dynamic IP address, the subnet mask, the default gateway IP address and optionally also with DNS name servers.

Note: You should not run two DHCP clients simultaneously.

To use DHCP you need a DHCP server in your network and a DHCP client:

Client Package Archiso Note Systemd units
dhcpcd dhcpcd Yes DHCP, DHCPv6, ZeroConf, static IP dhcpcd.service, dhcpcd@interface.service
ISC DHCP dhclient Yes DHCP, BOOTP, static IP dhclient@interface.service
pump pumpAUR No DHCP, BOOTP  ?

Note that instead of directly using a DHCP client you can also use a #network manager.

Network managers

A network manager lets you manage network connection settings in so called network profiles to facilitate switching networks.

Note: There are many solutions to choose from, but remember that all of them are mutually exclusive; you should not run two daemons simultaneously.

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Wifi Radar does not fit into the table - let's move it to Wireless network configuration#Utilities and then remove the "handles wired connections" column. (Discuss in Talk:Network configuration#)
Network manager handles wired
connections
GUI Archiso [2] CLI tools PPP support
(e.g. 3G modem)
#DHCP client Systemd units
ConnMan Yes 8 unofficial No connmanctl(1) Yes internal connman.service
netctl Yes 2 unofficial Yes (base) netctl(1), wifi-menu Yes dhcpcd or dhclient netctl-ifplugd@interface.service, netctl-auto@interface.service
NetworkManager Yes Yes No nmcli(1), nmtui(1) Yes internal, dhcpcd or dhclient NetworkManager.service
systemd-networkd Yes No Yes (base) No  ? internal systemd-networkd.service, systemd-resolved.service
Wicd Yes Yes No wicd-cli(8), wicd-curses(8) No dhcpcd wicd.service
Wifi Radar No Yes No No No any (just runs command)

See also List of applications#Network managers.

Resolving domain names

Tango-go-next.pngThis article or section is a candidate for moving to Domain name resolution.Tango-go-next.png

Notes: (Discuss in Talk:Domain name resolution#Rewrite)

To resolve a domain name using your system configuration, run:

$ getent hosts domain_name

For more fine-grained DNS queries use a dedicated DNS lookup utility, like dig(1) (provided by bind-tools) or drill(1) (provided by ldns).

If you cannot resolve domain names but you are connected to the internet, see resolv.conf and check the hosts line in nsswitch.conf(5).

Set the hostname

A hostname is a unique name created to identify a machine on a network, configured in /etc/hostname—see hostname(5) and hostname(7) for details. The file can contain the system's domain name, if any. To set the hostname, edit /etc/hostname to include a single line with myhostname:

/etc/hostname
myhostname
Tip: For advice on choosing a hostname, see RFC 1178.

Alternatively, using hostnamectl(1):

# hostnamectl set-hostname myhostname

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

# hostname myhostname

To set the "pretty" hostname and other machine metadata, see machine-info(5).

Local network hostname resolution

Tango-go-next.pngThis article or section is a candidate for moving to Domain name resolution.Tango-go-next.png

Notes: (Discuss in Talk:Domain name resolution#Rewrite)

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 allow other machines to address the host by name, it is necessary to either:

  • Configure the hosts(5) file, or
  • Enable a service which resolves the hostname.
Note: systemd provides hostname resolution via the myhostname nss module, enabled by default in /etc/nsswitch.conf. However, clients may still rely on /etc/hosts, see [3] [4] for examples.

To configure the hosts file, add the following line to /etc/hosts:

127.0.1.1	myhostname.localdomain	myhostname
Note: The order of hostnames/aliases that follow the IP address in /etc/hosts is significant. The first string is considered the canonical hostname and may be appended with parent domains, where domain components are separated by a dot (ie. .localdomain above). All following strings on the same line are considered aliases. See hosts(5) for more info.

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.

Note: Another option 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:
  • Samba provides hostname resolution via Microsoft's NetBIOS. It only requires installation of samba and enabling of the nmbd.service service. Computers running Windows, macOS, 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 macOS, 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.

Tips and tricks

Change interface name

Note: When changing the naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change.

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 does not 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.

Revert to traditional interface names

If you would prefer to retain traditional interface names such as eth0, Predictable Network Interface Names can be disabled by masking the udev rule:

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

Alternatively, add net.ifnames=0 to the kernel parameters.

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}="1500", ATTR{tx_queue_len}="2000"
Note:
  • mtu: For PPPoE, the MTU should be no larger than 1492. You can also set MTU via systemd.netdev(5).
  • tx_queue_len: Small value for slower devices with a high latency like modem links and ISDN. High value is recommend for server connected over the high-speed Internet connections that perform large data transfers.

ifplugd for laptops

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

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

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 (Vidéotron 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 MAC address spoofing.

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 us 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 are 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 us 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 official 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, unplug your cable then do the following:
# modprobe -r tg3
# modprobe broadcom
# modprobe tg3
  • Plug your network cable back in and check whether the module succeeded with:
$ dmesg | greg tg3
  • If this procedure solved the issue you can make it permanent by adding broadcom and tg3 (in this order) to the MODULES array:
/etc/mkinitcpio.conf
MODULES=(.. broadcom tg3 ..)
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 should be used for a reliable connection in this case. Blacklist r8169, if r8168 is not automatically loaded by udev, see Kernel modules#Automatic module handling.

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 to the onboard NIC and to any other pci-NIC 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 boots 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.

See also

Retrieved from "https://wiki.archlinux.org/index.php?title=Network_configuration&oldid=522669"