Masquerading on local ports
Hi everyone - this is my first post to this list - so if anything is wrong with my way of posting please tell.
And here is the question. How is it possible to nat a lokal port?
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refused
Henry
Quoted 7 lines
And here is the question. How is it possible to nat a lokal port?
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refused
iptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 81
Rob
Am Don, 2003-03-20 um 16.29 schrieb Rob Sterenborg:
Quoted 5 lines
Quoted 5 lines
And here is the question. How is it possible to nat a lokal port?
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
Quoted 8 lines
Quoted 2 lines
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refusediptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 81
Rob
Tanks for the answer,
I tried that one already but it behaves the same.
I also tried
IPTABLES -t nat -A PREROUTING -p tcp -d 172.16.172.12 --destination-port 81 -j REDIRECT --to-ports 80
wich works perfect for both port 80 and 81 from a foreign host.
Henry
Am Don, 2003-03-20 um 16.29 schrieb Rob Sterenborg:
Quoted 5 lines
Quoted 5 lines
And here is the question. How is it possible to nat a lokal port?
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
Quoted 8 lines
Quoted 2 lines
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refusediptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 81
Rob
Tanks for the answer,
I tried that one already but it behaves the same.
I also tried
IPTABLES -t nat -A PREROUTING -p tcp -d 172.16.172.12 --destination-port 81 -j REDIRECT --to-ports 80
wich works perfect for both port 80 and 81 from a foreign host.
Henry
This one works for me:
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 81 \
-j REDIRECT --to-ports 80Alex
Cópia Henry Ritzlmayr <[email protected]>:
Quoted 29 lines
Am Don, 2003-03-20 um 16.29 schrieb Rob Sterenborg:
Quoted 9 lines
Quoted 7 lines
And here is the question. How is it possible to nat a lokal port?
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refusediptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 80 -j
REDIRECT
Quoted 4 lines
--to-ports 81
Rob
Tanks for the answer,
I tried that one already but it behaves the same.
I also triedIPTABLES -t nat -A PREROUTING -p tcp -d 172.16.172.12 --destination-port
81 -j REDIRECT --to-ports 80wich works perfect for both port 80 and 81 from a foreign host.
Henry
Quoted 5 lines · Henry Ritzlmayr
Hi everyone - this is my first post to this list - so if anything is wrong with my way of posting please tell.
And here is the question. How is it possible to nat a lokal port?
Quoted 7 lines
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refusedHenry
Packets originating on the local box never go through the PREROUTING chains. This is why there is an OUTPUT chain in the nat table. (and the mangle table)
iptables -t nat -A OUTPUT -o lo -p tcp --dport 81 -j DNAT --to 127.0.0.1:80
should do it. I'm not sure if the REDIRECT target would work properly for this use (localhost->localhost), but you can try easily enough.
j
Am Fre, 2003-03-21 um 08.22 schrieb Joel Newkirk:
Quoted 18 lines · Henry Ritzlmayr
Quoted 5 lines
Hi everyone - this is my first post to this list - so if anything is wrong with my way of posting please tell.
And here is the question. How is it possible to nat a lokal port?
Quoted 7 lines
IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port 81 -j DNAT --to-destination 127.0.0.1:80
telnet localhost 80 <<< works
telnet localhost 81 <<< Connection refusedHenry
Packets originating on the local box never go through the PREROUTING chains. This is why there is an OUTPUT chain in the nat table. (and the mangle table)
Quoted 7 lines
iptables -t nat -A OUTPUT -o lo -p tcp --dport 81 -j DNAT --to 127.0.0.1:80
should do it. I'm not sure if the REDIRECT target would work properly for this use (
localhost->localhost), but you can try easily enough.j
That was it. I overlooked that local packets do not go trough the PREROUTING.
thanks for the help
Henry