Skip to content

Instantly share code, notes, and snippets.

@hydrz
Last active November 20, 2019 04:00
Show Gist options
  • Save hydrz/00737303584745b3ff127a57edad5237 to your computer and use it in GitHub Desktop.
Save hydrz/00737303584745b3ff127a57edad5237 to your computer and use it in GitHub Desktop.
#!/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