2

What happen when I assign 2 IP on one NIC?

e.g. I have one physical NIC (eth0) and I assign on this interface 2 IPs from different network. e.g.

auto eth0
iface eth0 inet static
    address 10.10.0.5
    netmask 255.255.255.0
    gateway 10.10.0.1

auto eth0:0
iface eth1 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    gateway 192.168.0.100

1)Which path will be if I'll send packet from 10.10.05 to 192.168.0.5 ?
2)10.10.0.1 and 192.168.0.100 are they should one physical device?
I would also appreciate a link to article/book which explains this case.

Thank you

user275402
  • 43
  • 1
  • 1
  • 6
  • `1.` The packet will go through `lo` `2.` what? – NickW May 22 '14 at 13:52
  • I don't know what exactly the question is. 1) the path is "internal", it won't take any path. 2) they can be the same physical device, they can be different physical devices. What problem are you trying to solve? – MichelZ May 22 '14 at 13:52
  • 1)Will the package go throw gateway or not? – user275402 May 22 '14 at 14:04

3 Answers3

5

eth0:0 is not same NIC as eth0 it's a virtual interface and can be used as the physical one to route traffic to other destinations.

The concept of creating or configuring multiple IP addresses on a single network interface is called IP aliasing. IP aliasing is very useful for setting up multiple virtual sites on Apache using one single network interface with different IP addresses on a single subnet network.

The main advantage of using this IP aliasing is, you don’t need to have a physical adapter attached to each IP, but instead you can create multiple or many virtual interfaces (aliases) to a single physical card.

10.10.0.1 and 192.168.0.100 are set on different interfaces not both the physical one.

cioby23
  • 166
  • 1
2

When you assign two IP addresses to the same NIC... you will have two IP addresses on the same NIC; nothing more and nothing less. Whether your computer will actually be able to talk to other computers, depends on your network configuration. It's perfectly legal, although often undesirable, to have different IP subnets sharing the same physical network (or VLAN).

1) The computer will recognize both IP addresses belong to it, thus it will handle the traffic internally; nothing will get sent on the network.

2) Not necessarily. There can be another computer (or router) using both IP addresses, or they can be two different devices. In either case, as long as they are connected to the same physical network network (or VLAN) as your NIC, your computer will be able to talk to both of them.

Massimo
  • 70,200
  • 57
  • 200
  • 323
1

Which path will be if I'll send packet from 10.10.05 to 192.168.0.5?

Your IP addresses correspond to a physical address.
You send out from the network card which both of your IP addresses are on.

If you need to know specifically which IP address your computer sends out information from, you can fire up Wireshark and take a look at the packets as they leave your computer.

10.10.0.1 and 192.168.0.100 are they should one physical device?

{"Are they should"} ?

If you mean 'should they be', then it doesn't make any difference.

If you mean 'are they on', then yes.

Vasili Syrakis
  • 4,558
  • 3
  • 22
  • 30