3

My company's employees website can be accessed:

  • from the outside world via its IP address 1.2.3.4 or name employees.corp.com
  • from inside the company's network via its IP address 192.168.1.2 or name employees.corp.com

Problem: After commuting from home, accessing the website employees.corp.com from inside the company often fails.

  • When it fails, if I run ping employees.corp.com it says 64 bytes from w91284.telco.com (1.2.3.4): icmp_seq=1 ttl=255 time=2.08 ms.
  • I am the only person with this problem. All other employees browse employees.corp.com all the time, inside and outside, with no problem. I am also the only one using Linux (Ubuntu 2018.04 installed from scratch but I had the same problem with 2016.04).

I have found two workarounds for when that happens:

  • Workaround A: Edit the URL to replace employees.corp.com with 192.168.1.2
  • Workaround B: Run sudo service network-manager restart

Both of these workarounds fix the problem momentarily, but none is satisfying as they waste time every day. What would be a permanent solution?

Disabling or shortening DNS cache would make the whole Internet a bit slower to access so I would prefer if it is limited to this particular domain. I am open to completely different solutions too.

Nicolas Raoul
  • 11,921

2 Answers2

3

This systemd script restarts Network Manager when resuming from suspend.

#!/bin/sh

MYNAME=$0

restart_network() {
    /usr/bin/logger $MYNAME 'restart_network BEGIN'
    systemctl restart NetworkManager.service
    /usr/bin/logger $MYNAME 'restart_network END'
}

/usr/bin/logger $MYNAME 'case=[' ${1}' ]'
case "${1}/${2}" in
    hibernate|suspend|pre*)
      ;;
    resume|thaw|post*)
      restart_network;;
esac

You'll need to create this script, called network-reset, with sudo powers and save it into the directory /lib/systemd/system-sleep. Then mark it executable using:

chmod a+x /lib/systemd/system-sleep/network-reset

The logger commands above allow you to audit results by running journalctl or by looking in /var/log/syslog.

0

I was mostly satisfied with WinEunuuchs2Unix' solution but somehow it was still failing sometimes for whatever reason so I had to restart the network very often, often 4 times during the same sitting at my company desk.

I finally ended up setting my WiFi connection to always use both DNS addresses:

enter image description here

It probably results in slower connection sometimes, but at least I can connect to the company website reliably.

Nicolas Raoul
  • 11,921