Traffic Splitting on a D-Link 2500U

I recently purchased a D-Link 2500U because it allows telnet access to manage using command line. This feature is not often provided for ADSL modems (not to be confused with the routers with an integrated ADSL modem). Besides, I can’t resist a Linux powered device.

I then decided to experiment with the route command and split local and international traffic. There was surprisingly a Local Router project with a 2500U script, however their use of route proved to be incorrect in syntax.

Here is my modified script if any of you need it or are interested:

#!/bin/sh
# Your router's IP Address:
host="ipaddress"
# Your router's login user:
user="username"
# Your router password:
passwd="password"
# Your router's local interface:
if="interfacename"
# Download new list of local routes
wget "http://developers.locality.co.za/routes-rs.txt" -O localroutes.txt
modify()
{
while read i s
do
if [ "$i" != "#" ]; then
echo send \"route add `echo $i | sed 's/,/ /'` $if \\\\r\" >> localrouter.sh
echo expect \"# \" >> localrouter.sh
fi
done < localroutes.txt
}
echo "#!/usr/bin/expect --" > localrouter.sh
# Perform login
cat >> localrouter.sh << EOF
spawn telnet
expect "telnet>"
send "open $host\r"
expect "ogin: "
send "$user\r"
expect "word: "
send "$passwd\r"
EOF
# Add routes
modify
# Exit
cat >> localrouter.sh << EOF
send "exit\r"
send "!\r"
expect "$ "
EOF
# Run script
bash localrouter.sh

ifconfig can be used to obtain the needed (local) interface name.

2 comments

  1. Pingback: E-bike

Leave a Reply

Your email address will not be published.

*