How To Add Multiple IP Addresses On Linux / Fedora Core / Fedora
Most guide to adding multiple IP addresses on Linux starts with the Microsoft-like solution of using ifconfig. While the solution is correct it doesn't survive a reboot or even a network restart. Here's how you can easily and permanently add multiple IP addresses to the same (or different) network interface on your Linux machine. I just successfully configured dozens of IP addresses on our new dedicated server using this method. First I will explain how you can add using the Fedora user interface and then from the Linux command line.
How to set multiple IP addresses using the Fedora user interface
Linux supports multiple IP adresses on the same network interface. Adding multiple IP addresses from the user interface in Fedora is simple.
1. Select menu item System->Administration->Network.
2. Click on New to add a new IP address
3. Select Ethernet connection
4. Select the Ethernet card (in my case it is Intel Corp 82566DC Gigabit Network Connection)
5. Specify your chosen IP address
6. Specify subnet mask (if in doubt use 255.255.255.0; better yet ask your system admin)
7. Specify your gateway, if you have one configured
8. Click Next and then click on Apply.
Repeat the procedure for all your IP addresses.
Restart the network:
/sbin/service network restart
You are done!
How to set multiple IP addresses using Linux command line
Go to /etc/sysconfig/network-scripts
Make multiple copies of ifcfg-eth0 and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.
Open each of them and at least change the IPADDR to your chosen IP address and the NETMASK to the subnet mask for that IP address.
A sample entry would look like this:
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=34.123.111.21
NETMASK=255.255.255.0
ONBOOT=yes
Restart the network:
/sbin/service network restart
You are done!
Filed under Fedora 7, Fedora Core 6, Headline News, How To, Linux, Linux Migration, Web, Web Hosting, Web Services |
|
RSS 2.0 |
Trackback this Article
|
Email this Article
You may also like to read |





































November 14th, 2007 at 8:42 am
Don’t forget to add the :0, :1, etc as in the filename to the DEVICE= lines in each file!
April 18th, 2008 at 10:29 am
Hi,
I have a problem setting up multiple IP addresses under Fedora 8: I can configure the addresses fine as detailed on this website, and I can ping them no trouble. The problem is when I come to actually use them with a client-server program I am developing:
The server program opens up a socket and binds it to one of the addresses, but when it tries to bind a second socket to one of the other address, I get the error “Address in use” - so it seems that I can’t actually set up concurrent servers on the different addresses.
Further, when the client program tries to connect with the one open server socket, it will quite happily connect with the server irrespective of the address used by the server, so long as it is connecting to one of those I have configured, or is the primary address.
I hope I have explained this clearly enough …
I am programming in C.
Cheers,
Keith Moore
April 18th, 2008 at 11:19 am
OK, panic over, found the problem - I was still binding with INADDR_ANY instead of the specific address, which had the dual effect of taking up all the IP addresses, and accepting incoming connections on all of them!
D’oh!
April 21st, 2008 at 10:47 am
Cool guide, but I need multi DNS (already know about the ip addresses tips)
thanks anyway
August 4th, 2008 at 9:50 pm
Do you have the script that does it automatically? I mean an sh file?