≡ Menu

How to set multiple IPs on Debian

Setting multiple IPs on Linux or in this case Debian is rather straight forward… All the network info is stored in the file /etc/network/interfaces and you just need to add the info to the file…

Before making changes to this file, I recommend you check your values at least 3 times! If you have made a mistake and trying to do it from a remote location, YOU WILL LOCK YOURSELF OUT!

This is a sample configuration with device eth0 having the IP address of 192.168.1.2 on a Class C Network with 192.168.1.1 as the default gateway.

/etc/network/interfaces:

# /etc/network/interfaces – configuration file for ifup(8), ifdown(8)

# the loopback interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

address 192.168.1.2
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

In order to add multiple IPs to the same interface, In this case eth0 You need to add it in the following method…

auto eth0:0
iface eth0:0 inet static

address 192.168.1.3
netmask 255.255.255.0
broadcast 192.168.1.255

auto eth0:1
iface eth0:1 inet static

address 192.168.1.4
netmask 255.255.255.0
broadcast 192.168.1.255

auto eth0:2
iface eth0:2 inet static

address 192.168.1.5
netmask 255.255.255.0
broadcast 192.168.1.255

Thats it, after you have made all the necessary changes, you need to restart the networking by issueing the following command…

# /etc/init.d/networking restart

Comments on this entry are closed.

  • Ryan Hill

    How would the configuration differ if the IPs used were not on the same class C subnet? For example, if I were adding 192.168.1.1 for eth0 & wanted 10.0.0.1 on eth0:0?

  • Hey Nish good info I wish Debian had a better way of doing this it is a pain that it doesn’t automatically start all IPs on the same device (eg. eth0)!

    Cheers

    Areeb

Next post:

Previous post:

Copyright © Nish Vamadevan 2002-2017. All Rights Reserved. Terms and Policies.