iptables 端口映射 80 to 8080
linux 1024以下的端口只能由root用户开启,所以会导致一些不安全因素,可以把1024以下的端口通过iptables端口映射到其他端口就可以使用非root用户启动程序监听80了,呵呵
编辑文件/ect/sysctl.conf 打开端口映射
net.ipv4.ip_forward = 1
然后使用命令
# iptables -t mangle -I PREROUTING -p tcp --dport 80 -j MARK --set-mark 8888
# iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
# iptables -I INPUT -p tcp --dport 8080 -m mark --mark 8888 -j ACCEPT
# service iptables save
# service iptables restart
ok,服务器又安全了许多.