LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 12-30-2007, 10:28 PM   #1
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 225

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

thanks

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

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
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, 11:01 PM   #3
mrrangerman
Member
 
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.


Code:
auto eth0
iface eth0 inet static
    address 192.168.1.20
    netmask 255.255.255.0
    broadcast 192.168.1.255
    network 192.168.1.0
    gateway 192.168.1.1


##subinterface

auto eth0:0
iface eth0:0 inet static
    address 192.168.1.21
    netmask 255.255.255.0
    broadcast 192.168.1.255
    network 192.168.1.0
    gateway 192.168.1.1


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.
 
  


Reply


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 01:11 PM
2 IP addresses on the same Linu box Zingaro2002 Linux - Networking 11 02-26-2003 06:49 AM


All times are GMT -5. The time now is 02:32 AM.

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