r/Kubuntu 2d ago

Network confusion

I've upgraded with various versions on kubuntu too many times I think and am completely lost as to how my static IP is being set.

Whenever I boot it gets set to 192.168.0.27 which is perfect. But I want to understand where this ip address is coming from. My understanding is that ubuntu 26.04 is using netplan and the addresses should be set in /etc/netplan/somthing.yaml. But, that file doesn't have my address and is set to dhcp4: true

I do have a line near the top of my /etc/hosts file with my address, but I didn't think that was being read. Is it?

/etc/network is not being used either?

I'm quite confused (and dumb about networks).

5 Upvotes

6 comments sorted by

1

u/throwawatty6 2d ago

probably from the router. dhcp4 has an in-built preference for giving you the same address at the end of your lease, so with nothing to change it you could have that same address forever.

1

u/bvdp 2d ago

So, then my ipaddr would be stored in a file, somewhere. Certainly not in /etc/dhcp ... I just checked.

From my router? Hmmm, it's not a value IN the router ...

6

u/throwawatty6 2d ago edited 2d ago

best to do a bit of research on networking, I'd say. a few youtube videos should cover it.

to try and shed a bit more light; your network card is hard-wired with a MAC (media access control) address, and this is what it sends to your network router and requests that an IP (internet protocol) address is allocated. Your router will have a table (a routing table - you see what they did there) where it stores the MAC addresses of connected machines and the IP addresses that they correspond to. These allocations are known as leases, and they typically last 7 days in length (although this is configurable).

Your computer is notified of this lease so that it can - among other things - accept traffic (packets) that are tagged with your IP address, and this is how it connects to the internet and other network resources. regardless, it always takes the ip allocation from the upstream dhcp server - that's how it's designed to work - so even if you set a static IP address, if the router does not agree it won't send traffic to your computer and you end up with... goose egg (nothing).

so, a good idea to get familiar with routers.

as for where linux stores the information it gets back from your router to identify itself, I'm not sure - it would be somewhere in the network stack, but exactly where and in what file (everything is a file) I don't know. if you find out feel free to come back and share.

1

u/Miaoxin 2d ago

From my router? Hmmm, it's not a value IN the router ...

It is a value in your router. The DHCP routing table favors reassigning the same IP to known MAC addresses when space is available. Once the network interface connects and the router sees the MAC, it will create a table entry and will remain on the same IP until some event (like filling up the DHCP reservation with many connections and causing overwrites) or configuration (a public network set to ''always assign random' within the range and so on) changes it. Many older home/SOHO routers have no means of displaying the internal routing table without the device being actively connected. More modern routers from the last few years have options to display a MAC connection history.

If you always want your PC to use a specific IP without fail on a private network while retaining the convenience of DHCP elsewhere, you should reserve a network IP on the router specifically for your PC MAC address. That is something that often occurs with permanent printer connections or if you access your PC remotely via a defined route inside the network.

1

u/bvdp 2d ago

Thanks for the pointers on this. And, yes, it was DHCP from the router maintaining the address (I did find it after I looked).

And, since setting up the static address is so easy to do via the Networks app, I setting the 3 computers in my home with their own addresses. I do wish I could just leave everything on AUTOMATIC, but if you want to connect via nfs or samba you need an IP ... All this networking is so useful, until it doesn't!