2

This is how I set up a static ip on my ubuntu machine:

https://askubuntu.com/a/178981/630142

Pretend this happens:

  1. I connect my ubuntu machine to a router (network) that assigns ip addresses (192.168.0.X)

  2. Then I assign a static ip to my Ubuntu machine of 192.168.0.50.

  3. Ubuntu machine has internet connection and everything works great. I am able to ping 192.168.0.50 from other computers on the same 192.168.0.X network.

  4. Someone changes the router that has a different network mask (192.168.10.X) instead of (192.168.0.X). So now devices that where connected through DHCP have a different ip.

  5. Because of this change now my Ubuntu machine is not able to connect to the internet. The ip address 192.168.0.50 is no longer valid.

Now my question is: How do I know that the reason that I have no internet connection is because the network changed? I may check for internet by doing:

ping google.com

Maybe the ping does not work because the whole network lost internet connection. But how can I tell if the reason was because the whole network lost internet --OR- if it was because my static ip is not valid

Tono Nam
  • 135
  • 1
  • 6

2 Answers2

2

This is an organisational problem.

If somebody changes your router settings they should notify you.

If you have to use static, locally assigned IP addresses on your system although there's a DHCP server, the admin of the DHCP server should reserve a range of IPs for static use and put it in the documentation notes.

If your internet does not work with static IP and you know there's a DHCP server, you can temporarily switch to using DHCP and see what you are assigned, then change your static setup accordingly.

Again, I think this is a communication/documentation issue in your organisation.

Sebastian Stark
  • 6,052
  • 17
  • 47
1

Well there are two aspects here.

For starters any decent DHCP server will attempt to verify that the IP address it hands out is unused prior to offering it. But there can be loopholes, of course. However, this typically means that you can assume that loss of connectivity means loss of internet connectivity.

However, if you wanted to establish that you can communicate at all, try communicating with your gateway. That is, use the output of ip route and pick the gateway for the default route and try to ping that gateway. If that works, the issue is probably upstream (internet connectivity) if it doesn't, your problem is local.

Besides, if you really use:

auto eth0
   iface eth0 inet dhcp

as you point out, under normal circumstances unplugging and replugging the cable will cause your DHCP client to re-request a lease from a DHCP server. But you can also tell your client to release the DHCP lease. For dhclient it is the -r option.

NB: make sure you don't have a parallel network manager setup of some kind.

0xC0000022L
  • 5,656
  • 6
  • 52
  • 91
  • But not all routers respond to pings :/ . Or it is disabled for security? – Tono Nam May 24 '18 at 18:44
  • 1
    @TonoNam *if* someone thinks s/he's doing something clever security-wise by filtering ICMP echo (aka ping) requests and responses you have certainly bigger problems at hand. But to be honest *you* should know how to talk to the router (after all you decided it's safe to connect your device to it!). And as a last resort you could always try `nmap` to see if a system is live at the IP address of the gateway. I used `ping` because that's the example you gave to try connectivity. But seriously, you didn't even mention this constraint in your question, so my answer stands. – 0xC0000022L May 24 '18 at 18:47