To configure a network interface to use DHCP:
auto eth0
iface eth0 inet dhcp
dns-nameservers 192.168.1.254
Or on Etch with hotplug:
allow-hotplug eth0 iface eth0 inet dhcp
To statically configure a network interface:
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
broadcast 192.168.1.255
dns-nameservers 192.168.1.254
Then if you have previously used DHCP then until you reboot dhclient will still be running and so you should kill it:
ps ax | grep dhclient kill -9 12345
Configure the IP alias in /etc/network/interfaces as shown below:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# Automatically bring up the following interfaces
auto lo eth0 eth0:0
# The loopback network interface
iface lo inet loopback
# The primary network interface
# allow-hotplug eth0
# iface eth0 inet dhcp
# Primary interface
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
broadcast 192.168.1.255
dns-nameservers 192.168.1.254
# Alias
iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.0
To remove an IP alias:
ifdown --force eth0:0 ip link set eth0:0 down
Subscribe to the RSS feed for Andy's Debian HOWTOs
Article from Andy's Debian HOWTOs (http://www.besy.co.uk/debian/debian)
Discussion