Skip to content

Instantly share code, notes, and snippets.

@jpstacey
Created February 21, 2010 09:16
Show Gist options
  • Save jpstacey/310225 to your computer and use it in GitHub Desktop.
Save jpstacey/310225 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Add or list DNS entries in an 02 wireless box
# To compensate for O2's unreliable DNS provision
# h/u/p for standard O2 wireless box
host=192.168.1.254
user=SuperUser
pass=O2Br0ad64nd
# OpenDNS server to add
# Can be overridden on command prompt
dns=4.2.2.2
metric=5
# First argument either:
if [ "$1" != "" ]; then
# -h to list usage
if [ "$1" == "-h" ]; then
echo "Usage: $0 [x.x.x.x|list] [weight]"
exit
fi
# DNS entry
dns="$1"
# Or "list" command: see below
fi
# Second argument is the metric for the DNS entry
if [ "$2" != "" ]; then
metric="$2"
fi
# Standard command to send over telnet
cmd="dns server route add dns=$dns intf=O2_ADSL2plus metric=$metric"
# Replace with completely different command if we want to list all routes
if [ "$1" == "list" ]; then
cmd="dns server route list"
fi
# Pipe session into telnet command
( echo open $host
echo ^]set echo ^
sleep 1
echo -e "${user}\r"
sleep 1
echo -e "${pass}\r"
sleep 1
echo -e "$cmd\r"
sleep 1
echo -e "quit\r" ) | telnet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment