Ubuntu 18.04 server unreachable after setting static IP
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
.
Solution 1:
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!