wireguard-install
wireguard-install copied to clipboard
iptable no work when server restart
my system is centos 7.6 64bit, after finished installation first, iptables works,
but no works when server restart, I need to manual run systemctl restart wg-iptables.service
.
so I change service file like below:
[Unit]
# here change to After
After=network.target nss-lookup.target
[Service]
# here simple use root user.
User=root
Type=oneshot
ExecStart=/usr/sbin/iptables -t nat -A POSTROUTING -s 10.7.0.0/24 ! -d 10.7.0.0/24 -j SNAT --to 10.0.0.11
ExecStart=/usr/sbin/iptables -I INPUT -p udp --dport 51820 -j ACCEPT
ExecStart=/usr/sbin/iptables -I FORWARD -s 10.7.0.0/24 -j ACCEPT
ExecStart=/usr/sbin/iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
ExecStop=/usr/sbin/iptables -t nat -D POSTROUTING -s 10.7.0.0/24 ! -d 10.7.0.0/24 -j SNAT --to 10.0.0.11
ExecStop=/usr/sbin/iptables -D INPUT -p udp --dport 51820 -j ACCEPT
ExecStop=/usr/sbin/iptables -D FORWARD -s 10.7.0.0/24 -j ACCEPT
ExecStop=/usr/sbin/iptables -D FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
```