0

I have been working with the GUI Network Manager (Method 1 in the link below) for over a year on Ubuntu 20.04 to set static ip addresses for all Ubuntu devices.

While this solution has been working well so far, I have been wondering if there is a chance that:

  1. One Ubuntu device is removed from the network and the DHCP allocates that IP address to another device will there be a clash if the original Ubuntu device comes online?
  2. DHCP allocates the same IP address to another new device resulting in an IP clash with an already existing static Ubuntu device configured using the GUI network manager

Alternatively, /etc/netplan/ configurations seem to be better because they go through the DHCP to request for a static ip if possible (this is Method 2 in the link below).

TLDR: Is method 2 (The “Ubuntu Server” steps.) in the link below better than method 1 (The “Ubuntu Desktop” steps.) in the link?

Link: https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-10-cosmic-cuttlefish-linux

==== Edit, the answer I have come to accept, thanks Tom Yan ==== If the router is inaccessible, use Method 2 to request for a particular IP address first, if unable then a dynamic IP address will be set but at least this avoids IP conflicts with other devices if Method 1 was used. The best method would be to of course reserve an IP address (192.168.1.12) using the MAC address of the device by adjusting the DHCP settings on the router. One step further would to assign dynamic IP addresses outside of this range (192.168.1.50 to 192.168.1.150)

javdevcpy
  • 1
  • 1
  • Normally if you do both DHCP and static with one IP subnet in a broadcast domain, you'll split the subnet into two ranges (not subnet though) of IPs and use each of them for each type of assignment. Even most of the cheapest / consumer-grade routers allow you to set the range for DHCP. – Tom Yan Jan 06 '22 at 04:16
  • 1
    And slightly better routers should allow you to configure "DHCP reservation", with the most sensical approach being using the MAC addresses of the hosts as mappings for IPs that should be assigned to each of the hosts that relies on DHCP for IP configuration. – Tom Yan Jan 06 '22 at 04:19
  • `they go through the DHCP to request for a static ip if possible` this makes so sense at all and neither does the article mention any nonsense like that. – Tom Yan Jan 06 '22 at 04:23
  • There's not exactly any way to prevent you or anyone from configuring any of the "reserved" IPs statically on a host. Whether you can prevent them from "interfering" the mapped hosts depends on the router. Usually no for cosumer-grade, AFAIK, coz that's more of a human error than a security issue in the home-use cases. – Tom Yan Jan 06 '22 at 04:28
  • Right, so from what I understand from your comments, if I were to set a static IP Address using either the GUI Network Manager or the /etc/netplan/ configuration it is setting the static IP on the host alone but it does not rule out the possibility of the router assigning that IP address to a new device unless a DHCP reservation is explicitly stated? According to https://superuser.com/questions/487607/how-to-request-a-specific-ip-address-from-dhcp-server/487608#487608 the best approach seems to be to request to see if an IP is available first before assigning it statically – javdevcpy Jan 06 '22 at 04:39
  • Does the Ubuntu 20.04 GUI network manager check if an IP address is available first before assigning it to the device or does it simply assign the static IP address irregardless which could potentially result in an IP clash? – javdevcpy Jan 06 '22 at 04:45
  • `they go through the DHCP to request for a static ip if possible this makes so sense at all and neither does the article mention any nonsense like that. ` In the article there is a line that says: `configure your network interface via DHCP` which leads me to believe that the /etc/netplan requests for the static IP first, if the static IP is not available a dynamic IP is assigned instead – javdevcpy Jan 06 '22 at 04:47
  • `Normally if you do both DHCP and static with one IP subnet in a broadcast domain, you'll split the subnet into two ranges (not subnet though) of IPs and use each of them for each type of assignment. Even most of the cheapest / consumer-grade routers allow you to set the range for DHCP. ` that's true, that would be the best. However I have no control over the router. Hence the situation of trying to assign static IP address from host (Ubuntu 20.04 computer). However, does the host (ie the Ubuntu network manager or the /etc/netplan) – javdevcpy Jan 06 '22 at 04:52
  • check if the Static IP address is available first? If it is available then the Host proceeds to use it, if it isn't then the host requests a dynamic Ip address to be assigned via DHCP. – javdevcpy Jan 06 '22 at 04:52
  • What's the point of any of those approaches you suggested? I'm really not seeing the sense here. I mean, what exactly is the scenario here and what exactly do you want to achieve? If you want to "request a specific address on each host by (specifying the desired address in the request)", what's the difference between that and a static configuration? If you can accept that the host ultimately be assigned with a different address, what's the point of *trying* to make it use a specific one? – Tom Yan Jan 06 '22 at 06:16
  • Aim: Setting a static IP for the host (e.g. 192.168.1.12). Problems: DHCP may assign this IP to another host if the original host is away leading to an IP conflict when the original host comes online. Even if the original host is online the DHCP may assign the IP to another host (DHCP does not take the effort to scan the network for free IPs). Solution: using the GUI network manager (Method 1 “Ubuntu Desktop”) may lead to the above 2 problems. (Method 2 “Ubuntu Server”) at least queries DHCP, so it prevents both the above 2 problems. – javdevcpy Jan 07 '22 at 08:34
  • Better solution: reserve IP on DHCP using MAC address (if router settings are accessible). @Tom Yan, by trying to make it static, development work on this network is drastically simplified for reasons I don’t want to get into. To answer the original question if one has no access to the router settings, you cannot notify the router that you want an IP address, you can only request for it and hope for it to be free – javdevcpy Jan 07 '22 at 08:36
  • Honestly, as I said, I don't see the point to *try* when you only *might* get/set the desired address. Solution: Just ask whoever manages the router which IP(s) you can use for static assignment / to reserve one for you. If you are not even privileged enough for that, just deal with what the server assigns. – Tom Yan Jan 07 '22 at 09:32
  • Thanks for your opinion but I’ll consider the question answered. – javdevcpy Jan 07 '22 at 20:41

0 Answers0