LinuxQuestions.org
Help answer threads with 0 replies.
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 01-07-2008, 01:38 AM   #1
arvind_77_99
LQ Newbie
 
Registered: Jan 2007
Posts: 1

Rep: Reputation: 0
how to assign two IPs on same NIC


I am using Fedora Core7. Can Anybody help me to assign two IP addresses on same NIC.

Arvind
 
Old 01-07-2008, 01:44 AM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
Behold the power of GOOGLE!
http://technodigits.wordpress.com/20...card-in-linux/
 
1 members found this post helpful.
Old 01-07-2008, 02:56 AM   #3
uffe2
Member
 
Registered: Dec 2007
Posts: 59

Rep: Reputation: 15
With static IP-addresses is just to define them.
With DHCP it's not possible
 
Old 01-07-2008, 06:08 AM   #4
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
Quote:
uffe2
With static IP-addresses is just to define them.
With DHCP it's not possible
Um that's not true, if he wants he could have both DHCP. Or he could have his first interface DHCP and the sub-interface static. I think it would be better to have static, as DHCP can change, but as a rule once an IP address has been issued DHCP will issue that same address the next time to the same interface/sub-interface.


Quote:
arvind_77_99

I am using Fedora Core7. Can Anybody help me to assign two IP addresses on same NIC.
Edit the file that Fedora places the interface info in, in Debian it's located in /etc/networking/interfaces.

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

## Sub-netinterface added

auto eth0:0
iface eth0:0 inet static
    address 192.168.1.21   <--- can not be the same as any other IP
    netmask 255.255.255.0
    broadcast 192.168.1.255
    network 192.168.1.0
    gateway 192.168.1.1
EDIT: uffe2
Well I had some time when I got home from work to check out if you could have DHCP on both for sure, it seems we were both half right. I couldn't get DHCP to work on both the primary and sub-interface at the same time, but I had no problem having DHCP on the primary interface and static on the sub-interface.
I was going by some linux lessons I have, and the instructor said it could be done. If it can, I wasn't able to get it to work.

Last edited by mrrangerman; 01-07-2008 at 03:32 PM. Reason: info
 
Old 01-08-2008, 04:48 AM   #5
LlNUX
Member
 
Registered: Oct 2007
Location: Sydney, Australia
Distribution: Debian
Posts: 63

Rep: Reputation: 15
http://blog.linuxconfig.org/configur...sses-on-linux/
 
Old 01-09-2008, 08:14 AM   #6
uffe2
Member
 
Registered: Dec 2007
Posts: 59

Rep: Reputation: 15
Subnet interface ? What's that ?
Is each "subnet interface" defined with there own unique MAC address ?
If "YES" then: How do you configure the MAC address for the second MAC address for subnet interface 2 ?

If "NOT", the DHCP server can't delivery more than one IP-address to each MAC-address (on the DHCP client discovery request from the host) ?
If each subnet interface has one unique MAC address, the DHCP server see each MAC address as different host's !



Quote:
Originally Posted by mrrangerman View Post
Um that's not true, if he wants he could have both DHCP. Or he could have his first interface DHCP and the sub-interface static. I think it would be better to have static, as DHCP can change, but as a rule once an IP address has been issued DHCP will issue that same address the next time to the same interface/sub-interface.



Edit the file that Fedora places the interface info in, in Debian it's located in /etc/networking/interfaces.

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

## Sub-netinterface added

auto eth0:0
iface eth0:0 inet static
    address 192.168.1.21   <--- can not be the same as any other IP
    netmask 255.255.255.0
    broadcast 192.168.1.255
    network 192.168.1.0
    gateway 192.168.1.1
EDIT: uffe2
Well I had some time when I got home from work to check out if you could have DHCP on both for sure, it seems we were both half right. I couldn't get DHCP to work on both the primary and sub-interface at the same time, but I had no problem having DHCP on the primary interface and static on the sub-interface.
I was going by some linux lessons I have, and the instructor said it could be done. If it can, I wasn't able to get it to work.

Last edited by uffe2; 01-09-2008 at 08:15 AM.
 
Old 01-09-2008, 08:19 AM   #7
uffe2
Member
 
Registered: Dec 2007
Posts: 59

Rep: Reputation: 15
"Virtual IP-address" ?! ...there is a lot of strange definitions....

It's only to define more than one IP-addresses per physical interface.
But, still all IP-addresses are using the same MAC address
on one physical Ethernet interface.



Quote:
Originally Posted by LlNUX View Post
 
Old 01-09-2008, 08:26 AM   #8
uffe2
Member
 
Registered: Dec 2007
Posts: 59

Rep: Reputation: 15
I belive "Virtual IP-address" and subnet interface is the same !
Then each physical Ethernet interface has only one MAC address, then it's possible to only use one ( and only one) IP-address with DHCP per phsical Ethernet interface.

But, maybe someone could write a new NIC-driver and emulate several virtual NIC cards by using serveral MAC addresses per physical Ethernet interface.
If the operating system detect several NIC card, it also support one IP-address per virtual interface used with DHCP.
 
Old 01-09-2008, 02:20 PM   #9
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 79
Perhaps I can clear some things up. The process described in the two articles above (which one article calls “Virtual IP-addresses”) is more correctly known as ip aliasing. Using this method, you may add multiple aliases to a network device. All alias devices (whose names consist of the base device, followed by a colon and the alias number) share the same MAC as the base device and all such interfaces will come down (and be deleted) when the base device is brought down.

If you want to have one physical network device with multiple MAC addresses (each of which in turn may have its own IP address and zero or more aliases), you may use something called VLAN Tagging (described in the IEEE802.1Q standards document). To do this on linux, you’ll need the 8021q module loaded (unless it’s compiled into the kernel). Once you create a VLAN tag (with the userspace utility vconfig), you can change its link address the same way you change the link address of a normal interface. In fact, you can even bring the interfaces up and down independently of each other. You should be careful that the new MAC does not conflict with any other MAC addresses in your network.

Here is an example of using 802.1Q tagging to get multiple MAC addresses (as well as IP addresses) on a single device.

Once you have separate MAC addresses, you should be able to use DHCP to configure both each tag separately.
 
Old 01-09-2008, 02:28 PM   #10
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,675

Rep: Reputation: Disabled
Code:
mate ~ # ifconfig eth0:0 hw ether 00:00:00:00:00:01
mate ~ # ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
          inet addr:192.168.2.56  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 
Old 01-09-2008, 05:25 PM   #11
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 79
Quote:
Originally Posted by Emerson View Post
Code:
mate ~ # ifconfig eth0:0 hw ether 00:00:00:00:00:01
mate ~ # ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
          inet addr:192.168.2.56  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
Yes, this works fine except that the base device has had its HWaddr altered as well. I believe the point was to alter the alias but leave the base device alone. AFAIK, this is not possible with aliases. It is possible with VLAN tags, which is what I talked about in my previous post (I even provided a hyperlink to a post detailing just that).

For example (using ifconfig):
Code:
# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
          inet addr:192.168.2.55  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
# vconfig add eth0 1
# ifconfig eth0.1 192.168.2.56
# ifconfig eth0.1 hw ether 00:00:00:00:00:02
# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
          inet addr:192.168.2.55  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
eth0.1    Link encap:Ethernet  HWaddr 00:00:00:00:00:02  
          inet addr:192.168.2.56  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
Note that it is always imperative to change the IP address prior to changing the MAC address (unless the VLAN tagged device is brought down). Otherwise, you have a race condition with two differing MAC devices sharing an IP (which should never be allowed to happen).
 
  


Reply

Tags
assign, how, ifconfig, ips


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
Assign different folders/users to different IPs on the same dedicated server yuye811 Linux - Server 2 12-17-2007 12:13 PM
Redhat 7 what file is being used to assign my multiple IPs? TooSlow Linux - Networking 3 10-24-2007 11:35 AM
2 IPs on 1 NIC mephitic Linux - Networking 6 07-19-2004 02:39 PM
dhcp does not assign IP to nic WurM Linux - Networking 5 02-25-2004 01:36 PM
how to assign 2 IPs to a computer dragon Linux - Networking 6 11-05-2002 08:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:28 PM.

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
Open Source Consulting | Domain Registration