Multiple IP Addresses in Debian

If you have multiple IP addresses assigned to a server and you want to listen to all of them then you can modify the interfaces file rather than using the eth0:0 syntax which is a little more cumbersome.

In this example, we will add a /29 subnet to eth0. Here's a summary of the network information that we will use in our example:

Network 192.168.1.0/29
Gateway IP 192.168.1.1
Usable IPs 192.168.1.2 - .6
Broadcast IP 192.168.1.7
Name Servers 192.168.1.50
192.168.1.51

Now, let edit the interfaces file by typing the following command in Debian:
vi /etc/network/interfaces

Then, edit the eth0 section of the file to look like the following:
auto eth0
iface eth0 inet static

# Add first IP along with network information
address 192.168.1.2
netmask 255.255.255.248
network 192.168.1.0
broadcast 192.168.1.7
gateway 192.168.1.1

# Consider adding DNS here but it could be added to resolv.conf instead
dns-nameservers 192.168.1.50 192.168.1.51

# Extra Remaining IPs .3 - .6
post-up for last in `seq 3 6`; do ip addr add 192.168.1.$last/32 dev $IFACE; done || true
pre-down for ip in `ip addr show dev $IFACE | sed -n 's@.* inet \([0-9.]*/32\) .*@\1@ p'`; do ip addr del $ip dev $IFACE; done || true

After completion, reboot the server and then check to see if the IPs are working by using Ping or some other method. They will not show up in ifconfig as they would if you used the eth0:0 method.

NOTE: You can ignore class boundaries using this method as long as the netmask encompasses the IP space that you are adding.
  • 35 Users Found This Useful
Was this answer helpful?

Related Articles

Change Time Zone in CentOS

Changing the time zone on a CentOS server is fairly easy.   First, you'll need to know your...

Change Time Zone in CentOS

Changing the time zone on a CentOS server is fairly easy.   First, you'll need to know your...

Configure Speed and Duplex in CentOS

If you have a colocated CentOS server with CeraNet then you may need to modify the speed and...

Configure Speed and Duplex in CentOS

If you have a colocated CentOS server with CeraNet then you may need to modify the speed and...

Configure Speed and Duplex in Ubuntu

If you have a colocated Ubuntu server with CeraNet then you may need to modify the speed and...