Use the firewall-cmd
command.
Assuming you're opening the firewall up to OpenVPN on the default zone, carry out the following commands. If you are running it on a non-default zone, then add --zone=<zone>
to the commands.
Note: If you use default public
zone for your external facing network adapter then your loopback interface could also be masqueraded (dependant on the version of firewalld
you're running) which can cause issues if you are running a service (such as mySQL) that is accessed locally.
First, list what's currently open:
# firewall-cmd --list-services
http https ssh
Next, add the openvpn
service:
# firewall-cmd --add-service openvpn
success
A quick check:
# firewall-cmd --list-services
http https openvpn ssh
The above will allow openvpn
to work, which you can now test. However, it won't last over restarts. To make it permanent, add the --permanent
option:
# firewall-cmd --permanent --add-service openvpn`
success
Note that this last command doesn't open the port until the next restart, so you need to use both commands.
Finally, add the masquerade:
# firewall-cmd --add-masquerade
success
And make it permanent after a restart:
# firewall-cmd --permanent --add-masquerade
success
Confirm it:
# firewall-cmd --query-masquerade
yes
Note that if your incoming OpenVPN connection is in a different zone to your Internet facing connection the masquerade should be on the latter and you'll need to use the --zone=<zone>
option with the --add-masquerade
commands.
/lib/firewalld/services/
. In your case, it will beopenvpn.xml
within that directory. User defined services go in/etc/firewalld/services
. Note that the default port for openvpn isUDP/1194
. – garethTheRed Mar 04 '16 at 07:24public
zone then it masquerades the loopback interface. It turns out that I'd previously set my default zone to beexternal
, so never faced the issue you're seeing. Try moving the services and the adapter to another zone to see if that helps. Let me know :-) – garethTheRed Mar 12 '16 at 07:47eth0
inexternal
with theopenvpn
service and masquerade enabled, andtun0
ininternal
. When I runfirewall-cmd --list-all-zones
there's no mention oflo
. – garethTheRed Mar 12 '16 at 08:06