openvpn-install icon indicating copy to clipboard operation
openvpn-install copied to clipboard

After rebooting the server, OpenVPN is not working.

Open gagangupta1404 opened this issue 2 years ago • 4 comments

Hello Team,

I have configured OpenVPN on my Ubuntu server, and everything is going fine, but when my server restarts, our vpn clients are not able to access the internet, although the VPN is still connected.

gagangupta1404 avatar Feb 10 '23 12:02 gagangupta1404

same

mindcont avatar Mar 12 '23 02:03 mindcont

check it out iptables masquerading rules and IP forwarding

root@tf-ovpnxortcp-radius-blr1-5:/home/chip$ iptables-save | grep MASQUERADE
-A POSTROUTING -s 192.168.255.0/24 -o eth0 -j MASQUERADE
-A POSTROUTING -s 192.168.254.0/24 -o eth0 -j MASQUERADE

and

root@tf-ovpnxortcp-radius-blr1-5:/home/chip$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

so, my sysctl config

cat > /etc/sysctl.d/ovpnxor.conf <<EOF
net.ipv4.ip_forward = 1
net.ipv4.ip_no_pmtu_disc = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.SERVER_PUB_NIC.disable_ipv6 = 1
EOF

CHIP0K avatar Mar 14 '23 16:03 CHIP0K

Hi, @gagangupta1404 @mindcont . I had the same issue. Edit /etc/systemd/system/iptables-openvpn.service and change line Before=network-online.target to After=network-online.target. Save the file, reboot and check.

wid-get avatar Mar 29 '23 18:03 wid-get

@wid-get that's odd - on Debian Bullseye it works with Before=network-online.target , after every reboot all iptables and ip6tables rules are loaded fine. Wonder if it's something platform dependent?

gits7r avatar Jun 06 '23 21:06 gits7r