davidjmorin

iptables setup for openvpn

Sep 7th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. iptables -A INPUT -i eth0 -m state --state NEW -p udp --dport 1194 -j ACCEPT
  2. Allow TUN interface connections to OpenVPN server
  3.  
  4. iptables -A INPUT -i tun+ -j ACCEPT
  5. Allow TUN interface connections to be forwarded through other interfaces
  6.  
  7. iptables -A FORWARD -i tun+ -j ACCEPT
  8. iptables -A FORWARD -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  9. iptables -A FORWARD -i eth0 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT
  10. NAT the VPN client traffic to the Internet. change the ip address mask according to your info of tun0 result while running "ifconfig" command.
  11.  
  12. iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  13. If your default iptables OUTPUT value is not ACCEPT, you will also need a line like:
  14.  
  15. iptables -A OUTPUT -o tun+ -j ACCEPT
  16. That's it now restart the iptables service and you are finished.
Advertisement
Add Comment
Please, Sign In to add comment