Advertisement
Guest User

Setting up openvpn as non default

a guest
Nov 14th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. # start vpn in background with automatic routing disabled
  2. sudo openvpn --config /etc/openvpn/CA\ Vancouver.ovpn --daemon --pull-filter ignore redirect-gateway
  3.  
  4. # run this then change the values below
  5. sudo nano /etc/sysctl.conf
  6.  
  7. net.ipv4.ip_forward = 1             # Enable IP Forwarding
  8. net.ipv4.conf.default.rp_filter = 0 # Disable Source Route Path Filtering
  9. net.ipv4.conf.all.rp_filter = 0     # Disable Source Route Path Filtering on All interfaces
  10.  
  11. # execute this to reload config
  12. sudo sysctl -p /etc/sysctl.conf
  13.  
  14. # Set interface values
  15. INTERNET_IFACE=enp2s0
  16. VPN_IFACE=eth0
  17.  
  18. # Enable masquerading
  19. sudo iptables -A FORWARD -i "$INTERNET_IFACE" -j ACCEPT
  20. sudo iptables -t nat -A POSTROUTING -o "$INTERNET_IFACE" -j MASQUERADE
  21.  
  22. # Forward the vpn to internet
  23. sudo iptables -A FORWARD -i "$INTERNET_IFACE" -o "$VPN_IFACE" -j ACCEPT
  24. sudo iptables -A FORWARD -i "$VPN_IFACE" -o "$INTERNET_IFACE" -m state --state RELATED,ESTABLISHED -j ACCEPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement