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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-07-2008, 01:38 AM
|
#1
|
LQ Newbie
Registered: Jan 2007
Posts: 1
Rep:
|
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
|
|
|
01-07-2008, 01:44 AM
|
#2
|
Member
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896
Rep:
|
|
|
1 members found this post helpful.
|
01-07-2008, 02:56 AM
|
#3
|
Member
Registered: Dec 2007
Posts: 59
Rep:
|
With static IP-addresses is just to define them.
With DHCP it's not possible
|
|
|
01-07-2008, 06:08 AM
|
#4
|
Member
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528
Rep:
|
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
|
|
|
01-08-2008, 04:48 AM
|
#5
|
Member
Registered: Oct 2007
Location: Sydney, Australia
Distribution: Debian
Posts: 63
Rep:
|
|
|
|
01-09-2008, 08:14 AM
|
#6
|
Member
Registered: Dec 2007
Posts: 59
Rep:
|
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
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.
|
|
|
01-09-2008, 08:19 AM
|
#7
|
Member
Registered: Dec 2007
Posts: 59
Rep:
|
"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
|
|
|
|
01-09-2008, 08:26 AM
|
#8
|
Member
Registered: Dec 2007
Posts: 59
Rep:
|
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.
|
|
|
01-09-2008, 02:20 PM
|
#9
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
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.
|
|
|
01-09-2008, 02:28 PM
|
#10
|
LQ Sage
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,675
Rep: 
|
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
|
|
|
01-09-2008, 05:25 PM
|
#11
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Quote:
Originally Posted by Emerson
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).
|
|
|
All times are GMT -5. The time now is 11:28 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|