Contents
Gentoo-based ADSL router
Gentoo network initscripts should support ADSL (pppoe), but in some weird way it didn't work for me... So I had to do some custom hacking :D. I added following code to /etc/conf.d/local.start:
adsl-startand to /etc/conf.d/local.stop:
adsl-stopNow to get routing working I had to create following firewall configuration (using iptables) and also set ip_forwarding to 1 in /proc
iptables -F
iptables -t nat -F
iptables -I FORWARD -i eth1 -d 10.0.0.0/255.255.255.0 -j DROP
iptables -A FORWARD -i eth1 -s 10.0.0.0/255.255.255.0 -j ACCEPT
iptables -A FORWARD -i ppp0 -d 10.0.0.0/255.255.255.0 -j ACCEPT
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADEAnd to make sure it's really working I had to enable packet forwarding from /etc/sysctl.conf:
# Enable packet forwarding
net.ipv4.ip_forward = 1
# Enables source route verification
net.ipv4.conf.default.rp_filter = 1Nothing fancy, because it's only the basic setup. (I also coded basic (again nothing fancy) PHP/Apache-driven web-based frontend to start-stop ADSL or view connection information :D, bug me if you want it)
Automatic ssh tunnels
When building ADSL-router I found out that the ISP had closed all the ports. So I had to create an automatic ssh tunnel which forwards port 22 (or any other) to some other publicly accessible server. I used autossh package.
First I created ssh keys (empty passwords!!!):
ssh-keygen -f id_rsa -t rsaThen moved my private key id_rsa to ~/.ssh/ directory:
mv id_rsa ~/.ssh/
Then added public key to server's authorized_keys file.
And finally added following to the /etc/conf.d/local.start:
eval `ssh-agent -s`
ssh-add /root/.ssh/id_rsa
autossh -2 -fNg -M 20000 -R 2200:localhost:22 user@hostWorks for me :D
