配置端口转发:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 10080
查看规则是否已成功配置:
iptables -t nat -nL --line
删除配置的规则-A变成-D
iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 10080
保存规则至配置文件:
iptables-save >/etc/iptables.conf
添加系统重启后自动恢复iptables规则任务:
echo '/sbin/iptables-restore < /etc/iptables.conf' >> /etc/rc.local
chmod 755 /etc/rc.local