2

What are dependencies and relations between device, interface and connection in nmcli cmdline utility under linux?

The below questions are asked in context of nmcli and networking in linux:

Which can be only in 1:1 relation and which can be in 1:many relation ?

In case of 1:many, can many be active at the same time ?

Is network card (nic) the same as device ?

Is ip address eg 10.0.0.1 an instance of interface or connection ?

Can one network card have multiple ip addresses active at the same time ?

Can multiple network cards (in the same server) share the same ip address, is it network teaming ?

  • 4
    Is this a homework question? – HopelessN00b Jan 5 '15 at 11:15
  • 1
    (I typed out most of the answer before this got closed, so I reopened it to post an answer - make sure to read it before the auto-deletion scripts nuke the whole thing.) – HopelessN00b Jan 5 '15 at 11:41
  • 1
    not a homework, I tried to learn networking with nmcli under linux and got confused by trio device connection interface - one too much for me (two would be understandable and enough for me). Is device a nic and a single ip address a connection ? If so what is interface for ? – bastiat Jan 6 '15 at 12:04
10

A "network device" (in the context of a computer) typically refers to a piece of hardware - the network interface card (NIC). Once upon a time, back when dinosaurs roamed the internet and lots of people still used modems, NICs really only came with one interface, but nowadays, NICs with multiple interfaces are common. A NIC can have multiple active IP addresses (as can an interface), and multiple NICs can have the same IP address. There are undoubtedly countless NICs and/or interfaces in the world with the 192.168.1.1 IP address right now.

An interface, in this context, is the hole you plug a network cable into (often referred to as a port, but not to be confused with a [software] port). For many intents and purposes, different network interfaces on the same device/NIC can be treated as different devices - they are often independent, can almost always be configured independently (and differently), and are seen as different devices by your software, even if they come on the same card. For example, the computer I'm typing this up on has a dual-port NIC, one of which was fried by a lightning strike a couple years back. The other interface still works just fine, though. See below image to understand the relationship of device and interface.

enter image description here

A network connection... is a much more ambiguous term. In the context of hardware, it would refer to the physical connection between the interface on a computer and the interface on a second network device (switch, router, other computer, etc.), by a network cable of some sort. It's a vague term, though, so it can mean just the cable, just the connection on one end, the connection on both ends, or encompass the whole thing, interface, cable and other interface. It can even extend further than than - as in "check your connection to the internet," which would cover a computer, a router, at least a couple cables, and possibly more.

In terms of software, a "connection" generally means a network session (such as an SSH or FTP sessions between two computers), but is often used to refer to stateless protocols as well, like http. Even though there is no actual session, people will often talk of a "connection" with a website, for example.


However, as far as nmcli is concerned, a connection is the equivalent of a 'profile' for an interface that bundles all the relevant configuration for that interface. Let's imagine you have to temporarily connect your server to a different network and have only 1 interface. Let's assume this interface is called ens33, and has all its config stored in a connection called primary. Thus have to change certain settings on the interface (perhaps the static IP and gateway for that new network) for the new connection to work at all. You could delete the existing settings, in which case you'll have to write them back again - or just create a new connection for that interface (let's call it testing). Now, you can keep both sets of settings separate and you can change all the settings at once by switching connections with:

# nmcli con down primary; nmcli con up testing

As far as the relationships are concerned, 1 NIC (device) can have multiple interfaces, and each interface can have multiple connections (associated settings stored in a file /etc/sysconfig/network-scripts/ifcfg-<interfaceName>).

| improve this answer | |
  • Too bad that this answer will most likely get buried / deleted. As a non native speaker it took a while to get all the terms in my head. – Reaces Jan 5 '15 at 13:35
  • 1
    @Reaces Yeah, the ESL factor is really the only reason I answered. I think it'll take 9 days for the auto-deletion scripts to hit this question (at least as it stands now), so hopefully it'll help out a non-native speaker or two before then. – HopelessN00b Jan 5 '15 at 13:55
  • In context of linux and nmcli: device is 1:1 to nic ? " A NIC can have multiple active IP addresses (as can an interface)" - does this active IP addresses belong to nic, device or interface or connection ? Maybe Interface can have addresses only from the same network ? Maybe addresses from different networks must belong to distinct interfaces ? Can single NIC have addresses from different networks ? And how nmcli connection fits into it ? Is connection the same as single IP address ?Can a single connection have multiple IP addresses or opposite- siglle ip addr is rather assigned to many conns? – bastiat Jan 6 '15 at 12:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.