0

What I am trying to accomplish is extremely close to this, with one twist. I want the second "nic" to be a second ip address (I guess sometimes called a virtual nic), added to the same physical nic (on the same subnet, and able to get to the gateway if I specifically send a packet over this new nic). I know you will probably ask why the h*ll I need to do that, and as you might guess its a long, complicated answer, but the bottom line is I need:

  • Two unique addresses that can get to the internet when I bind to them specifically
  • Those interfaces be on the same subnet for ease of the remainder of the network config

If it helps, the second interface need only "behave" when I bind to it and send packets out of it (or packets specifically arrive to it). That is, I don't need any other routing rules than that.

Now, I tried the most obvious which is to modify the answer above just changing eth1 to eth0:1, however that did not work for me, resulting in RTNETLINK answers: File exists and the virtual nic not actually functioning when I bound to it (for example, with a simple test of wget --bind-address.

I feel like that solution is very close though, it just needs a little something more - please help!

1 Answers1

0

You can also do it this way. This method is better for newer ubuntu systems.

auto eth0 
iface eth0 inet static
    address 192.168.1.50
    netmask 255.255.255.0
    broadcast 192.168.255
    gateway 192.168.1.1
         # the "up" lines are executed verbatim when the interface is brought up
    up ip addr add 192.168.1.2 brd 192.168.1.255 dev eth0 label eth0:0
    up ip addr add 192.168.1.3 brd 192.168.1.255 dev eth0 label eth0:1