Tag Archives: router

Scripting a reboot of a Billion Router over Telnet

Sometimes with older hardware and ADSL connections, you just need to do a reboot every now and then. Newer modems let you do this, but the Billion one I had the joy of playing with today, didn’t.

Lets turn to a simple script running on a Linux box on the same subnet.
Turns out using ‘expect’ you can script a Telnet session. (I know, Telnet isn’t ideal). This could be used across switches, routers, modems, other random boxes that require a telnet interface.

Create a File

nano modem-reboot.sh

Add the code. You’ll need to change the “expect” values as necessary

#!/usr/bin/expect
#If it all goes pear shaped the script will timeout after 20 seconds.
set timeout 20
#First argument is assigned to the variable name
set name [lindex $argv 0]
#Second argument is assigned to the variable user
set user [lindex $argv 1]
#Third argument is assigned to the variable password
set password [lindex $argv 2]
#This spawns the telnet program and connects it to the variable name
spawn telnet $name
#The script expects login
expect "Login:"
#The script sends the user variable
send "$user\r"
#The script expects Password
expect "Password:"
#The script sends the password variable
send "$password\r"
#This hands control of the keyboard over two you (Nice expect feature!)
#interact
#Reboot
expect "admin>"
# Change the following value to whatever your devices reboot command is.
send "system restart\r"

Finally make the file executable


chmod +x modem-reboot.sh

Test it.

Help it doesn’t work.
Under a stock standard Ubuntu 14.04 install I had to add the ‘expect’ package

sudo apt-get install expect

Thanks to http://stackoverflow.com/questions/7013137/automating-telnet-session-using-bash-scripts for the assistance and starting point of the script.

Endian DHCP stopped and failing to start on 3.0.5beta1

TL:DR Updated Endian this morning, and the DHCP service failed to start. Turns out having a 2nd DNS server set in the Web GUI doesn’t correctly write to the dhcp.conf file. Solution. Remove 2nd DNS server or manually add a comma (,) into the config file using nano.

In the Web GUI under “Status -> System Status”

The DHCP server was shown as “Stopped”.

Manually starting from the shell also failed.

‘service dhcpd start’

A quick look in the logs:

‘cat /var/log/messages’

Feb 25 10:22:51 endian dhcpd: Internet Systems Consortium DHCP Server V3.0.5-RedHat
Feb 25 10:22:51 endian dhcpd: Copyright 2004-2006 Internet Systems Consortium.
Feb 25 10:22:51 endian dhcpd: All rights reserved.
Feb 25 10:22:51 endian dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Feb 25 10:22:51 endian dhcpd: /etc/dhcpd.conf line 21: semicolon expected.
Feb 25 10:22:51 endian dhcpd:         option domain-name-servers 192.168.0.3 192.
Feb 25 10:22:51 endian dhcpd:                                                ^
Feb 25 10:22:51 endian dhcpd: Configuration file errors encountered -- exiting
Feb 25 10:22:51 endian dhcpd:
Feb 25 10:22:51 endian dhcpd: If you did not get this software from ftp.isc.org, please
Feb 25 10:22:51 endian dhcpd: get the latest from ftp.isc.org and install that before
Feb 25 10:22:51 endian dhcpd: requesting help.
Feb 25 10:22:51 endian dhcpd:
Feb 25 10:22:51 endian dhcpd: If you did get this software from ftp.isc.org and have not
Feb 25 10:22:51 endian dhcpd: yet read the README, please read it before requesting help.
Feb 25 10:22:51 endian dhcpd: If you intend to request help from the [email protected]
Feb 25 10:22:51 endian dhcpd: mailing list, please read the section on the README about
Feb 25 10:22:51 endian dhcpd: submitting bug reports and requests for help.
Feb 25 10:22:51 endian dhcpd:
Feb 25 10:22:51 endian dhcpd: Please do not under any circumstances send requests for
Feb 25 10:22:51 endian dhcpd: help directly to the authors of this software - please
Feb 25 10:22:51 endian dhcpd: send them to the appropriate mailing list as described in
Feb 25 10:22:51 endian dhcpd: the README file.
Feb 25 10:22:51 endian dhcpd:
Feb 25 10:22:51 endian dhcpd: exiting.

 

Luckily the log points us in the right direction.

/etc/dhcpd.conf line 21: semicolon expected.
Feb 25 10:22:51 endian dhcpd:         option domain-name-servers 192.168.0.3 192.

In the Web GUI if I remove the 2nd Name server, all is well, the service starts up and the log shows requests being received.
When I add it back in, it fails to start again.

When I add the comma in using nano, I’m able to manually start the service.
Although I’m sure it will break if any changes are made to the web gui.

Update: It appears that this bug has been around for a few days, and is reported: https://jira.endian.com/browse/UTM-1388

Overkill Router for any small business (or advanced home user)

Small businesses generally have an IT budget of 0, but need the best performance that money can buy.

Most small businesses rely on their little modem/router/wireless access point combination plastic box to perform all the needed tools and utilities to get the internet around their network to all their uses. But sometimes there comes a day where the little router just doesn’t have the functions required for the expanding network. (Such as complex block lists, cache, VPN functions etc). But at the same time, any left over IT budget goes into upgrading staff machines, rather than the network infrastructure.

But you don’t have to pay a lot for these extra features. If you have an old machine lying around the office, the only major upgrade that you might have to do is spend $15 on a new PCI network card and 10 cents on a CD to turn that machine into a fully fledged Firewall/Router/Proxy Server/etc.

What we are doing is turning that old Windows 98 machine into a dedicated (i.e you can’t use it for anything else) firewall and router for your small business network.

Basically all you need is a copy of either of the following operating systems:

And a machine with 2 network cards.

*Endian calls itself a Unified Threat Management & Requires better hardware than the others listed. It can perform virus and spam scans on the data in real time as it passes though the firewall. Pretty cool ey.

Check out Episode 718 of Hak5 to see how they turned a few parts they had lying around (Motherboard with a Intel Atom processor, 2GB of ram, 250GB IDE harddrive, please note they do stress that what they are using is an overkill but the process is still the same. Ed Note: The current Firewall at the office here is a simple 133Mhz processor, with 32 mb of ram & a 3 GB hard drive, it runs 24/7 and serves upto 8 users, IPCop or Smoothwall can run on almost anything) into a dedicated router and firewall.

Once you have it setup, just plug it into your network between the modem and your switch and let it go.