Objectivo
A instalação por omissão do Debian configura a rede para obter um endereço dinâmico via DHCP. No entanto, para que o sistema seja configurado como um servidor, deve ter um endereço IP estático.
O objectivo é configurar a interface de rede eth0 com o endereço IP estático 192.168.1.100. Ao mesmo tempo será indicado o endereço do dispositivo acesso à internet, ou "gateway" (192.168.1.1). Numa configuração caseira, este será o endereço estático do router ADSL ou Cabo.
Configuração
A configuração das interfaces de rede é guardada no ficheiro /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# allow-hotplug eth0
# iface eth0 inet dhcp
# Static IP address
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
É necessário também indicar qual o endereço do servidor DNS. Nesta configuração, o servidor DNS funciona no router ADSL, pelo que o parâmetro nameserver deve ter o valor 192.168.1.1, no ficheiro /etc/resolv.conf:
search localdomain
nameserver 192.168.1.1
Reiniciar os serviços de rede:
server:~# /etc/init.d/networking restart
Reconfiguring network interfaces...
done.
Verificação
O comando ifconfig fornece informação detalhada sobre a configuração das interfaces de rede. A configuração da interface eth0 deve exibir agora os parâmetros previamente definidos:
server:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:E4:D1:2D
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee4:d12d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:576 errors:0 dropped:0 overruns:0 frame:0
TX packets:151 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:51002 (49.8 KiB) TX bytes:20083 (19.6 KiB)
Interrupt:177 Base address:0x1400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Deverá ser também possível contactar servidores Internet:
server:~# ping -c3 www.debian.org
PING www.debian.org (194.109.137.218) 56(84) bytes of data.
64 bytes from klecker.debian.org (194.109.137.218): icmp_seq=1 ttl=128 time=67.7 ms
64 bytes from klecker.debian.org (194.109.137.218): icmp_seq=2 ttl=128 time=107 ms
64 bytes from klecker.debian.org (194.109.137.218): icmp_seq=3 ttl=128 time=93.6 ms
--- www.debian.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 67.780/89.547/107.240/16.365 ms
Links relacionados
* Referência Debian , 10.6.1 Configurando uma interface com um endereço IP estático (http://www.debian.org/doc/manuals/reference/ch-gateway.pt-br.html#s-high-static)




















