I'm following a tutorial on setting up a dns-tunnel.

I've run into the following instruction:

Now you need to enable forwarding on this server. I use iptables to implement masquerading. There are many HOWTOs about this (a simple one, for example). On Debian, the configuration file for iptables is in /var/lib/iptables/active. The relevant bit is:

*nat
:PREROUTING ACCEPT [6:1596]
:POSTROUTING ACCEPT [1:76]
:OUTPUT ACCEPT [1:76]

-A POSTROUTING -s 10.0.0.0/8 -j MASQUERADE
COMMIT

Restart iptables:

/etc/init.d/iptables restart

The problem is that I don't have any /var/lib/iptables/active. (I'm on ubuntu.)

How can I accomplish this? I suspect that I should just interact with the iptables command somehow but I have no clue what to write. Best would probably be if I could put the commands in a script somehow I suppose.

(A side-note. If I execute a few iptables-commands it wont be there for ever, right? The rules will be discarded on reboot?)

link|improve this question

57% accept rate
While you can directly manipulate firewall rules, I strongly suggest you consider using a front-end script like firehol. See: serverfault.com/questions/397/… and serverfault.com/questions/126795/… – Zoredache May 11 '10 at 20:39
feedback

4 Answers

up vote 1 down vote accepted

Use the following command:

/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -j MASQUERADE

If you want it to be applied everytime the system boots the easiest way will be to put in the file /etc/rc.local before the exit 0 line.

link|improve this answer
feedback

for what it's worth, there's no /var/lib/iptables/active on my debian system, so i'm guessing this guide/howto is out of date a little bit.

i'm not even really sure what to make of:

*nat :PREROUTING ACCEPT [6:1596] :POSTROUTING ACCEPT [1:76] :OUTPUT ACCEPT [1:76]

i'm guessing it's either the default rules for the chains or specifying you should allow ports 6 to 1596, etc.

link|improve this answer
feedback

You may find it simpler to install Shorewall and let it manage the iptables for you. It is packaged for Debian and well documented.

link|improve this answer
feedback

there is a package that contains a system service to restore

sudo apt-get install iptables-persistent

put rules in /etc/iptables/rules.

one way to do this is:

sudo bash -c "iptables-save > /etc/iptables/rules"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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