I'm a little confused about the network interface. Based on my understanding, a network interface does the translation between link-layer and internet layer, and does the ARP. Is that right? Also what's difference between a network interface and a network interface card (NIC)? I know NIC is a hardware-like network interface, so why we need NIC when we already have software-like network interfaces? At last, does every network interface must have its own IP address and MAC address? Can multiple network interfaces have the same IP address or MAC address?
2 Answers
What does network interface do?
A NIC provides data-link-layer (data framing and MAC addressing) and physical-layer connectivity (cable attachment and line encoding). Modern NICs may also provide various offloading features for the network and transport layers.
what's difference between a network interface and a network interface card (NIC)?
"NIC" used to be short for network interface card when this function required an add-on card. When it evolved to an on-board commodity, it became network interface controller. Technically, there's no difference beyond the form factor.
Strictly speaking, network interface may also refer to a port with less (or more) functionality than a NIC, e.g. a switch port or sometimes even a print server option card for a printer or a serial server.
a network interface does the translation between link-layer and internet layer, and does the ARP.
There's no translation. The internet layer (or network layer) uses the underlying link layer for transport. Internet-layer packets are encapsulated in link-layer frames (e.g. Ethernet frames). ARP is required for this encapsulation since the proper MAC address needs to be determined. Strictly speaking, ARP isn't done by the NIC but the IPv4 stack (part of the OS). The NIC just transports those ARP packets.
Picture the IP packet as a container with an overseas address. It's loaded on a truck (frame) but the truck driver needs a street address he can drive to (MAC address). His controller (ARP) looks up the harbor address (gateway) for the container ship and passes it to the driver. At the port, the container is loaded onto a ship (another frame type) and the captain uses entirely different navigation than on the truck (another network type) for the destination port. At the destination, the container goes onto the next truck, and so on.
why we need NIC when we already have software-like network interfaces?
After all, the data needs to be transported physically in the physical world. Purely virtual interfaces (e.g. a VPN interface or a vNIC inside a hypervisor) and networks require no additional hardware - but the data can never leave the physical host.
Basically, a NIC provides physical (L1) and data link layer (L2) functionality in hardware, while the OS provides network (L3) and transport layer (L4) in software. The application layer (L7) resides in the application. (Where implemented, session (L5) and presentation layer (L6) as well.)
does every network interface must have its own IP address and MAC address? Can multiple network interfaces have the same IP address or MAC address?
Within a specific L2 segment and L3 subnet, yes. (There may be virtual IP addresses or even MAC addresses in special scenarios.)
A MAC address can be present in multiple L2 segments when VLANs are trunked to a NIC, for instance. Hardware MAC addresses are said to be globally unique, but that isn't always the case.
An IPv4 address is generally unique in a subnet, but private addresses may be used elsewhere, possibly requiring network address translation (NAT) in between. A virtual IP address may be shared by multiple devices, usually in an active-passive scheme like with VRRP or HSRP.
NICs are mostly used for end devices like PCs, printers 🖨️ etc . Network interfaces are used on network devices. They mostly work the same, except Network interfaces can do more like advance networking e.g. transmit frames, route packets, etc.
Sometimes, they are used interchangeably, so you don't have to worry about it much.
@zec67 has said most of other advance features.
Regards.