转发网关,依旧是LINUX好用,记CentOS 8.0 X64
分类:传奇三私服 阅读:1081 日期:2024-11-14 |
转发网关,依旧是LINUX好用,记CentOS 8.0 X64
安装 iptables yum install iptables-services 停止 iptables service iptables stop 打开 iptables echo 1 > /proc/sys/net/ipv4/ip_forward 编辑 iptables -A PREROUTING -p tcp -m tcp --dport 8001:9000 -j DNAT --to-destination 8.8.8.8 -A PREROUTING -p tcp -m tcp --dport 9001:9009 -j DNAT --to-destination 4.4.4.4 -A PREROUTING -p tcp -m tcp --dport 9010 -j DNAT --to-destination 4.4.4.4:9521 -A POSTROUTING -d 8.8.8.8/32 -p tcp -m tcp --dport 8001:9000 -j MASQUERADE -A POSTROUTING -d 4.4.4.4/32 -p tcp -m tcp --dport 9001:9009 -j MASQUERADE -A POSTROUTING -d 4.4.4.4/32 -p tcp -m tcp --dport 9521 -j MASQUERADE ESC键 :wq 回车 保存 iptables service iptables save 启动 iptables service iptables restart 查看 iptables cat /etc/sysconfig/iptables 开机自启 systemctl enable iptables.service 老版本开机自启 service iptables on 关闭firewalld防火墙 systemctl stop firewalld.service systemctl disable firewalld.service 以下为自启动 利用echo 1 修改 echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.d/rc.local \ && echo 1 > /proc/sys/net/ipv4/ip_forward \ && chmod +x /etc/rc.d/rc.local \ && ll /etc/rc.d/rc.local \ && cat /proc/sys/net/ipv4/ip_forward 利用sysctl 修改 echo "sysctl -w net.ipv4.ip_forward=1" >> /etc/rc.d/rc.local \ && echo "sysctl -p" >> /etc/rc.d/rc.local \ && chmod +x /etc/rc.d/rc.local \ && ll /etc/rc.d/rc.local \ && cat /proc/sys/net/ipv4/ip_forward 测试:重启生效 |
下一篇:Windows 端口转发 Linux 端口转发