神器iptables出场,设置将80端口转发到8080端口,/etc/hosts绑定本地到日常的域名也可以通过80端口自动转发,方便。
-------------------------------------------------------------------
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080如果不需要转发了,通过以下命令清除设置
iptables -t nat -F PREROUTING iptables -t nat -F OUTPUT如果要保存iptables的设置以便重启后生效,可以参考这里
-------------------------------------------------------------------
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 这条命令很有用。
比如这个例子-http://briteming.blogspot.com/2013/03/pptp-vpn_4.html
类似的命令: http://briteming.blogspot.co.uk/2012/12/iptables-nat.html
------------------------------------
you can specify an iptables rule to direct incoming tcp requests on port 80 to port 8080. Assuming you have iptables installed the command you need is: iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 This will redirect traffic on all interfaces so if you’re doing some other stuff with the local loopback that might break. You can also specify an interface in the rule as follows: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 This will only do the redirect for traffic on the eth0 interface.