Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am constantly logged into my home machine, which runs Ubuntu, from various remote locations via SSH. Sometimes I would like to change the settings on my home Linksys router - port forwarding settings or disable/enable wireless, things like that.

When I try to use the links2 text browser to configure it, 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 I could 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.

share|improve this question
add comment

3 Answers

up vote 5 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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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