开发者

iptables redirect local cennections

I used

iptables -A PREROUTI开发者_开发百科NG -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 8085

to redirect all http requests to jboss server on port 8085. This works fine if packets come from outside. If I try to open from the same machine it doesnt work. Telnet gives connection refused.

How do I redirect local connections?

Working on centos, kernel 2.6.18 x64


local generated packets does not income on eth0. you have to do this:

iptables -t nat -A OUTPUT --src 0/0 --dst 127.0.0.1. -p tcp --dport 80 -j REDIRECT --to-ports 8085

and

To redirect locally generated packets, you must have the kernel option CONFIG_IP_NF_NAT_LOCAL set to Y

from: http://wiki.debian.org/Firewalls-local-port-redirection


Also to allow forward just run the command

sysctl -w net.ipv4.ip_forward=1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜