From 2c9701d477ca983fd7287ee975f80589139f22f5 Mon Sep 17 00:00:00 2001 From: Angristan Date: Tue, 4 Oct 2016 17:34:11 +0200 Subject: [PATCH] Better way to enable IP forwarding https://github.com/Nyr/openvpn-install/commit/791c54786c2cb2f6500e20f931b33fbb234a8ce4?diff=unified --- openvpn-install.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 9a31820..da1ee94 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -367,15 +367,9 @@ crl-verify crl.pem tls-server tls-auth tls-auth.key 0" >> /etc/openvpn/server.conf # Enable net.ipv4.ip_forward for the system - if [[ "$OS" = 'debian' ]]; then - sed -i 's|#net.ipv4.ip_forward=1|net.ipv4.ip_forward=1|' /etc/sysctl.conf - else - # CentOS 5 and 6 - sed -i 's|net.ipv4.ip_forward = 0|net.ipv4.ip_forward = 1|' /etc/sysctl.conf - # CentOS 7 - if ! grep -q "net.ipv4.ip_forward=1" "/etc/sysctl.conf"; then - echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf - fi + sed -i '/\/c\net.ipv4.ip_forward=1' /etc/sysctl.conf + if ! grep -q "\" /etc/sysctl.conf; then + echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf fi # Avoid an unneeded reboot echo 1 > /proc/sys/net/ipv4/ip_forward