Add two ips to one NIC in ubuntu

edit file: /etc/network/interfaces

the original content should be something like:

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
    
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.1

add the following settings in the file:

auto eth0:1
iface eth0:1 inet static
address 192.168.0.6
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.1

run command in root mode:

/etc/init.d/networking restart

that’s all. you can run ifconfig to check if it works.

I had tested it under ubuntu 6.10.

Leave a Reply

Your email address will not be published.