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.

6
  • I agree and removed the flag... however I don't see how to partially clear the DNS cache. To my knowledge, dnsmasq does not support it (see this discussion lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2014q1/…) Jul 2, 2018 at 12:04
  • Does it help to run systemd-resolve --flush-caches instead of restarting network manager? Jul 2, 2018 at 21:26
  • Because you suspend your laptop when traveling. One solution would be a resume hook that automatically runs sudo service network-manager restart. Jul 3, 2018 at 2:38
  • @SebastianStark: Would this be a permanent solution? Or a slightly better workaround that I would still be forced to use every single day? Jul 3, 2018 at 3:25
  • @WinEunuuchs2Unix: Sounds like a great idea! Jul 3, 2018 at 3:26

2 Answers 2

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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.