Web Designing Company Singapore, Web Hosting Company, Custom Software Applications, eCommerce websites

Web Designing Company Singapore, Web Hosting Company, Custom Software Applications, eCommerce websites

OpenVPN + CSF configuration

1. Create new conf file as, /etc/sysctl.d/openvpn.conf

sudo nano /etc/sysctl.d/openvpn.conf

2. add content into it as,

net.ipv4.ip_forward = 1

Now time to add CSF firewall rules.

3. Create new SH file inside CSF folder,

sudo nano /etc/csf/csfpost.sh

4. Add below contents into it as,

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A FORWARD -o tun0 -j ACCEPT
iptables -A FORWARD -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT

5. Make the above file as 'Executable'

chmod +x /etc/csf/csfpost.sh

6. Now Disable & Enable the CSF by command,

csf -x && csf -e

7. Finally, better to reboot the whole server,

sudo reboot now