The goal: allow a remote computer to view a website hosted on my local computer.
Steps:
- Set up an account with dyndns.org
- Install ddclient on my Ubuntu machine to periodically notify dyndns.org what my IP address is
- Don't prepend "http://" to your domain name in the ddclient setup!
- On my router, assign my computer a static IP address
- On my router, forward incoming traffic on port 8080 to the new static IP address
- On my computer, port-forward port 8080 to port 80, where my apache webserver is listening
- sudo iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 (add the port forwarding rule)
- sudo iptables -F (flush the rule)
- sudo iptables -t nat --list (view the rule)
- sudo bash -c "iptables-save < /etc/iptables.rules" (save the rule to a file)
- sudo echo -e '#!/bin/sh\niptables-restore < /etc/iptables.rules\nexit 0' > /etc/network/if-pre-up.d/iptablesload (to create a script to restore the iptable rules every time the network interface comes up)
- sudo chmod +x /etc/network/if-pre-up.d/iptablesload (to make the script executable)
- Visit my site in a browser at http://subdomain.dyndns.org:8080
2 comments:
Yes Ben, everyone knows how smart you are....(-;
You know that's not why I posted it. :)
I spend half my working hours searching various forums and blogs for answers to random programming questions, so whenever I figure something out, I like giving back by posting a clear tutorial or example of how I solved the problem.
It's the ecosystem of the internet.
Post a Comment