Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I have some rules on my server for my VPN, but my partner does port forwarding if needed for my customers. I want to know how to do it myself but he doesn't want to tell me. Now I found these rules on my server, could anyone translate it to the command that was entered? Like the command my partner typed in putty to add this rule, so I can learn from it.

If possible explain what everything does aswell please :).

Picture of rules:

http://img211.imageshack.us/img211/8536/f47067ed35ff487c97db0bf.png

share|improve this question
2  
You have a serious problem with your partner, and it has nothing to do with iptables rules. –  Michael Hampton Dec 26 '12 at 22:37
    
Then how did he manage to port forward these ports? –  Niel Dec 26 '12 at 22:39

2 Answers 2

up vote 8 down vote accepted

If you do

iptables-save > iptables.txt

Will get the iptables commands, you will need to add iptables in front of them to add just the one line

You can use

iptables-restore < iptables.txt

to restore the iptables rules as they are in the in files.
This is useful for backups before changing things.

share|improve this answer

Read up the iptables man page to see what each switch/flag does.

iptables -t nat -A PREROUTING -p tcp --dport 1338 -j DNAT --to 10.8.1.1:1338
iptables -t nat -A PREROUTING -p tcp --dport 777 -j DNAT --to 10.8.1.1:777
iptables -t nat -A PREROUTING -p tcp --dport 1122 -j DNAT --to 10.8.1.1:1122
iptables -t nat -A PREROUTING -p tcp --dport 1124 -j DNAT --to 10.8.1.1:1124
iptables -t nat -A PREROUTING -p tcp --dport 1604 -j DNAT --to 10.8.1.1:1604
iptables -t nat -A PREROUTING -p tcp --dport 3030 -j DNAT --to 10.8.1.1:3030
share|improve this answer
    
Thanks, this is what I was looking for! –  Niel Dec 26 '12 at 22:41
    
The other answer by Epaphus is better; it will allow you to find the commands for any other rules too. Of course, learning it properly is still even better though. –  fukawi2 Dec 27 '12 at 22:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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