I am trying to setup an OpenVPN server on a VPS running Fedora Server 35. I got the VPN setup and working, but am running into issues with the firewall setup.
This is my first experience administering a firewall, and I'm not a Linux-native either, but I'm trying to learn. I followed a guide for a CentOS instance, but since CentOS is no longer, I opted for a Fedora image in Contabo.
The guide relied on firewalld, and since it was already installed and partly setup on my VPS, I did the same. I know that the firewalld is the issue because when I turn it off, VPN client connects without issues.
There are 2 active zones configured, FedoraServer and trusted. The FedoraServer zone came pre-configured with the VPS image, and it was setup as the default zone. I used the following commands to alter the configuration as per the guide:
firewall-cmd --zone=trusted --add-service openvpn
firewall-cmd --zone=trusted --add-service openvpn --permanent
firewall-cmd --add-masquerade
firewall-cmd --add-masquerade --permanent
VAR=$(ip route get 1.1.1.1 | awk 'NR==1 {print $(NF-2)}')
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -A POSTROUTING -s 10.8.0.0/24 -o $VAR -j MASQUERADE
firewall-cmd --reload
The current zone info is as follows:
[~]# firewall-cmd --info-zone=FedoraServer
FedoraServer (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
forward: no
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[~]# firewall-cmd --info-zone=trusted
trusted (active)
target: ACCEPT
icmp-block-inversion: no
interfaces: tun0
sources:
services: openvpn
ports:
protocols:
forward: yes
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
The interesting caveat is that when I set trusted as the default zone, I am able to connect to VPN with firewalld running, with NAT working and having Internet access.
Now, you could say problem solved. But due to my lack of knowledge I am concerned I might be leaving a hole in the security because the trusted zone uses target: ACCEPT.
I read countless threads on StackExchange, Fedora forums and OpenVPN forums, as well as firewalld docs to no awail. I feel I am missing underlying networking knowledge to figure this out, and I don't know what to search for anymore.
Any help, tips or guidance would be appreciated!