≡ 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

2 comments… add one

Leave a Comment

Next post:

Previous post:

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