The scenario is the following: You are behind your home network, usually controlled by a wireless router which connects to the internet, and you want to get access from outside of your network, let’s say to access both of your http and ssh, in a specific machine of the LAN.
- If there are more then one machine in the network which needs to be seen from the outside, then configure your http and ssh daemons to run on a specific ports - a different one for each machine. I like to use the default port with a suffix of two numbers that are easy to remember... let's say ssh: port 2269, http 8069. Usually you need to edit the config files, for instance: and for ssh and apache respectively (config files might be on a different location depending on your distro - set them up accordingly).
- Enter your router admin page, and forward the ports specified above, for those in your machine (usually mac address is used to select the machine in the network).
- Check if it works by trying and using your browser with That's the easy part. The next step is to keep track of the dynamic ip address as seen from the outside (assuming you don't have a static one).
- First you need to get the ip as seen from the outside. The website whatismyip.com provides a service for automation processes. Then you need to export it to an accessible machine. The following script does the task (I assume you have the ssh authorization keys setup on both client and server machine, if you don't, google how to do it):
- Test if it works, by making it executable and run it on the command line.
- If it does, than yay! Now let's make it automatically by creating a cron task (I use vixie-cron) to execute the
script above every 10 minutes: Note: If you don’t know how to use cron, check this.
- Add this cron to you crontab, reload it, and check if it's running with
- Check if everything is working by peeking at and check if the last update date is changing as expected.
There, done it.