3

What can an IP address be assigned to?

  • A network interface, which is what I thought originally. (I seem to hear a network interface can have multiple IP addresses assigned to it, and if it is true, it doesn't affect that a IP address can be assigned to a network interface.)
  • nothing, which is what I seem to hear https://unix.stackexchange.com/questions/508007/when-does-an-ip-address-not-need-to-be-assigned-to-a-network-interface where all loopback IP addresses (except 127.0.0.1) can work (be communicated with) without being assigned to network interface(s).
  • A host or network, which is implied by DNS resolution, and also by some sentences from Tanenbaum's Computer Network

    The IP address 0.0.0.0, the lowest address, is used by hosts when they are being booted. It means this network or this host.

    The address consisting of all 1s, or 255.255.255.255—the highest address—is used to mean all hosts on the indicated network.

Must a public IP address be assigned to a network interface?

Must a private IP address (i.e. 10.0.0.0 – 10.255.255.255/8, 172.16.0.0 – 172.31.255.255/12, 192.168.0.0 – 192.168.255.255/16) be assigned to a network interface?

Can a public IP address be assigned to more than one network interface?

Can a private IP address be assigned to more than one network interface?

Thanks.

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
Tim
  • 1,575
  • 17
  • 31

2 Answers2

6

IP addresses are assigned to interfaces, either physical or virtual. For example, for a physical interface, such as a NIC, or a virtual interface, such as a loopback or SVI.

Some people think IP addresses are assigned to hosts, but they are assigned to the interfaces of hosts, and a host can have multiple interfaces, each having an IP address (maybe more than one IP address per interface).

Networks are concepts. They represent a group of IP addresses with the same network as defined by their masked addresses (see this two-part answer for how that works). You do not assign an IP address to a network because there is nothing to which you can assign the address.

Can a public IP address be assigned to more than one network interface?

Can a private IP address be assigned to more than one network interface?

Each interface gets a different IP address. There is nothing in IP to distinguish public or private addresses. To IPv4 they are all the same type of address. The Private addresses are artificial, and it is simply that the ISPs have agreed to not route those address ranges. (IPv6 has no concept of Private addresses.)

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
1

A network interface, which is what I thought originally.

In general IP addresses are normally assigned to interfaces, however precisely what assigning an address to an interface means varies a bit between implementations.

Under the "strong host model", packets sourced from an IP address are only ever sent out that interface and packets are only accepted on an interface if their destination matches the interfaces IP address.

Under the "weak host model", hosts act in a manner more similar to routers. The interface for an outgoing packet is chosen based on the routing table with no regard for source address. Similarly packets can be received on any interface regardless of which of the host's IP addresses they are destined for.

Most unix-like systems are based on the "weak host model", as were pre-vista versions of windows. Current windows apparently follows the "strong host model" by default but can be reconfigured to use the "weak host model".

Even on a router or a host following the weak-host model, the relationship between interfaces and addresses does affect some things.

  • The selection of source IP addresses when the application/transport protocols doesn't specify a particular source address is usually based on the address(es) assigned to the interface the packet is sent from.
  • When an interface goes down the OS usually removes the corresponding IP address(es) from it's list.
  • The address and subnet mask assigned to an interface set the default behaviour for which hosts are assumed to be directly reachable from that interface, and for what the subnet broadcast address is for that interface.

On a router, or a host that follows the weak host model, it is possible to assign addresses to the loopback interfaces. This is mostly done on routers, though it can also be done on servers. The extra address can be advertised in routing protocols, providing an address over which the system can be reached regardless of what interfaces are up.

Peter Green
  • 13,882
  • 2
  • 23
  • 54