Home server with two network adapters: possible to set two host names?

Hi all,

my home server is usually connected to my home LAN via ethernet, straight to my router.
However I may occasionally move it around and ssh into it while it’s connected to my home WiFi.

Since my router’s DHCP assigns different IPs to those two interfaces (e.g. 10.230.230.2 for eth and .3 for wifi), I was wondering if there’s a way to declare two hostnames, e.g. home-server-eth and home-server-wifi, so that I can reach it by name rather than IP.

My home router should support local DNS resolution AFAIK, but the host name is not something I can decide there, I guess it’s discovered automatically, and therefore it stays the same for both IPs, leading to ambiguity:

I tried to have a look at nmtui, but there is only a global Set system hostname option and that’s it.

Thanks :slight_smile:

well… one way is to manually add those IPs to the /etc/hosts file of the machine you are using to connect to your home-server.

10.230.230.2 home-server-eth
10.230.230.3 home-server-wifi

that should solve the problem.

Thanks, but I’d rather have something DNS-based since I may also ssh into my server from an Android phone.

This is a first world problem I reckon, with static leases I will know that I have to ssh either into .2 or .3. The point is, this would be a way for me to learn something new :slight_smile:

Nice picture, but where is it from?

my tp link home router

You might want to try to ssh into your router and then change the DNS entries there (it seems to be possible for tp link routers) - you might be in luck.
On the other hand, if the router is from your internet provider, most likely that possibility is locked/disabled.

man nm-settings and search for dhcp-hostname and dhcp-send-hostname.

I’ve not tried this but using nmcli, you could maybe have it configured to send a different hostname value on the dhcp request. For instance:
#get connection names
nmcli show con

nmcli con show “wireless name”

One of the properties is ipv4.dhcp-hostname
so maybe:

nmcli con modify “wireless name” ipv4.dhcp-hostname “some unique hostname”

You could then just add it to your hosts file as well assuming you see the hostname reflected in the router on next dhcp

You guys rock! It works!

BUT! My crappy router apparently does not resolve names of locally connected devices! Although it shows their names…

 🐧 andrea 11:15:47 12/04/24  🏠  ❌2  dig home-server

; <<>> DiG 9.18.25 <<>> home-server
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 59193
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;home-server.                   IN      A

;; Query time: 0 msec
;; SERVER: 10.230.230.1#53(10.230.230.1) (UDP)
;; WHEN: Fri Apr 12 11:17:07 CEST 2024
;; MSG SIZE  rcvd: 40

Although the server is clearly my router (10.230.230.1), nothing comes back.

So al of this was for nothing (well, learning some nm cli settings, I guess!).

Again about those screen shots. As you explained they are from your router, but there is no title/header, thus what the table shows is unclear.

My impression is that they are just a list of IP addresses managed by the DHCP server in the router. Nothing more. No connection with an eventual DNS server that may or may not run in the same router.

Yes it turns out that while my router stores device names and their local addresses, it won’t provide a DNS service on the LAN.

As the systems on a home LAN will most probably not have fully qualified domain names, I guess that is something you can not ask from the device.

It seems like many home router manufacturers provide this capability tho, at least according to some forum users complaining about this shortage on their Tp-Link.

Anyway, it’s been an occasion for me to learn something new about NM and I’m happy I gave it a try.

I guess I’m gonna connect to the statically leased IP addresses and call it a day (as I’ve been doing so far).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.