Configurar IP do Linux

A configuração das interfaces de rede é guardada no ficheiro /etc/network/interfaces: /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 modem/router ADSL ou cabo, pelo que o parâmetro nameserver deve ter o valor 192.168.1.1, no ficheiro /etc/resolv.conf: /etc/resolv.conf

domain localdomain
search localdomain
nameserver 192.168.1.1

Reiniciar a interface de rede para activar a nova configuração:

root@server:~# ifdown eth0
root@server:~# ifup eth0

Deixe um comentário