Page 1 of 1

forward ports in iptables

Posted: Wed Jul 07, 2010 8:56 pm
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

Re: forward ports in iptables

Posted: Wed Jul 07, 2010 9:36 pm
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.