I am constantly logged into (ssh'd) my home machine (ubuntu) from various remote locations. Sometimes I would like to change my home linksys router settings (change the port forwarding settings or disable/enable wireless, things like that).

When I try and use the links2 text browser, there isn't much I can do because the tab titles don't show up (presumably because they are pictures?).

Is there another way of configuring a linksys router from a command line? I guess my only other option is to set up a proxy on my home machine and use a browser connected to that proxy to configure it, but I would think there might be a non-browser way of doing it.

Thanks

link|improve this question

feedback

3 Answers

up vote 3 down vote accepted

Some third-party router firmwares (like DD-WRT, OpenWRT, Tomato, etc) provide an SSH interface to the router. I'd enable this on the LAN side but not the WAN. (You could also enable it on the WAN side using a nonstandard port, and a very strong password; likewise you could enable WAN access to the web interface; but I don't recommend those configurations.)

Once enabled, you can SSH into your router from within the LAN. (Eg, if the SSH interface is enabled on the LAN but not the WAN, you'd SSH into your Ubuntu machine, and SSH again from there into the router.) Once there you get a minimal shell (often provided by BusyBox), and have access to configuration files, daemon scripts, firmware settings and whatever commands are installed.

For example, I have an older Linksys WRT54G running OpenWRT. Via the SSH interface, I have access to:

  • iptables (eg, for opening temporary ports);
  • the /etc/hosts and /etc/dnsmasq.conf files (eg, for adding local DNS overrides or tweaking the DHCP server); and
  • the reboot command (if needed).

I can also inspect firmware settings (nvram show), alter them (nvram set), and write them to nonvolitile flash memory (nvram commit). Much of what you can access in the web interface is directly accessible with nvram, but be careful. This old OpenWRT HowTo describes basic nvram usage; there are probably better and more recent guides online, so read up and take care when using that utility.

link|improve this answer
feedback

If you're using ssh, you can have that set up a quick, temporary proxy:

ssh -L 9000:routerip:80 homemachine

Then on your local computer, point your webbrowser to http://127.0.0.1:9000/ and you should see your router's configuration screen. routerip is the IP that your home ubuntu machine would use to connect to the router.

If you're using puTTY, these settings are under Connection->SSH->Tunnels Source-port 9000, destination routerip:80, type Local (then click "Add", then open the connection like you usually would).

It's a quick, simple proxy that you can set up any time you need to connect and tweak something.

link|improve this answer
feedback

I wrote a script to reboot my router (a Motorola Surfboard). It is here. Trouble was that the only port open on the router, when scanned from within the LAN was port 80, which offered an HTML configuration page.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.