• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3135
  • Last Modified:

Port forwarding

Hi all,

I've set port forwarding up on my debian box using:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.0.2:80
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -i eth0 -j ACCEPT

and it works fine until I do a reboot. How can I get my ports to survive a reboot?

Thanx in advance

Mk
0
onlinede
Asked:
onlinede
  • 3
  • 2
2 Solutions
 
http:// thevpn.guruCommented:
Use

iptables-save
0
 
http:// thevpn.guruCommented:
0
 
onlinedeAuthor Commented:
iptables-save did not work :(

Have you got any other suggestions?

Mk
0
WatchGuard 2018 Security Predictions Webinar!

2017 was another scary year for cyber security. Moving into 2018, what new challenges could lay ahead? Join WatchGuard CTO Corey Nachreiner and his security panel on January 9th for an exciting, interactive discussion on the upcoming year in cyber security.

 
http:// thevpn.guruCommented:
Yeah put those in a script and add it to startup. What went wrong with iptables-save
0
 
onlinedeAuthor Commented:
Me! I didn't read the tutorial correctly. Got that working now how ever your right I do need to put those in to a script and add it to start up.

How do I do that?

Cheers

Mk
0
 
nmvCommented:
Create a new file named /etc/init.d/local with the following content:

#!/bin/sh
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.0.2:80
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -i eth0 -j ACCEPT
#put other manual startup stuff here

Then, make the file executable:

chmod 755 /etc/init.d/local

Add it to startup:

update-rc.d local defaults 80

And that should be it!
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now