Skip to content

Instantly share code, notes, and snippets.

@CodeZombie
Last active November 19, 2018 05:26
Show Gist options
  • Save CodeZombie/cb887be648e7f48162fe6fef0462e4a9 to your computer and use it in GitHub Desktop.
Save CodeZombie/cb887be648e7f48162fe6fef0462e4a9 to your computer and use it in GitHub Desktop.
Configuring a DD-WRT router as a remotely-connectable home linux server.
######################################
########### INSTALLATION #############
######################################
First, we will configure the primary internet-facing router.
- Reserve an IP address that will be your DD-WRT router. In this example, I will use 192.168.1.69
- Setup your port-forwarding to expose SSH by setting the external port to something memorable like 420, and the internal port to 22 on IP 192.168.1.69.
Now, factory reset the DD-WRT router, and connect it directly to your laptop via ethernet. Disconnect from your primary router.
Go to the DD-WRT router configuration page at 192.168.1.1.
Let's first enable SSH (Remember to Save and Apply Settings after changes to each section):
Go to <Services> and set
SSHd: Enable
Now go to <Administration> and set
SSH Management: Enable
Allow Any Remote IP: Enable
Now, let's connect this DD-WRT router to the primary router:
In <Setup>, fill in the following information:
Local IP Address: 192.168.1.69
Subnet Mask: 255.255.255.0
Gateway: 192.168.1.1
Local DNS: 192.168.1.1
DHCP Server: DISABLE
Save and reboot the router.
While it reboots, connect an Ethernet cable between a ETH port on the primary router to an ETH port on the DD-WRT router.
If you connect to the primary router, you should now be able to go to 192.168.1.69 in your browser to access the management page.
And running `ssh <your external ip>:420` will connect you to the SSH server on your DD-WRT router.
Now is a good time to setup and enable DDNS on your DD-WRT router.
######################################
######## Configuring Linux ###########
######################################
Login to the DDWRT machine via SSH as Root.
Follow this guide to install OPKG/Entware: https://wiki.dd-wrt.com/wiki/index.php/Installing_Entware
Once that is succesfully, running, go ahead and run
opkg install busybox
opkg install sudo
Now, we want to create a non-root user that we will login to SSH with.
adduser admin
visudo
Add the following line to this file:
admin ALL=(ALL) ALL
Now log out of SSH, and try to log back in again as `admin`. once logged in, try to run `vi /etc/passwd`. If you do not have root access by default, this file should be empty.
Now try `sudo vi /etc/passwd`. After entering the root password, there should be contents in this file. Everything is now working correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment