# One nic, several ip addresses

## tholin

I want to be able to get several IP addresses assigned to the same NIC with DHCP.

The reason is:

I have 100MBit download and 10MBit upload on my ISP but I've discovered that the upload cap is per IP address. I can start Virtualbox in the bridged adapter network mode and upload at 10MBit in the virtual machine while uploading at 10MBit outside the virtual machine because the host and VM gets their own ip addresses.

There must be some way of doing this without using a virtual machine but I haven't been able to figure it out.

I have tried:

to use alias to get a virtual eth0:0 device but I could not get a DHCP addresses on the eth0:0 device. It use the same mac address as the real eth0 and can't get a new IP because of that. 

I have also tried to use something called VLAN to create a eth0.5 virtual device. I could change the mac adress on the virtual device but I still could not get a DHCP lease. The VLAN never activated promiscuous mode on the NIC so the NIC could never receive packages with other MAC adresses. Virtualbox always activate promiscuous mode when the bridge adapter is used.

Now I have run out of options. There must be some way of doing this without using Virtualbox but I can't figure it out.

----------

## UberLord

You can use eth0:0 and eth0:1 by giving each one a different ClientID on the DHCP command.

----------

## tholin

 *UberLord wrote:*   

> You can use eth0:0 and eth0:1 by giving each one a different ClientID on the DHCP command.

 Hm... Can't get it to work.

I googled and found this

 *Quote:*   

> To get the alias interface (eth0:0) up using dhcp I then ran the following command
> 
> ginga:~# dhcpcd-bin -I 01:00:1e:4f:ab:26:94 eth0:0
> 
> err, eth0:0: SO_SOBINDTODEVICE: No such device
> ...

 

So I tried the same thing

```
multivac ~ # ifconfig

eth1      Link encap:Ethernet  HWaddr 00:15:f2:11:07:74

          inet addr:XXX.228.197.172  Bcast:XXX.228.207.255  Mask:255.255.240.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:26004 errors:0 dropped:0 overruns:0 frame:0

          TX packets:9978 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:9784437 (9.3 MiB)  TX bytes:1367312 (1.3 MiB)

          Interrupt:21

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:549 errors:0 dropped:0 overruns:0 frame:0

          TX packets:549 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:46580 (45.4 KiB)  TX bytes:46580 (45.4 KiB)

multivac ~ # dhcpcd -d -d -I 01:00:15:f2:11:07:75 eth1:0

eth1:0: dhcpcd 4.0.7 starting

eth1:0: hardware address = 00:15:f2:11:07:74

eth1:0: executing `/lib/dhcpcd/dhcpcd-run-hooks', reason PREINIT

eth1:0: open_udp_socket: No such device

eth1:0: broadcasting for a lease

eth1:0: sending DHCP_DISCOVER with xid 0x7f4778fc, next in 3.42 seconds

eth1:0: offered XXX.228.197.172 from XXX.228.192.1

eth1:0: checking XXX.228.197.172 is available on attached networks

eth1:0: sending ARP probe (1 of 3), next in 1.30 seconds

eth1:0: sending ARP probe (2 of 3), next in 1.35 seconds

eth1:0: sending ARP probe (3 of 3), next in 2.00 seconds

eth1:0: sending DHCP_REQUEST with xid 0x7f4778fc, next in 3.20 seconds

eth1:0: acknowledged XXX.228.197.172 from XXX.228.192.1

eth1:0: leased XXX.228.197.172 for 3600 seconds

eth1:0: adding IP address XXX.228.197.172/20

eth1:0: adding route to 0.0.0.0/0 via XXX.228.192.1

eth1:0: executing `/lib/dhcpcd/dhcpcd-run-hooks', reason BOUND

eth1:0: sending ARP announce (1 of 2), next in 2.00 seconds

eth1:0: sending ARP announce (2 of 2)

eth1:0: renew in 1797 seconds

^Ceth1:0: received SIGINT, stopping

eth1:0: deleting IP address XXX.228.197.172/20

eth1:0: executing `/lib/dhcpcd/dhcpcd-run-hooks', reason STOP

multivac ~ # dhcpcd -d -d -I 00:15:f2:11:07:75 eth1:0

eth1:0: dhcpcd 4.0.7 starting

eth1:0: hardware address = 00:15:f2:11:07:74

eth1:0: executing `/lib/dhcpcd/dhcpcd-run-hooks', reason PREINIT

eth1:0: open_udp_socket: No such device

eth1:0: broadcasting for a lease

eth1:0: sending DHCP_DISCOVER with xid 0x1ec09d59, next in 3.16 seconds

eth1:0: offered XXX.228.197.172 from XXX.228.192.1

eth1:0: checking XXX.228.197.172 is available on attached networks

eth1:0: sending ARP probe (1 of 3), next in 1.70 seconds

eth1:0: sending ARP probe (2 of 3), next in 1.82 seconds

eth1:0: sending ARP probe (3 of 3), next in 2.00 seconds

eth1:0: sending DHCP_REQUEST with xid 0x1ec09d59, next in 4.11 seconds

eth1:0: acknowledged XXX.228.197.172 from XXX.228.192.1

eth1:0: leased XXX.228.197.172 for 3600 seconds

eth1:0: adding IP address XXX.228.197.172/20

eth1:0: adding route to 0.0.0.0/0 via XXX.228.192.1

eth1:0: executing `/lib/dhcpcd/dhcpcd-run-hooks', reason BOUND

eth1:0: sending ARP announce (1 of 2), next in 2.00 seconds

eth1:0: sending ARP announce (2 of 2)

eth1:0: renew in 1797 seconds

```

I got the same IP address all the time. I also tried to play around with the --hostname and --vendorclassid of dhcpcd but it made no difference.

----------

## Anarcho

Just an idea, I'm not sure if it works, but you could try the following:

1. Create a bridge with your physical IF in it (just like virtual box would do it)

2. Create Dummy Interfaces and add these to your bridge and configure the MAC addresses of these dummy interfaces

----------

## py-ro

Even if you get it working, this alone would not help you. You must also manipulate your outgoing IP and Ididn't know if this is possible. Normaly only the first IP suitable for Routing will be used.

Py

----------

## tholin

 *Anarcho wrote:*   

> Just an idea, I'm not sure if it works, but you could try the following:
> 
> 1. Create a bridge with your physical IF in it (just like virtual box would do it)
> 
> 2. Create Dummy Interfaces and add these to your bridge and configure the MAC addresses of these dummy interfaces

 

I've been trying to get this to work but I'm not really sure how the bridge stuff work. I have found some posts with people who try to do the same thing but no real guide or anything like that.

The linux foundation got a page about bridging with a few steps for setting up bridging between two nics. They also write "In order to act a a bridge, the network device must be placed into promiscuous mode which means it receives all traffic on a network" but they never include information about this in the guide. Is the bridge util suppose to activate promiscuous mode or me?

The commands I tried was something like this

```
ifconfig eth1 promisc

ifconfig eth1 0.0.0.0

ifconfig dummy0 0.0.0.0

brctl addbr mybridge

brctl addif mybridge eth1

brctl addif mybridge dummy0

brctl setfd mybridge 0

ifconfig mybridge up

dhcpcd -d mybridge  <-- Works

dhcpcd -d dummy0  <-- Fails to get a DHCP reply

```

Is this what you had in mind? I tried to set the mac adress of the dummy to something close to my real nic but it didn't help.

While googling I found this page http://kerneltrap.org/node/6523

I'm not sure I he ever got it to work but he seems to have the same problem as me.

"I am unable to settle for just IP aliasing because the IP addresses are to be assigned by a DHCP server. And some DHCP servers don't want to assign two different IP addresses to a NIC with one MAC address (even if I request for two IP addresses with different client IDs)"

----------

## Anarcho

I'm sorry, but from what I've read so far it seems that this will not work.

Now I think your only option will be something like KVM, XEN, UML, etc.

----------

## UberLord

 *tholin wrote:*   

> I got the same IP address all the time. I also tried to play around with the --hostname and --vendorclassid of dhcpcd but it made no difference.

 

That is probably because the DHCP server you're using has your MAC address hardcoded and as such ignores the clientid.

At least, my version of ISC DHCPD does this. When I remove the MAC hardcoding, the two dhcpcd instances get different addresses.

----------

## tholin

 *py-ro wrote:*   

> Even if you get it working, this alone would not help you. You must also manipulate your outgoing IP and Ididn't know if this is possible. Normaly only the first IP suitable for Routing will be used.
> 
> 

 

Seems like you are right. I connected a cable to the other onbord nic called eth0 in my box. It got an IP without any problems but getting anything to use that IP was not so easy.

I believed that using the "bind to interface" feature in my bittorrent client would make it use that interface but that was not so. All packages go out through eth1 because it's the first in the routing table. The only thing "bind to interface" changed was which interface peers respond back to.

Seems like programs can't decide for themselves which interface to use and I can't force the kernel to assign one program to one interface like I want.

 *UberLord wrote:*   

> That is probably because the DHCP server you're using has your MAC address hardcoded and as such ignores the clientid. 
> 
> At least, my version of ISC DHCPD does this. When I remove the MAC hardcoding, the two dhcpcd instances get different addresses.

 

The DHCP server belongs to my ISP and I can't change it.

----------

