Score:0

How to give a name to a specific interface in a local network? (Ubuntu 20.04)

cn flag
JYF

I am currently trying to set up (as a total noob) a small home server running Ubuntu 20.04. The server is a Minisforum mini PC (U820 model) with two Ethernet ports. The first port is connected to my ISP fibre box. The second port is connected to my usual everyday computer, a Mac — so the Ubuntu server is some kind of router. The Mac is also wirelessly connected to the server (as I activated wifi sharing in Ubuntu).

On the Ubuntu terminal, the ip a command originally told me to use the 10.42.0.1 address to locally access the server via Ethernet from the Mac:

3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 5c:85:7e:4e:6c:e5 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.1.255 scope global noprefixroute enp2s0
       valid_lft forever preferred_lft forever
    inet6 fe80::1ea8:95f4:8840:fee/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b0:a4:60:7c:c0:a4 brd ff:ff:ff:ff:ff:ff
    inet 10.42.1.1/24 brd 10.42.0.255 scope global noprefixroute wlp3s0
       valid_lft forever preferred_lft forever
    inet6 fe80::d87f:88e4:afe7:637f/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

But recently (after an Ubuntu reboot?) the local addresses changed, they were reversed, now I have to use the address 10.42.1.1 to connect to the server via the Ethernet port.

How can I prevent future reversals? Or is it possible to give some name to the enp2s0 Ethernet interface, a name that could be used from the Mac to always connect to the server through the wired path?

user535733 avatar
cn flag
`enp2s0` is the consistent name of one of your ethernet interfaces. See https://netplan.io/examples/ for examples of how to use that consistent name to set up your networking properly.
cn flag
JYF
Thanks for your answer, but the netplan.io/examples page is too difficult for me. How can I connect from my local computer to the server via Ethernet using a command like `ssh myname@enp2s0` or `ssh myname@server-via-cable`? How can I set a permanent name for the Ethernet interface, recognizable by any other computer on the local network?
user535733 avatar
cn flag
The only kind of "*permanent name for the Ethernet interface, recognizable by any other computer on the local network*" is an IP address. Other machines do not know your system's ethernet port names. They only know your system's IP address. (That's why it's called an *address*). There are other methods of spotting machines and services on a local network, but they are all tied to that IP address.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.