Score:0

Ubuntu 18.04 server unreachable after setting static IP

sl flag

I've configured netplan to set static IP for a server on my local network. However, after sudo netstat apply server just becomes unreachable. When I check the router, I can see it listed with assigned static IP (after waiting for a long time), but it's still unreachable. Does it have something to do with modems default settings that were provided by ISP? Here is my netstat config:

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                myssid:
                    password: "[redacted]"
            dhcp4: false
            addresses:
              - 192.168.0.66/32
            routes:
            - to: 0.0.0.0/0
              via: 192.168.0.1
            nameservers:
              addresses:
                - 1.1.1.1
            optional: true

The issues appears the moment I set dhcp4 to false.

chili555 avatar
cn flag
Is there any improvement with `192.168.0.66/24?
hr flag
Yeah I don't think /32 is valid is it? That leaves no bits at all for the host portion...
Terrance avatar
id flag
https://www.subnet-calculator.com/ will show you that the highest mask bit you can use is /30. /32 is not valid.
Gitnik avatar
sl flag
Why /32 is not valid? I only want to reserve one static IP address for the server :\ /24 is the full range, but I only need one address. Is this a limitation on C class or something else?
Terrance avatar
id flag
@Gitnik Whether you have static or not, putting the IP with a /32 will make it so that it cannot and nothing else can communicate with it since it will be on its own network. You can put static IPs in the DHCP range, or you can put them outside of the DHCP range as long as they are in the same subnet network. If you put it in the DHCP range, make sure that your DHCP server has that IP address reserved so that it doesn't give it out to anything else.
Gitnik avatar
sl flag
Thank you for the explnation @Terrance Can you add this as answer so I can accept it? :)
Score:1
id flag

Whether you have static or not, putting the IP with a /32 will make it so that it cannot and nothing else can communicate with it since it will be on its own network.

You can put static IPs in the DHCP range, or you can put them outside of the DHCP range as long as they are in the same subnet network. If you put it in the DHCP range, make sure that your DHCP server has that IP address reserved so that it doesn't give it out to anything else.

You can use https://www.subnet-calculator.com/ to check your network settings and what IP addresses would be valid.

The static IP you have of 192.168.0.66 with a /24 will be fine as it will be in the full subnet of 192.168.0.1 - 192.168.0.254 and as long as your DHCP server has that IP address reserved, nothing else should get that IP. If your DHCP server starts the first IP of 192.168.0.100, your IP of 192.168.0.66/24 is still considered in the subnet range, but not in the DHCP range and will still work and you would not need a reservation for it.

Hope this helps!

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.