Jump to content

  •  

Photo
- - - - -

How to set Multiple Static IPs on Debian and Ubuntu

Debian 7 Ubuntu Server 14.04

  • Please log in to reply
No replies to this topic

#1 Wilson18

Wilson18

    Administrator

  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 07 June 2014 - 08:12 PM

In this tutorial, I will be showing you how you can set up multiple static ips on a debian installation. I will be doing this by modifying the network interfaces file. To open this file, type

nano /etc/network/interfaces

The file should look like this

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).


# The loopback network interface
auto lo
iface lo inet loopback

At the bottom of this, we will need to add our ethernet interface so we can set a static IP for it. This should be eth0 however this could be different with other network interfaces. We can see an example of these settings below.

auto eth0
iface eth0 inet static
        address 192.168.1.41
        netmask 255.255.255.0
        gateway 192.168.1.1

To assign multiple, we will need to create virtual network adapters for each IP which can be seen below.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        address 192.168.1.41
        netmask 255.255.255.0
        gateway 192.168.1.1
#Add extra ips to virtual network adapters
auto eth0:0   #the :0 would change depending on how many adapters you would add.
iface eth0:0 inet static
        address 10.0.0.41
        netmask 255.0.0.0
For each additional IP you would like to add, you just include another few lines like below but making sure to increment the number after the ':' and to assign different IPs which are unused. 
auto eth0:1 
iface eth0:1 inet static
        address 10.0.1.41
        netmask 255.0.0.0

After we have done this, we can then restart the networking service like so

service networking restart

We can then use the ifconfig command to see our network adapters and their settings.

ifconfig

which should return something that looks like this

ifconfig.PNG

If this doesn't work, you may still have the Network Manager program running which is stopping you from managing your network. View This Tutorial for How to Disable Network Manager from Starting in Debian

Once you have done this, you should reboot just to be safe!

 

If you are following this after running a DHCP configuration, you should probably follow this guide to find out How to set which DNS / Nameservers to use on Debian

 


List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+






Also tagged with one or more of these keywords: Debian 7, Ubuntu Server 14.04