mirror of
https://github.com/angristan/wireguard-install.git
synced 2024-10-31 18:52:31 +00:00
Update wireguard-install.sh
Co-Authored-By: Stanislas <angristan@pm.me>
This commit is contained in:
parent
3ad36b0f90
commit
77be3cf171
@ -126,17 +126,13 @@ Address = $SERVER_WG_IPV4/24,$SERVER_WG_IPV6/64
|
|||||||
ListenPort = $SERVER_PORT
|
ListenPort = $SERVER_PORT
|
||||||
PrivateKey = $SERVER_PRIV_KEY" > "/etc/wireguard/$SERVER_WG_NIC.conf"
|
PrivateKey = $SERVER_PRIV_KEY" > "/etc/wireguard/$SERVER_WG_NIC.conf"
|
||||||
|
|
||||||
# Add iptables rules
|
|
||||||
if [[ "$OS" != 'fedora' ]]; then
|
|
||||||
echo "PostUp = iptables -A FORWARD -i $SERVER_WG_NIC -j ACCEPT; iptables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE; ip6tables -A FORWARD -i $SERVER_WG_NIC -j ACCEPT; ip6tables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE
|
|
||||||
PostDown = iptables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT; iptables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE; ip6tables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT; ip6tables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE" >> "/etc/wireguard/$SERVER_WG_NIC.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add firewalld rules
|
|
||||||
if [[ "$OS" = 'fedora' ]]; then
|
if [[ "$OS" = 'fedora' ]]; then
|
||||||
FIREWALLD_ADDRESS=$(echo $SERVER_WG_IPV4 | cut -d"." -f1-3)".0"
|
FIREWALLD_ADDRESS=$(echo $SERVER_WG_IPV4 | cut -d"." -f1-3)".0"
|
||||||
echo "PostUp = firewall-cmd --add-port $SERVER_PORT/udp && firewall-cmd --add-rich-rule='rule family=ipv4 source address=$FIREWALLD_ADDRESS/24 masquerade'
|
echo "PostUp = firewall-cmd --add-port $SERVER_PORT/udp && firewall-cmd --add-rich-rule='rule family=ipv4 source address=$FIREWALLD_ADDRESS/24 masquerade'
|
||||||
PostDown = firewall-cmd --remove-port $SERVER_PORT/udp && firewall-cmd --remove-rich-rule='rule family=ipv4 source address=$FIREWALLD_ADDRESS/24 masquerade'" >> "/etc/wireguard/$SERVER_WG_NIC.conf"
|
PostDown = firewall-cmd --remove-port $SERVER_PORT/udp && firewall-cmd --remove-rich-rule='rule family=ipv4 source address=$FIREWALLD_ADDRESS/24 masquerade'" >> "/etc/wireguard/$SERVER_WG_NIC.conf"
|
||||||
|
else
|
||||||
|
echo "PostUp = iptables -A FORWARD -i $SERVER_WG_NIC -j ACCEPT; iptables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE; ip6tables -A FORWARD -i $SERVER_WG_NIC -j ACCEPT; ip6tables -t nat -A POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE
|
||||||
|
PostDown = iptables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT; iptables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE; ip6tables -D FORWARD -i $SERVER_WG_NIC -j ACCEPT; ip6tables -t nat -D POSTROUTING -o $SERVER_PUB_NIC -j MASQUERADE" >> "/etc/wireguard/$SERVER_WG_NIC.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the client as a peer to the server
|
# Add the client as a peer to the server
|
||||||
|
Loading…
Reference in New Issue
Block a user