Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-30-2007, 09:28 PM   #1
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 229

Rep: Reputation: 16
Linux box with two ip addresses...

I have an ubuntu box with only one network interface, and is it possible to setup two ip to one network interface?, I want the box to act as a router/server


Last edited by Tinkster; 03-27-2008 at 09:42 PM. Reason: shameless plug removed
Old 12-30-2007, 09:43 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Yes, one network card can have multiple IP addresses -- they can be specified by the device name, followed by a colon, followed by a number ,e.g. eth0:1, eth0:2, etc.

I'm not sure how you'd make a router with only one NIC, though, as you have to connect physically to two different networks.
Old 12-30-2007, 10:01 PM   #3
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 50
What you are wanting to setup is a sub-interface, you want to edit your /etc/network/interfaces. Lets say your interface setup looks something like this.

auto eth0
iface eth0 inet static


auto eth0:0
iface eth0:0 inet static

The subinterface would or could look like this. Note: this is for a static subinterface, you could make it DHCP if you wanted. Notice the first line, there is no rule that says you have to set it up as eth0:0 you could have it eth0:1 or 2, but I think it is easier to start the sub with a 0.

Also the subs IP address can not be already in use.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add / bind ip addresses to one box on slackware ? Mouse_103 Linux - Newbie 3 03-30-2003 12:11 PM
2 IP addresses on the same Linu box Zingaro2002 Linux - Networking 11 02-26-2003 05:49 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration