Multiple IP aaddresses on one NIC
Multiple IP aaddresses on one NIC
You told me somewhere(I just can't find that thread anymore) that instead of using two separate NICs I can use only one and then add a new dynamic IP address on it, but here's how my ISP handles the MAC/DHCP/NIC thing.
When you connect to their net, they notice the new MAC address and you get into to some sort of subnet that only allows you to browse to one page where you can set description of the NIC and add it or even remove it or others and only after that you get a "true" internet address.
So my question is, if I use your method these to different IP addresses would have the same MAC address, right?
and if so I don't know what'll happen when trying to add that new IP. I Gotta try this before I decide what to do.
When you connect to their net, they notice the new MAC address and you get into to some sort of subnet that only allows you to browse to one page where you can set description of the NIC and add it or even remove it or others and only after that you get a "true" internet address.
So my question is, if I use your method these to different IP addresses would have the same MAC address, right?
and if so I don't know what'll happen when trying to add that new IP. I Gotta try this before I decide what to do.
I would definitely try it before deciding. :) What I was referring to is "subinterfaces" and yes, each subinterface would have the same MAC address as the physical interface so once your provider approves your MAC address it would have to allow any IP to use that same MAC address. You do have static IP service and not dynamic right?
There is a more difficult way to have multiple IP addresses on one physical interface and that is by using VLAN tagging but in order for that to be possible you have to be plugged into a switch that you can configure VLAN tagging. Using this method you would have logical vlan interfaces on your Linux box, each with their own MAC and IP address. Here is some things I've done using VLAN interfaces:
http://voidmain.is-a-geek.net/forums/vi ... light=vlan
I'm guessing in your situation the best option would be subinterfaces if they will work with your provider. If not you'll probably have to go with multiple interfaces.
You're machine actually has subinterfaces defined by default. You can look at the physical adapter like you already know:
# ifconfig eth0
To look at the first subinterface you would:
# ifconfig eth0:1
Second subinterface:
# ifconfig eth0:2
etc. You can assign them IP addresses just like you assign the physical interace an IP address and you would create an /etc/sysconfig/network-scripts/ifcfg-eth0:1 config file just like the ifcfg-eth0 config file. Just make sure you use DEVICE=eth0:1 instead of DEVICE=eth0 in the new config.
There is a more difficult way to have multiple IP addresses on one physical interface and that is by using VLAN tagging but in order for that to be possible you have to be plugged into a switch that you can configure VLAN tagging. Using this method you would have logical vlan interfaces on your Linux box, each with their own MAC and IP address. Here is some things I've done using VLAN interfaces:
http://voidmain.is-a-geek.net/forums/vi ... light=vlan
I'm guessing in your situation the best option would be subinterfaces if they will work with your provider. If not you'll probably have to go with multiple interfaces.
You're machine actually has subinterfaces defined by default. You can look at the physical adapter like you already know:
# ifconfig eth0
To look at the first subinterface you would:
# ifconfig eth0:1
Second subinterface:
# ifconfig eth0:2
etc. You can assign them IP addresses just like you assign the physical interace an IP address and you would create an /etc/sysconfig/network-scripts/ifcfg-eth0:1 config file just like the ifcfg-eth0 config file. Just make sure you use DEVICE=eth0:1 instead of DEVICE=eth0 in the new config.
I created the ifcfg-erth0:1 file and changed the value on the DEVICE row.
and I can also 'ifup' and it says its online if I try to ifup it again, but it wont show up when do 'ifconfig'.
if I ifconfig eth0:1 then it shows up but with no IP address
and I can also 'ifup' and it says its online if I try to ifup it again, but it wont show up when do 'ifconfig'.
Code: Select all
[root@ftp network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:19:66:05:C8:ED
inet addr:82.196.123.58 Bcast:82.196.123.255 Mask:255.255.254.0
inet6 addr: fe80::219:66ff:fe05:c8ed/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:228985863 errors:75 dropped:4374 overruns:75 frame:0
TX packets:320385580 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3859592165 (3.5 GiB) TX bytes:3289412618 (3.0 GiB)
Interrupt:23 Base address:0x6c00
eth1 Link encap:Ethernet HWaddr 00:0E:0C:D0:B7:2B
inet addr:192.168.67.250 Bcast:192.168.67.255 Mask:255.255.255.0
inet6 addr: fe80::20e:cff:fed0:b72b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:368576134 errors:20525 dropped:0 overruns:0 frame:13633
TX packets:278915247 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1219346592 (1.1 GiB) TX bytes:945489140 (901.6 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:388825 errors:0 dropped:0 overruns:0 frame:0
TX packets:388825 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2166839076 (2.0 GiB) TX bytes:2166839076 (2.0 GiB)
[root@ftp network-scripts]#
if I ifconfig eth0:1 then it shows up but with no IP address
Code: Select all
[root@ftp network-scripts]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:19:66:05:C8:ED
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:23 Base address:0x6c00
ifcfg-eth0:1
result:
and if I the ifup eth0:1 again
Code: Select all
# for the documentation of these parameters.
TYPE=Ethernet
DEVICE=eth0:1
HWADDR=00:10:b5:d1:07:8e
BOOTPROTO=dhcp
ONBOOT=yes
USERCTL=no
PEERDNS=yes
IPV6INIT=no
NM_CONTROLLED=no
Code: Select all
[root@webserver network-scripts]# ifup eth0:1
Determining IP information for eth0:1... done.
[root@webserver network-scripts]#
Code: Select all
[root@webserver network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:10:B5:D1:07:8E
inet addr:82.196.123.215 Bcast:82.196.123.255 Mask:255.255.254.0
inet6 addr: fe80::210:b5ff:fed1:78e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:220390 errors:0 dropped:0 overruns:0 frame:0
TX packets:115858 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15901959 (15.1 MiB) TX bytes:172379742 (164.3 MiB)
Interrupt:11 Base address:0xf00
eth1 Link encap:Ethernet HWaddr 00:04:75:D2:79:2E
inet addr:192.168.67.124 Bcast:192.168.67.255 Mask:255.255.255.0
inet6 addr: fe80::204:75ff:fed2:792e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3947 errors:0 dropped:0 overruns:0 frame:0
TX packets:2663 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:303671 (296.5 KiB) TX bytes:534144 (521.6 KiB)
Interrupt:5 Base address:0x4e80
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:20359 errors:0 dropped:0 overruns:0 frame:0
TX packets:20359 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:165753874 (158.0 MiB) TX bytes:165753874 (158.0 MiB)
[root@webserver network-scripts]#
Code: Select all
[root@webserver network-scripts]# ifup eth0:1
Determining IP information for eth0:1...dhclient(16027) is already running - exiting.
This version of ISC DHCP is based on the release available
on ftp.isc.org. Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.
Please report for this software via the Red Hat Bugzilla site:
http://bugzilla.redhat.com
exiting.
failed.
[root@webserver network-scripts]#
You can't do DHCP on subinterfaces if the base interface is also DHCP. I thought I asked you if you were running static or DHCP and I don't remember if I ever got an answer so I assumed you were static because you were setting up a mail server. Remember that the subinterfaces and the physical interface have the same MAC address? DHCP is based on MAC and would have already assigned a DHCP address for the physical interface if you are using DHCP on that as well. I thought we talked about subinterfaces having to be static before, maybe not.
Having said all that there might be some tricks that you could do with bridges. For example, kvm and VMware create virtual interfaces for each virtual machine and bridge them to the real physical interface of the host. Each virtual interface has it's own MAC address and therefore can get a DHCP address for each virtual interface. I'm not familiar with creating virtual interfaces. Maybe there is a way to create virtual interfaces on the host (no VM) and bridge them to the single physical interface. I'll do a little research on that. If that is possible each virtual interface should be able to have it's own MAC and therefore DHCP on each would be possible.
Having said all that there might be some tricks that you could do with bridges. For example, kvm and VMware create virtual interfaces for each virtual machine and bridge them to the real physical interface of the host. Each virtual interface has it's own MAC address and therefore can get a DHCP address for each virtual interface. I'm not familiar with creating virtual interfaces. Maybe there is a way to create virtual interfaces on the host (no VM) and bridge them to the single physical interface. I'll do a little research on that. If that is possible each virtual interface should be able to have it's own MAC and therefore DHCP on each would be possible.
Last edited by Void Main on Wed Feb 18, 2009 12:59 am, edited 1 time in total.
Well the static IP address is the problem since the mail server is on my own network from my IPS and that is not "truly" a static address, but the IP address won't change as often as lets say ADSL. It might change 1 times a year.
I'll have to read up or ask my ISP if there is a possibility to get a static IP address but if that is for companies only then I can't do it cos it's way to expensive, like $300 per months for a 10mbit line.
I'll have to read up or ask my ISP if there is a possibility to get a static IP address but if that is for companies only then I can't do it cos it's way to expensive, like $300 per months for a 10mbit line.
I think I am onto something that should work using tap interfaces. I am able to create a tap0 and a tap1 interface and bridge them to eth0 via a bridge br0. The tap interface each have their own MAC address so they *should* be able to get their own DHCP addresses. I can assign them all addresses statically and they all work, are pingable from remote, etc. Just not getting DHCP. I have something wrong obviously, I'll probably won't get another chance to mess with it until tomorrow after work.
Although this seems very interesting for future work but as you said I totally forgot that I'm supposed to use the same IP address thus name based for the two websites.
So if you feel like it, sure do show how but you don't have to for this particular case.
So if you feel like it, sure do show how but you don't have to for this particular case.
Last edited by Basher52 on Wed Feb 18, 2009 7:09 am, edited 1 time in total.
You mean "same IP address" right? Name based vhosts all can use the same IP address which is what I thought you were doing. If you wanted to do IP based vhosts and used static IP addresses you could use those subinterfaces. If you needed to use DHCP you have either use multiple physical interfaces or something other than subinterfaces on a single NIC (because of the shared MAC address). So, we're back to you using "name based vhosts" which only require one IP and NIC right? I thought I was losing my mind there for a minute.