How to configure iptables for openvpn

By: Baby Meerkat | 1 Year | Syntax: Plain Text | Views: 213
URL http://paste.itunix.eu/view/003cb71c

  1. If you have installed the openvpn server and iptable is blocking the service by default then use these configurations for openvpn to function properly. First let's allow the tcp connection on the openvpn port. If you are using udp or another port number then change this line accordingly.
  2.  
  3. iptables -A INPUT -i eth0 -m state --state NEW -p udp --dport 1194 -j ACCEPT
  4.  
  5. Allow TUN interface connections to OpenVPN server
  6.  
  7. iptables -A INPUT -i tun+ -j ACCEPT
  8.  
  9. Allow TUN interface connections to be forwarded through other interfaces
  10.  
  11. iptables -A FORWARD -i tun+ -j ACCEPT
  12. iptables -A FORWARD -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  13. iptables -A FORWARD -i eth0 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT
  14.  
  15. NAT the VPN client traffic to the Internet. change the ip address mask according to your info of tun0 result while running "ifconfig" command.
  16.  
  17. iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  18.  
  19. If your default iptables OUTPUT value is not ACCEPT, you will also need a line like:
  20.  
  21. iptables -A OUTPUT -o tun+ -j ACCEPT
  22.  
  23. That's it now restart the iptables service and you are finished.

Reply to "How to configure iptables for openvpn"

Here you can reply to the paste above