The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 490     Votes:  3     ✅ Solution
Tags: networking   dns   intranet  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1051686
Title: Every time I change networks, DNS cache has the wrong IP. How to fix automatically every time?
ID: /2018/07/03/Every-time-I-change-networks_-DNS-cache-has-the-wrong-IP.-How-to-fix-automatically-every-time_
Created: July 3, 2018    Edited:  July 4, 2018
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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.

⇧ 18.04 Sound Through hdmi Running a Bash while loop over all similar files  ⇩