How to bind a range of IP’s in Debian / Ubuntu Linux
Q. I’ve recently installed Debian Linux 4.0 on my server and Ubuntu Linux 7.04 on Laptop. I would love to have a multiple IP address that I can use for verity of purposes. I would like to bind 4 IP's to the 'eth0' device or NIC. How do I do that?
A.. Let us assume that your eth0 IP address is 192.168.1.1. You need to create alias or binding using eth0:0, eth0:1...eth0:N devices. You need to add range of IP's in /etc/network/interfaces config file under Debian/Ubuntu Linux. First make a backup of existing file:
# cp /etc/network/interfaces /root/working.interfaces
Now open file using vi text editor:
#vi /etc/network/interfaces
OR
$ sudo vi /etc/network/interfaces
Modify as follows:
auto eth0 auto eth0:0 auto eth0:1 iface eth0 inet static address 192.168.1.1 netmask 255.255.255.248 gateway 192.168.1.254 iface eth0:0 inet static address 192.168.1.2 netmask 255.255.255.248 gateway 192.168.1.254 iface eth0:1 inet static address 192.168.1.3 netmask 255.255.255.248 gateway 192.168.1.254 # add rest of alias / binds below
Save and close the file.
Now restart networking, enter:
# /etc/init.d/networking restart
OR
$ sudo /etc/init.d/networking restart
Updated for accuracy.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Linux / FreeBSD: Multiple IP Addresses on One Interface
- How do I use shell aliases under Linux?
- Linux creating or adding new network alias to a network card (NIC)
- Linux: Find out which network card or NIC server is bind or running on
- Linux vmware VPS server routing problem
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: /etc/network/interfaces, alias, etc network, iface, ip address, network interfaces, Networking, nic, static address, Ubuntu Linux



May 30th, 2007 at 2:56 am
Did you possibly make a type for the 192.168.1.3 assignment?
shows:
iface eth0:0 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.254
should be (?):
iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.254
January 31st, 2008 at 4:09 am
Yes, he meant to type iface eth0:1 instead of iface eth0:0
He typo’d
June 9th, 2008 (5 weeks ago) at 9:38 am
Hi,
Thank you a lot for this very nice howto.
It was very helpful