make local only daemon listening on different interface (using iptables port forwarding)?

Posted by UniIsland on Server Fault See other posts from Server Fault or by UniIsland
Published on 2010-03-22T16:58:39Z Indexed on 2010/03/22 17:01 UTC
Read the original article Hit count: 378

i have a daemon program which listens on 127.0.0.1:8000.
i need to access it when i connect to my box with vpn.
so i want it to listen on the ppp0 interface too.

i've tried the "ssh -L" method. it works, but i don't think it's the right way to do that, having an extra ssh process running in the background.
i tried the "netcat" method. it exits when the connection is closed. so not a valid way for "listening".

i also tried several iptables rules. none of them worked.
i'm not listing here all the rules i've used.

iptables -A FORWARD -j ACCEPT
iptables -t nat -A PREROUTING -i ppp+ -p tcp --dport 8000 -j DNAT --to-destination 127.0.0.1:8000

the above ruleset doesn't work.
i have net.ipv4.ip_forward set to 1.

anyone knows how to redirect traffic from ppp interface to lo?
say, listen on "192.168.45.1:8000 (ppp0)" as well as "127.0.0.1:8000 (lo)"
there's no need to alter the port.

thanx

© Server Fault or respective owner

make local only daemon listening on different interface (using iptables port forwarding)?

Posted by UniIsland on Stack Overflow See other posts from Stack Overflow or by UniIsland
Published on 2010-03-22T16:47:53Z Indexed on 2010/03/22 16:51 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

i have a daemon program which listens on 127.0.0.1:8000.
i need to access it when i connect to my box with vpn.
so i want it to listen on the ppp0 interface too.

i've tried the "ssh -L" method. it works, but i don't think it's the right way to do that, having an extra ssh process running in the background.
i tried the "netcat" method. it exits when the connection is closed. so not a valid way for "listening".

i also tried several iptables rules. none of them worked.
i'm not listing here all the rules i've used.

iptables -A FORWARD -j ACCEPT
iptables -t nat -A PREROUTING -i ppp+ -p tcp --dport 8000 -j DNAT --to-destination 127.0.0.1:8000

the above ruleset doesn't work.
i have net.ipv4.ip_forward set to 1.

anyone knows how to redirect traffic from ppp interface to lo?
say, listen on "192.168.45.1:8000 (ppp0)" as well as "127.0.0.1:8000 (lo)"
there's no need to alter the port.

thanx

© Stack Overflow or respective owner

Related posts about iptables

Related posts about port-forwarding