greg wroteThere is a millions of script iptables for openvpn on internet but no one works
First: What are you trying to achieve (Tunneling, Networking, Remote access)? What architecture is your server on (Dedicated or VPS)?
IPTABLES can be configured to 'work' in just a few lines, but until you know your specific goals, then a specific config is not possible.
If you want a
simple tunnel, with security then I can show you a setup which definitely works:
https://forums.openvpn.net/topic7722.html
I wrote that for my self, and have used it many times -- so if it is a tunnel you want, then the code is there to use. If not tunnel, then do specify.
At the very core is this:
#
#Accept connections on 1194 for vpn access from clients
#Take note that the rule says "UDP", and ensure that your OpenVPN server.conf says UDP too
#
iptables -A INPUT -p udp --dport 1194 -j ACCEPT
#
#Apply forwarding for OpenVPN Tunneling
#
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT #10.8.0.0 ? Check your OpenVPN server.conf to be sure
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
#
#Enable forwarding
#
echo 1 > /proc/sys/net/ipv4/ip_forward
You NEED that. Everything else is optional.
If you do find you solution here, please to write back and share what it was.