Are network cards and IP addresses a one-one map?
-
1Easy example: IPv6 will often have a link-local and a global scope address. – Steve-o Sep 16 '11 at 15:43
-
Also, all network cards obviously listen on both the external-ip and also 127.1 – djangofan Sep 16 '11 at 22:26
-
8@djangofan, you'd be hardpressed to find an OS where the 127/8 range makes it to any level of hardware or driver. They all recognize that address internally, some assign it to a virtual loopback device. – Chris S Sep 16 '11 at 23:57
7 Answers
Yes, you can have multiple; they are not one to one.
A single network card can do this in a couple of ways; it can answer for multiple IP addresses with a single MAC address (assigning multiple addresses to a NIC in most operating systems will do this), or with multiple MAC addresses (virtualization platforms behave in this way).
- 112,982
- 12
- 174
- 248
-
-
-
-
Other OS? Are you multibooting and want this on more than one OS? – Bart Silverstrim Sep 16 '11 at 15:30
-
@kernel, normally this is called ip aliasing, and how you set it up is dependent upon your Operating system.. – Doon Sep 16 '11 at 15:31
-
I mean one solution for linux should be easily adapted to other OS if necessary. – kernel Sep 16 '11 at 15:31
-
@kernel depends upon which vendors version of linux, how they setup the scripts. normally it is sconfigured same way as primary, but just use eth0:0 or eth0:1 – Doon Sep 16 '11 at 15:32
-
4@kernel - the mechanics of network configuration and "other OS" are completely different. – EEAA Sep 16 '11 at 15:38
-
What I really mean is: once I know one,I should have enough clue to find the configuration for other OS by google or what ever.. – kernel Sep 16 '11 at 15:39
-
4@kernel. Yes. Google: ip alias {insert OS here} should tell you all you need to know. . – Doon Sep 16 '11 at 15:51
A single physical network card definitely can have multiple IP addresses. This is almost essential when implementing server virtualization: with multiple virtual servers running on the same physical hardware, each needs its own IP address.
- 14,149
- 3
- 52
- 95
Not only is this possible, it is very common. A network card may have multiple IP addresses. This is a concept called multihoming. There are other variants of multihoming as well.
- 6,413
- 1
- 41
- 63
-
3I believe the answer is wrong. In the host multihoming, a single host gets multiple IP addresses but OP wants to know of a single NIC getting multiple IP addresses. It's a subtle difference. – 7_R3X Mar 26 '18 at 11:12
On linux, the command is ip addr add IFADDR dev STRING
, where IFADDR and STRING are replaced by the IP address and device name. You can see some examples in the Guide to IP Layer NEtwork Administration with Linux. You'll also want to specify your routes that use that IP address using ip route
. Again, the guide comes through.
Even though the syntax of the ip
commands makes it seem that you are associating the IP address with a specific network card, linux considers the IP address as belonging to the overall system. Thus in some circumstances you may want to twiddle with ARP settings.
- 12,493
- 2
- 30
- 49
Yes you can have more than one IP address when using a single Network Card.
Setting this up is different in each Operating System, but may involve creating a new Network Interface. This can look like a unique connection but will be using the same Network Card behind the scenes. OS X and Linux use this method.
To add a new IP address in Windows open up the network connection you wish to add another IP address to. Go to Properties –> Internet Protocol (TCP/IP) –> Advanced –> In IP settings, click add and add the new IP address and netmask.
This can be used to expose a server in two network ranges. For example one network range may be used for secure traffic which the other network range cannot access. Firewall rules could be different for each Network Interface.
- 171
- 2
-
1Linux is the only OS I know of that makes you setup a subinterface. Windows and the BSDs do not. – Chris S Sep 16 '11 at 20:57
-
Thanks for the information, I've updated the answer to be more accurate. – Thomas Coats Sep 16 '11 at 21:09
IP layer (the ip address) is completely independent from the physical layer (your network adapter). If your operating system has properly implemented the OSI stack or some close model of it you should be able to easily define several incoming IP addresses on a single network interface. Handling incoming traffic over multiple IP's is pretty easy within linux. However, it's a little more tricky making outgoing traffic have different source IPs when sharing a single interface. Applications typically default to use the primary IP for outgoing source if you don't do anything special to force another IP to show up, but it's definitely possible to do this as well.
- 251
- 1
- 4
-
1Agreed. Network cards and IP addresses have no close tie. You could have IP addresses with no network cards (virtual networks or SLIP) or network cards with no IP addresses (Appletalk), or 1 IP address over many network cards (Bonded connections) or many IP addresses talking over one card (as other answers). – TessellatingHeckler Sep 16 '11 at 22:12
-
Hi @TessellatingHeckler , for this scenario `You could have IP addresses with no network cards (virtual networks or SLIP)`. Is the IP address attached to virtual network interface [veth](https://man7.org/linux/man-pages/man4/veth.4.html)? – Ryan Lyu Apr 05 '22 at 08:23
A very common example of one NIC with multiple IP addresses is where the NIC provides a management interface in addition to what the OS sees. e.g. HP servers with ILO.
- 14,149
- 3
- 52
- 95
- 27,262
- 12
- 53
- 108