What happen when I assign 2 IP on one NIC?

12,326

Solution 1

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.

Solution 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.

Share:
12,326

Related videos on Youtube

user275402
Author by

user275402

Updated on September 18, 2022

Comments

  • user275402
    user275402 over 1 year

    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

    • NickW
      NickW almost 10 years
      1. The packet will go through lo 2. what?
    • MichelZ
      MichelZ almost 10 years
      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?
    • user275402
      user275402 almost 10 years
      1)Will the package go throw gateway or not?