-
-
Save hydrz/00737303584745b3ff127a57edad5237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 开启转发 | |
echo 'net.ipv4.ip_forward=1' >/usr/lib/sysctl.d/20-forward.conf | |
sysctl -p | |
# 指定外网 IP | |
# iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j SNAT --to-source 192.168.0.1 | |
# 内网段 | |
iptables -t nat -I POSTROUTING -s 192.168.0.0/16 -j MASQUERADE | |
iptables -t filter -A FORWARD -s 192.168.0.0/16 -j ACCEPT | |
iptables -t filter -A FORWARD -d 192.168.0.0/16 -j ACCEPT | |
# 保存 iptables | |
yum -y install systemd-devel iptables-services | |
iptables-save >/etc/sysconfig/iptables | |
systemctl --now mask firewalld 2>/dev/null | |
systemctl enable iptables 2>/dev/null | |
systemctl restart iptables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment