forward ports in iptables

Post Reply
mister_v
Posts: 139
Joined: Sat Jun 20, 2009 5:42 pm

forward ports in iptables

Post by mister_v »

Hi,

Is there an easy way to create a forward port to another machine and the delete it after a few minutes?

I don't want to leave it open.

Thanks for the help
Chris
Site Admin
Posts: 129
Joined: Mon Jul 21, 2008 9:45 am
Location: Leuven, Belgium
Contact:

Re: forward ports in iptables

Post by Chris »

You can easily create a forward port with the following command:

Code: Select all

iptables -t nat -A PREROUTING -p tcp --dport 8080 -i eth0 -j DNAT --to 192.168.1.1:80
The following command list all the forward rules the

Code: Select all

iptables -t nat -L PREROUTING -n --line-numbers
This command delete the second rule:

Code: Select all

iptables -D PREROUTING 2 -t nat
This should do what you ask.
It is easy and quick.
Post Reply