feat: add IPv4 support for WireGuard configuration
Updated configuration script to include IPv4 rules alongside existing IPv6 rules for iptables. This ensures that both protocols are properly handled, enhancing network versatility and compatibility. Enabled IPv4 forwarding in sysctl to support the new rules.
This commit is contained in:
parent
e192076414
commit
b47e81791d
1 changed files with 7 additions and 3 deletions
10
worker.py
10
worker.py
|
@ -313,14 +313,17 @@ PersistentKeepalive = {persistent_keepalive}
|
||||||
ssh_execute_command(server_ip, f"echo '{wg_config}' > /etc/wireguard/wg0.conf")
|
ssh_execute_command(server_ip, f"echo '{wg_config}' > /etc/wireguard/wg0.conf")
|
||||||
ssh_execute_command(server_ip, "wg-quick up wg0")
|
ssh_execute_command(server_ip, "wg-quick up wg0")
|
||||||
|
|
||||||
# Configure ip6tables
|
# Configure ip(6)tables
|
||||||
ip6tables_rules = [
|
iptables_rules = [
|
||||||
"ip6tables -A FORWARD -i wg0 -j ACCEPT",
|
"ip6tables -A FORWARD -i wg0 -j ACCEPT",
|
||||||
"ip6tables -A FORWARD -o wg0 -j ACCEPT",
|
"ip6tables -A FORWARD -o wg0 -j ACCEPT",
|
||||||
"ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE",
|
"ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE",
|
||||||
|
"iptables -A FORWARD -i wg0 -j ACCEPT",
|
||||||
|
"iptables -A FORWARD -o wg0 -j ACCEPT",
|
||||||
|
"iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE",
|
||||||
]
|
]
|
||||||
|
|
||||||
for rule in ip6tables_rules:
|
for rule in iptables_rules:
|
||||||
ssh_execute_command(server_ip, rule)
|
ssh_execute_command(server_ip, rule)
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,6 +363,7 @@ def main(provider, location, server_type):
|
||||||
"apt update",
|
"apt update",
|
||||||
"apt install -y wireguard",
|
"apt install -y wireguard",
|
||||||
"echo 'net.ipv6.conf.all.forwarding=1' >> /etc/sysctl.conf",
|
"echo 'net.ipv6.conf.all.forwarding=1' >> /etc/sysctl.conf",
|
||||||
|
"echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf",
|
||||||
"sysctl -p",
|
"sysctl -p",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue