My First NetworkManagerDispatcher Script

For anyone not interested in Linux, skip this post, it’ll just bore you… 🙂

I whipped up a tiny little script today to automate something that’s been bugging me for ages. At home, I have an unreliable router, particularly unreliable for DNS purposes. So I manually override the default DHCP settings and specify the ISP’s DNS servers directly. Today I wrote this little script for NetworkManagerDispatcher to do this automatically for me.

# Script to dispatch NetworkManager events
# Update /etc/resolv.conf on thouse network

if [ -z "$1" ]; then
	echo "$0: called with no interface" 1>&2
	exit 1
# Run the right scripts
if [ "$2" = "up" ] && [ "$1" = "eth1" ]
	iwconfig $1 | grep ESSID | while read interface junk ieee essid nick
		if [ "${essid:7:5}" = "T-Two" ]
			cp /etc/resolv.conf.thouse /etc/resolv.conf
			exit 0

If that’s double dutch to you, don’t worry. It’s a very custom script which only really applies to my situation, but you never know, it might be useful to somebody, somewhere, one day…

Leave a Reply

Your email address will not be published. Required fields are marked *