Difference between revisions of "Network configuration (Português)"

From ArchWiki
Jump to: navigation, search
m (updated to pacman -Syu)
(Starting the real translation. please, do not vandalize.)
Line 1: Line 1:
[[Category:Português]]
+
[[Category:Networking]]
 +
[[Category:Getting and installing Arch]]
 
[[cs:Configuring Network]]
 
[[cs:Configuring Network]]
[[en:Configuring Network]]
 
 
[[es:Configuring Network]]
 
[[es:Configuring Network]]
 +
[[fr:Connexions reseau]]
 
[[it:Configuring Network]]
 
[[it:Configuring Network]]
 +
[[ja:Network Configuration]]
 
[[nl:Configuring Network]]
 
[[nl:Configuring Network]]
 +
[[pt:Configuring Network]]
 
[[ro:Configurare retea]]
 
[[ro:Configurare retea]]
 
[[ru:Configuring Network]]
 
[[ru:Configuring Network]]
 
[[sk:Configuring Network]]
 
[[sk:Configuring Network]]
 
[[tr:Ağ_Yapılandırması]]
 
[[tr:Ağ_Yapılandırması]]
[[zh-CN:Configuring Network]]
+
[[zh-CN:Network Configuration]]
{{Bad translation}}
+
{{Article summary start}}
{{Out of date|Esse artigo ainda faz referência ao rc.conf, o qual está obsoleto.}}
+
{{Article summary text|A simple guide for setting up and troubleshooting network.}}
 +
{{Article summary heading|Overview}}
 +
{{Article summary text|{{Networking overview}}}}
 +
{{Article summary heading|Related}}
 +
{{Article summary wiki|Jumbo Frames}}
 +
{{Article summary wiki|Firewalls}}
 +
{{Article summary wiki|Wireless Setup}}
 +
{{Article summary end}}
  
=Introdução=
+
Esta página explica como configurar uma conexão '''cabeada'''. Se você deseja configurar uma rede '''wireless/sem fio''' veja a página[[Wireless_Setup (Português)|Configuração de Redes Sem Fio]].
  
Este tutorial visa a configuração de pequenas redes e como configurar conexões com a Internet disponíveis aqui no brasil.
+
== Verificando a conexão ==
 +
{{Note|Se você receber algum erro como {{ic|ping: icmp open socket: Operation not permitted}} quando executar o comando ping, tente reinstalar o pacote {{ic|iputils}}.}}
  
=Pacotes Necessários=
+
Muitas vezes, o procedimento básico de instalação cria uma configuração de rede cabeada. Para verificar se há configuração, utilize o seguinte comando:
+
{{Note|A opção {{ic|-c 3}} chama 3 vezes a ação de envio de pacotes icmp. Veja {{ic|man ping}} para maiores informações.}}
Para instalar os pacotes use o pacman:
+
  
pacman -Syu
+
{{hc|$ ping -c 3 www.google.com|2=
pacman -S nome_do_pacote
+
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
  
Logo abaixo está a lista de pacotes necessário ao seguir este tutorial:
+
--- www.l.google.com ping statistics ---
# lshwd
+
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
# module-init-tools
+
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms}}
  
=Instalando a Placa de Rede=
+
Caso funcione, você precisará apenas personalizar algumas das opções abaixo.
  
Antes de começarmos a configurar a rede vamos verificar se os módulos estão carregados corretamente. Para saber qual é a sua placa de rede e o módulo necessário digite no console:
+
Se o comando acima reclamar de unknown hosts(host desconhecido), significa que seu computador não pôde resolver nomes de domínios. Pode ser relacionado ao seu provedor de internet ou gateway/roteador. Tente pingar um endereço IP para provar que sua máquina possui acesso a internet.
+
lshwd | grep Ethernet
+
  
Aparecerá algo como:
+
{{hc|$ ping -c 3 8.8.8.8|2=
 +
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
  
03:06.0 Ethernet controller: Realtek|RTL8139 (8139too)
+
--- 8.8.8.8 ping statistics ---
 +
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
 +
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms}}
  
Os números são a identificação do barramento, a marca e o modelo vem logo depois de ''Ethernet Controller:'' e entre parênteses o nome do módulo necessário para a placa de rede funcionar. Caso não apareça nada digite somente ''lshwd'' e procure por lá sua placa de rede.
+
{{Note|{{ic|8.8.8.8}} é um endereço ip estático de fácil memorização. É o endereço do DNS primário do Google, considerado uma fonte confiável para testes e geralmente não bloqueado por sistemas de filtro de conteúdo ou proxies.}}
  
==Verificando se o Módulo está Carregado==
+
Caso você consiga pingar este endereço, pode adicioná-lo ao arquivo {{ic|/etc/resolv.conf}} com a palavra nameserver na frente como solução de dns.
  
Para verificar se o módulos foram carregados no console digite:
+
== Configurando um hostname ==
 +
Um A [[Wikipedia:Hostname|hostname]] é um endereço único criado para identificar um computador em uma rede. É configurado no arquivo {{ic|/etc/hostname}}. Este arquivo pode conter o domínio do sistema, se houver. Para configurar um hostname, execute:
  
  lsmod | grep 8139too
+
  # hostnamectl set-hostname '''meunome'''
  
'''Atenção''': Substitua o termo ''8139too'' pelo nome do módulo, o nome que estava entre parênteses no comando lshwd no capítulo anterior.
+
Este comando colocará a informação '''meunome''' no arquivo {{ic|/etc/hostname}}.
  
Se aparecer algo como:
+
Veja {{ic|man 5 hostname}} e {{ic|man 1 hostnamectl}} para maiores detalhes.
  
8139too            26622 0
 
  
Sua placa de rede já está instalada corretamente, caso contrário verifique se o módulo foi compilado com o kernel, digitando o seguinte comando no console:
+
{{Note|
 +
*{{ic|hostnamectl}} suporta FQDNs
 +
*Você não precisa mais editar o arquivo {{ic|/etc/hosts}}, pois o {{pkg|systemd}} proverá a resolução de nomes, e é instalado por padrão no sistema.}}
  
modprobe -l nome_do_módulo
+
Para alterar o hostname temporariamente(até o próximo restart), utilize o comando {{ic|hostname}} do pacote {{Pkg|inetutils}}:
  
Se aparecer algo como:
+
# hostname ''meunome''
  
/libmodules/2.6.16-ARCH/kernel/drivers/net/8139too.ko
+
== Drivers de dispositivos ==
  
O módulo foi compilado caso nada venha a aparecer o módulo não foi compilado e será necessário recompilar o kernel com o módulo necessário.
+
=== Verifique o estado do seu driver ===
  
Se módulo foi compilado no kernel, basta somente carregá-lo com o comando:
+
O [[udev]] deverá detectar sua interface de rede([http://pt.wikipedia.org/wiki/Placa_de_rede NIC]) e carregará automaticamente o módulo necessário. Busque pela entrada "Ethernet controller"(ou similar) no resultado do comando {{ic|lspci -v}}. Este comando dirá qual módulo do kernel é necessário para o funcionamento do dispositivo. Por exemplo:
  
  modprobe nome_do_módulo
+
{{hc|$ lspci -v|
 +
  02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)
 +
...
 +
Kernel driver in use: atl1
 +
Kernel modules: atl1}}
  
Para não ter que executar esse comando toda vez que iniciarmos o ARCH deveremos inserir o nome do módulo no arquivo /etc/rc.conf conforme o exemplo abaixo no qual usaremos como base o nome 8139too mas que deve ser substituído pelo nome do módulo de sua placa, use seu editor de textos predileto para isso.
+
Após, veja se o driver foi carregado através de um {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}}. Exemplo:
 +
 
 +
$ dmesg | grep atl1
 +
    ...
 +
    atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex
 +
 
 +
Pule para a próxima sessão caso o driver tenha sido carregado com sucesso. Caso contrário, você precisará descobrir qual é o módulo necessário para o seu modelo de interface de rede em específico.
 +
 
 +
=== Carregando o driver do dispositivo ===
 +
 
 +
Google for the right module/driver for the chipset. Some common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset. Once you know which module to use, try to [[Kernel modules#Manual module handling|load it manually]]. If you get an error saying that the module was not found, it's possible that the driver is not included in Arch kernel. You may search the [[AUR]] for the module name.
 +
 
 +
If udev is not detecting and loading the proper module automatically during bootup, see [[Kernel modules#Loading]].
 +
 
 +
== Network Interfaces ==
 +
 
 +
=== Device names ===
 +
 
 +
For motherboards that have integrated NICs, it is important to have fixed device name. Many configuration problems are caused by interface name changing.
 +
 
 +
[[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}}.
 +
 
 +
This behavior may be disabled by adding a symlink:
 +
 
 +
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
 +
 
 +
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.
 +
 
 +
{{Tip|You can run {{ic|ip link}} or {{ic|ls /sys/class/net}} to list all available interfaces.}}
 +
 
 +
==== Change device name ====
 +
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>}} -->
 +
* 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 ===
 +
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 ===
 +
 
 +
Current NIC names can be found via sysfs
 +
 
 +
{{hc|$ ls /sys/class/net|
 +
lo eth0 eth1 firewire0}}
 +
 
 +
=== Enabling and disabling network interfaces ===
 +
 
 +
You can activate or deactivate network interfaces using:
 +
 
 +
# ip link set eth0 up
 +
# ip link set eth0 down
 +
 
 +
To check the result:
 +
 
 +
{{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
 +
[...]}}
 +
 
 +
== Configure the IP address ==
 +
 
 +
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.
 
   
 
   
  #
+
=== Dynamic IP address ===
  # Modules to load at boot-up (in this order)
+
 
  #   - prefix a module with a ! to blacklist it
+
==== Manually run DHCP Client Daemon ====
  #  
+
 
  MODULES=(8139too)  
+
Please note that {{ic|dhcpcd}} is not {{ic|dhcpd}}.
 +
 
 +
{{hc|# dhcpcd eth0|
 +
dhcpcd: version 5.1.1 starting
 +
dhcpcd: eth0: broadcasting for a lease
 +
...
 +
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds}}
 +
 
 +
And now, {{ic|ip addr show dev eth0}} should show your inet address.
 +
 
 +
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.
 +
 
 +
==== Run DHCP at boot ====
 +
 
 +
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).
 +
 
 +
To start DHCP for {{ic|eth0}}, simply use:
 +
 
 +
  # systemctl start dhcpcd@eth0
 +
 
 +
You can enable the service to automatically start at boot with:
 +
 
 +
  # systemctl enable dhcpcd@eth0
 +
 
 +
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:
 +
 
 +
{{hc|/etc/modules-load.d/realtek.conf|
 +
r8169}}
 +
 
 +
{{Tip|To find out which modules are used by your network card, use {{ic|lspci -k}}.}}
 +
 
 +
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:
 +
 
 +
{{hc|/etc/dhcpcd.conf|
 +
nohook resolv.conf}}
 +
 
 +
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:
 +
 
 +
{{hc|/etc/dhcpcd.conf|
 +
nooption domain_name_servers}}
 +
 
 +
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.
 +
 
 +
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}}.
 +
 
 +
=== Static IP address ===
 +
 
 +
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.
 +
 
 +
{{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.}}
 +
 
 +
You need:
 +
 
 +
* Static IP address
 +
* [[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.
 +
 
 +
==== Manual assignment ====
 +
 
 +
You can assign a static IP address in the console:
 +
 
 +
# ip addr add <IP address>/<subnet mask> dev <interface>
 +
 
 +
For example:
 +
 
 +
# ip addr add 192.168.1.2/24 dev eth0
 +
 
 +
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}
 +
 
 +
For more options, see {{ic|man ip}}.
 +
 
 +
Add your gateway like so:
 +
 
 +
# ip route add default via <default gateway IP address>
 +
 
 +
For example:
 +
 
 +
# ip route add default via 192.168.1.1
 +
 
 +
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.
 +
 
 +
==== Manual connection at boot using systemd ====
 +
 
 +
First create configuration file for the [[systemd]] service, replace {{ic|<interface>}} with proper interface name:
 +
 
 +
{{hc|/etc/conf.d/network@<interface>|<nowiki>
 +
address=192.168.0.15
 +
netmask=24
 +
broadcast=192.168.0.255
 +
gateway=192.168.0.1
 +
</nowiki>}}
 +
 
 +
Create a systemd unit file:
 +
 
 +
{{hc|/etc/systemd/system/network@.service|<nowiki>
 +
[Unit]
 +
Description=Network connectivity (%i)
 +
Wants=network.target
 +
Before=network.target
 +
BindsTo=sys-subsystem-net-devices-%i.device
 +
After=sys-subsystem-net-devices-%i.device
 +
 
 +
[Service]
 +
Type=oneshot
 +
RemainAfterExit=yes
 +
EnvironmentFile=/etc/conf.d/network@%i
 +
ExecStart=/usr/bin/ip link set dev %i up
 +
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
 +
ExecStart=/usr/bin/ip route add default via ${gateway}
 +
 
 +
ExecStop=/usr/bin/ip addr flush dev %i
 +
ExecStop=/usr/bin/ip link set dev %i down
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 +
</nowiki>}}
 +
 
 +
Enable the unit and start it, passing the name of the interface:
 +
 
 +
# systemctl enable network@eth0.service
 +
# systemctl start network@eth0.service
 +
 
 +
==== Calculating addresses ====
 +
 
 +
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.
 +
 
 +
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|2=
 +
Address:  10.66.66.1
 +
 
 +
Netmask:  255.255.255.252 = 30
 +
Network:  10.66.66.0/30
 +
HostMin:  10.66.66.1
 +
HostMax:  10.66.66.2
 +
Broadcast: 10.66.66.3
 +
Hosts/Net: 2                    Class A, Private Internet}}
 +
 
 +
== Load configuration ==
 +
 
 +
To test your settings either reboot the computer or reload the relevant systemd services:
 +
 
 +
# systemctl restart dhcpcd@eth0
 +
 
 +
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:
 +
 
 +
$ ping -c 3 www.google.com
 +
 
 +
== Additional settings ==
 +
 
 +
=== ifplugd for laptops ===
 +
 
 +
{{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.
 +
 
 +
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|[[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}}.}}
 +
 
 +
=== Bonding or LAG ===
 +
 
 +
See [[netctl#Bonding]].
 +
 
 +
=== IP address aliasing ===
 +
 
 +
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}
 +
 
 +
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 ====
 +
 
 +
You will need {{Pkg|netctl}} from the [[Official Repositories]].
 +
 
 +
Prepare the configuration:
 +
 
 +
{{hc|/etc/netctl/mynetwork|2=
 +
Connection='ethernet'
 +
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')
 +
}}
 +
Then simply execute:
 +
 
 +
$ netctl start mynetwork
 +
 
 +
=== Change MAC/hardware address ===
 +
 
 +
See [[MAC Address Spoofing]].
 +
 
 +
=== Internet Share ===
 +
 
 +
See [[Internet Share]].
 +
 
 +
=== Router Configuration ===
 +
 
 +
See [[Router]].
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Swapping computers on the cable modem ===
 +
 
 +
Most domestic cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.
 +
 
 +
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].
 +
 
 +
=== The TCP window scaling problem ===
 +
 
 +
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.
 +
 
 +
Back in 1992, as more and more memory became available, [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.
 +
 
 +
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.
 +
 
 +
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.
 +
 
 +
The resulting connection is at best very slow or broken.
 +
 
 +
==== How to diagnose the problem ====
 +
 
 +
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).
 +
 
 +
When you have this problem, the {{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.
 +
 
 +
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).
 +
 
 +
==== How to fix it (The bad way) ====
 +
 
 +
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.
 +
 
 +
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem
 +
 
 +
==== How to fix it (The good way) ====
 +
 
 +
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.conf}} (see also [[sysctl]])
 +
 
 +
net.ipv4.tcp_window_scaling = 0
 +
 
 +
==== How to fix it (The best way) ====
 +
 
 +
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.
 +
 
 +
==== More about it ====
 +
 
 +
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].
 +
 
 +
There are also several relevant threads on the LKML.
 +
 
 +
=== 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:
 +
 
 +
==== Method 1 - Rollback/change Windows driver ====
 +
 
 +
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).
 +
 
 +
==== Method 2 - Enable WOL in Windows driver ====
 +
 
 +
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.
 +
 
 +
In Windows XP (example)
 +
Right click my computer
 +
--> Hardware tab
 +
  --> Device Manager
 +
    --> Network Adapters
 +
      --> "double click" Realtek ...
 +
        --> Advanced tab
 +
          --> Wake-On-Lan After Shutdown
 +
            --> Enable
 +
 
 +
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{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 ====
 +
 
 +
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).
 +
 
 +
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====
 +
 
 +
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.
 +
<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 ===
 +
 
 +
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
 +
 
 +
==== How to diagnose the problem ====
 +
 
 +
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.
 +
 
 +
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)
 +
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
 +
 
 +
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.
 +
 
 +
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),
 +
 
 +
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki>
 +
            => '/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}}.
 +
 
 +
==== How to fix it ====
 +
 
 +
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.
 +
 
 +
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:
 +
 
 +
DHCPCD_ARGS="-t 30 -h $HOSTNAME"
 +
 
 +
Add the {{ic|-R}} flag to the arguments, e.g.,
 +
 
 +
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"
 +
 
 +
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#For DHCP assigned IP address]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}
 +
 
 +
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.
 +
 
 +
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:
 +
 
 +
nameserver 10.1.1.1
 +
 
 +
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:
 +
 
 +
nameserver 211.29.132.12
 +
nameserver 10.1.1.1
 +
 
 +
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.
 +
 
 +
==== More about it ====
 +
 
 +
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:
 +
 
 +
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.
 +
 
 +
=== 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"
 +
 
 +
substituting 00:19.0 with the address obtained from lspci.
 +
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"
  
=Começando a Configuração=
+
Don't forget to substitute the address again.
  
Agora que sua placa de rede está configurada podemos começar a configurar os dados específicos da Rede, no ARCH as configurações de rede são feitas no arquivo /etc/rc.conf como em alguns sistemas *BSD. O arquivo rc.conf é bem documentado e organizado as configurações ficam na sessão NETWORKING, veja um exemplo deste trecho:
+
{{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.}}
  
#
+
=== PC Pingable by IP but not by hostname? ===
# -----------------------------------------------------------------------
+
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:
# NETWORKING
+
  systemctl enable smbd.service
# -----------------------------------------------------------------------
+
  systemctl enable nmbd.service
#
+
HOSTNAME="meuhost"
+
#
+
# Interfaces to start at boot-up (in this order)
+
# Declare each interface then list in INTERFACES
+
#  - prefix an entry in INTERFACES with a ! to disable it
+
#  - no hyphens in your interface names - Bash doesn't like it
+
#
+
# Note: to use DHCP, set your interface to be "dhcp" (eth0="dhcp")
+
#
+
lo="lo 127.0.0.1"
+
eth0="eth0 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"
+
INTERFACES=(lo eth0)
+
#
+
# Routes to start at boot-up (in this order)
+
# Declare each route then list in ROUTES
+
#  - prefix an entry in ROUTES with a ! to disable it
+
#
+
gateway="default gw 192.168.0.1"
+
ROUTES=(!gateway)
+
#
+
# Enable these network profiles at boot-up.  These are only useful
+
# if you happen to need multiple network configurations (ie, laptop users)
+
#  - set to 'menu' to present a menu during boot-up (dialog package required)
+
  #  - prefix an entry with a ! to disable it
+
  #
+
# Network profiles are found in /etc/network-profiles
+
#
+
#NET_PROFILES=(main)
+
  
== HOSTNAME ==
+
Which makes them run at startup. If you don't want to restart then you can start then right away with:
  HOSTNAME="nome_do_computador"
+
  systemctl start smbd.service
Entre parênteses deve-se digitar o hostname que é o nome do computador dentro da rede.
+
systemctl start nmbd.service
  
== INTERFACES ==
+
And that makes the computer available by name on the network.
INTERFACES=(lo eth0 eth1 ppp0)
+
Entre parênteses coloca-se o nome das interfaces de rede, aqui uma pequena lista de possíveis interfaces:
+
  
*ethX  Interface de Rede Ethernet ou WaveLan
+
=== Broadcom BCM57780 ===
*pppX  Interface de Rede PPP
+
*slipX  Interface de porta serial
+
*plipX  Interface de porta paralela
+
*trX    Tolk Ring
+
  
'''Obs.:''' O "X" representa o número que indentificam sequencialmente as interfaces a primeira interface é identificada com 0 (zero).
+
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.
  
Existe também a interface de loopback, identificada por ''lo'' que permite com que se faça concecções com o próprio computador local, o protocolo TCP/IP reserva o ip 127.0.0.1 para esta interface e o utiliza em várias funções. Esta pode ser usada para realizar testes sem necessariamente estar conectado a uma rede local.
+
These steps should help if your computer has this chipset:
 +
$ lspci | grep Ethernet
 +
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)
  
== Configurando a Interface de Rede ==
+
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):
 +
# modprobe -r tg3
 +
# modprobe broadcom
 +
# modprobe tg3
  
Observe no exemplo, do arquivo rc.conf, a décima quinta e a décima sexta linha nelas são configurados as interfaces de rede seguindo o seguinte padrão:
+
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:
  nome_da_interface="nome_da_interface IP_Local opção1 valor_da_opção1 opção2..."
+
  MODULES=".. broadcom tg3 .."
Existem inúmeras opções veja algumas delas:
+
* '''IP local''' é o numero IP máquina na rede, como se fosse um nome esses números indentificam o computador na rede , coloca-se depois do nome_da_interface que está dentro de aspas
+
eth0="eth0 '''192.168.0.1''' netmask 255.255.255.0 broadcast 192.168.0.255"
+
* '''netmask'''' é o endereço da máscara de rede
+
* '''broadcast'''é o endereço broadcast
+
  
=Referências=
+
Then rebuild the initramfs:
 +
# mkinitcpio -p linux
  
*Linux Networking HOWTO ([http://www.tldp.org/HOWTO/NET3-4-HOWTO.html NET3-4-HOWTO])
+
{{Note|These methods may work for other chipsets, such as BCM57760.}}

Revision as of 17:04, 28 August 2013

Summary help replacing me
A simple guide for setting up and troubleshooting network.
Overview
Template:Networking overview
Related
Jumbo Frames
Firewalls
Wireless Setup

Esta página explica como configurar uma conexão cabeada. Se você deseja configurar uma rede wireless/sem fio veja a páginaConfiguração de Redes Sem Fio.

Contents

Verificando a conexão

Note: Se você receber algum erro como ping: icmp open socket: Operation not permitted quando executar o comando ping, tente reinstalar o pacote iputils.

Muitas vezes, o procedimento básico de instalação cria uma configuração de rede cabeada. Para verificar se há configuração, utilize o seguinte comando:

Note: A opção -c 3 chama 3 vezes a ação de envio de pacotes icmp. Veja man ping para maiores informações.
$ ping -c 3 www.google.com
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms

--- www.l.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms

Caso funcione, você precisará apenas personalizar algumas das opções abaixo.

Se o comando acima reclamar de unknown hosts(host desconhecido), significa que seu computador não pôde resolver nomes de domínios. Pode ser relacionado ao seu provedor de internet ou gateway/roteador. Tente pingar um endereço IP para provar que sua máquina possui acesso a internet.

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

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms
Note: 8.8.8.8 é um endereço ip estático de fácil memorização. É o endereço do DNS primário do Google, considerado uma fonte confiável para testes e geralmente não bloqueado por sistemas de filtro de conteúdo ou proxies.

Caso você consiga pingar este endereço, pode adicioná-lo ao arquivo /etc/resolv.conf com a palavra nameserver na frente como solução de dns.

Configurando um hostname

Um A hostname é um endereço único criado para identificar um computador em uma rede. É configurado no arquivo /etc/hostname. Este arquivo pode conter o domínio do sistema, se houver. Para configurar um hostname, execute:

# hostnamectl set-hostname meunome

Este comando colocará a informação meunome no arquivo /etc/hostname.

Veja man 5 hostname e man 1 hostnamectl para maiores detalhes.


Note:
  • hostnamectl suporta FQDNs
  • Você não precisa mais editar o arquivo /etc/hosts, pois o systemd proverá a resolução de nomes, e é instalado por padrão no sistema.

Para alterar o hostname temporariamente(até o próximo restart), utilize o comando hostname do pacote inetutils:

# hostname meunome

Drivers de dispositivos

Verifique o estado do seu driver

O udev deverá detectar sua interface de rede(NIC) e carregará automaticamente o módulo necessário. Busque pela entrada "Ethernet controller"(ou similar) no resultado do comando lspci -v. Este comando dirá qual módulo do kernel é necessário para o funcionamento do dispositivo. Por exemplo:

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

Após, veja se o driver foi carregado através de um dmesg | grep module_name. Exemplo:

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

Pule para a próxima sessão caso o driver tenha sido carregado com sucesso. Caso contrário, você precisará descobrir qual é o módulo necessário para o seu modelo de interface de rede em específico.

Carregando o driver do dispositivo

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

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

Network Interfaces

Device names

For motherboards that have integrated NICs, it is important to have fixed device name. Many configuration problems are caused by interface name changing.

Udev is responsible for which device gets which name. Systemd v197 introduced Predictable Network Interface Names, which automatically assigns static names to network devices. Interfaces are now prefixed with en (ethernet), wl (WLAN), or ww (WWAN) followed by an automatically generated identifier, creating an entry such as enp0s25.

This behavior may be disabled by adding a symlink:

# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules

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.

Tip: You can run ip link or ls /sys/class/net to list all available interfaces.

Change device name

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

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

A couple things to note:

  • To get the MAC address of each card, use this command: cat /sys/class/net/device-name/address
  • Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.
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.

Set device MTU and queue Length

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

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

Get current device names

Current NIC names can be found via sysfs

$ ls /sys/class/net
lo eth0 eth1 firewire0

Enabling and disabling network interfaces

You can activate or deactivate network interfaces using:

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

To check the result:

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

Configure the IP address

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

Dynamic IP address

Manually run DHCP Client Daemon

Please note that dhcpcd is not dhcpd.

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

And now, ip addr show dev eth0 should show your inet address.

For some people, dhclient (from the dhclient package) works where dhcpcd fails.

Run DHCP at boot

If you simply want to use DHCP for your Ethernet connection, you can use dhcpcd@.service (provided by the dhcpcd package).

To start DHCP for eth0, simply use:

# systemctl start dhcpcd@eth0

You can enable the service to automatically start at boot with:

# systemctl enable dhcpcd@eth0

If the dhcpd service starts before your network card module (FS#30235), manually add your network card to /etc/modules-load.d/*.conf. For example, if your Realtek card needs r8169 to be loaded, create:

/etc/modules-load.d/realtek.conf
r8169
Tip: To find out which modules are used by your network card, use lspci -k.

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 dhcpcd.conf:

/etc/dhcpcd.conf
nohook resolv.conf

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

/etc/dhcpcd.conf
nooption domain_name_servers

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

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

Static IP address

There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.

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.

You need:

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.

Manual assignment

You can assign a static IP address in the console:

# ip addr add <IP address>/<subnet mask> dev <interface>

For example:

# ip addr add 192.168.1.2/24 dev eth0
Note: The subnet mask was specified using CIDR notation.

For more options, see man ip.

Add your gateway like so:

# ip route add default via <default gateway IP address>

For example:

# ip route add default via 192.168.1.1

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

Manual connection at boot using systemd

First create configuration file for the systemd service, replace <interface> with proper interface name:

/etc/conf.d/network@<interface>
address=192.168.0.15
netmask=24
broadcast=192.168.0.255
gateway=192.168.0.1

Create a systemd unit file:

/etc/systemd/system/network@.service
[Unit]
Description=Network connectivity (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network@%i
ExecStart=/usr/bin/ip link set dev %i up
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/usr/bin/ip route add default via ${gateway}

ExecStop=/usr/bin/ip addr flush dev %i
ExecStop=/usr/bin/ip link set dev %i down

[Install]
WantedBy=multi-user.target

Enable the unit and start it, passing the name of the interface:

# systemctl enable network@eth0.service
# systemctl start network@eth0.service

Calculating addresses

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

$ ipcalc -nb 10.66.66.1 -s 1
Address:   10.66.66.1

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

Load configuration

To test your settings either reboot the computer or reload the relevant systemd services:

# systemctl restart dhcpcd@eth0

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

$ ping -c 3 www.google.com

Additional settings

ifplugd for laptops

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

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

Note: Netctl package includes netctl-ifplugd@.service, otherwise you can use ifplugd@.service from ifplugd package. Use for example systemctl enable ifplugd@eth0.service.

Bonding or LAG

See netctl#Bonding.

IP address aliasing

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

Reason: Manual method using ip should be added; then move current example using netctl into netctl. (Discuss in Talk:Network configuration (Português)#)

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

You will need netctl from the Official Repositories.

Prepare the configuration:

/etc/netctl/mynetwork
Connection='ethernet'
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')

Then simply execute:

$ netctl start mynetwork

Change MAC/hardware address

See MAC Address Spoofing.

Internet Share

See Internet Share.

Router Configuration

See Router.

Troubleshooting

Swapping computers on the cable modem

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

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

The TCP window scaling problem

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

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

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

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

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

The resulting connection is at best very slow or broken.

How to diagnose the problem

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

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

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

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

How to fix it (The bad way)

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

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

How to fix it (The good way)

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

net.ipv4.tcp_window_scaling = 0

How to fix it (The best way)

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

More about it

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

There are also several relevant threads on the LKML.

Realtek no link / WOL problem

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

Method 1 - Rollback/change Windows driver

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

Method 2 - Enable WOL in Windows driver

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

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

Method 3 - Newer Realtek Linux driver

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

Method 4 - Enable LAN Boot ROM in BIOS/CMOS

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

DLink G604T/DLink G502T DNS problem

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

How to diagnose the problem

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

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

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

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

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

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

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

How to fix it

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

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

DHCPCD_ARGS="-t 30 -h $HOSTNAME"

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

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

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

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

nameserver 10.1.1.1

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

nameserver 211.29.132.12
nameserver 10.1.1.1

Now restart the network daemon by running systemctl restart dhcpcd@<interface> and do pacman -Syy. If it syncs correctly with the server, then the problem is solved.

More about it

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

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

Check DHCP problem by releasing IP first

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

# dhcpcd -k

Then request a new one:

# dhcpcd

Maybe you had to run those two commands many times.

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 compat-wireless (that has become 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 mailing listand alx pagefor latest working solution for alx.

The driver must be built and installed after every kernel change.

Alternatively you can use the AUR package for 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 compat-drivers-patched from AUR.

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"

substituting 00:19.0 with the address obtained from lspci. 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"

Don't forget to substitute the address again.

Note: This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): Forum discussion. It also appears a fix is on the way. (It will be likely fixed in 3.9.) In the meantime, the above is a suitable workaround.

PC Pingable by IP but not by hostname?

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:

systemctl start smbd.service
systemctl start nmbd.service

And that makes the computer available by name on the network.

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:

$ lspci | grep Ethernet
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)

If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):

# modprobe -r tg3
# modprobe broadcom
# modprobe tg3

Now plug you network cable in. If this solves your problems you can make this permanent by adding broadcom and tg3 (in this order) to the MODULES array in /etc/mkinitcpio.conf:

MODULES=".. broadcom tg3 .."

Then rebuild the initramfs:

# mkinitcpio -p linux
Note: These methods may work for other chipsets, such as BCM57760.