How can I define separate roles for users and administrator in OpenVPN running on CentOS 7 server? Specifically, the users must only be allowed to https, while the administrator must be allowed to both https and ssh.


In translating the instructions from the link suggested by @garethTheRed, I have defined the following steps. I have also completed steps one, two, and three. But I do not know how to complete step four. Can someone please show how to translate STEP FOUR into firewalld from iptables, and also confirm the other steps?

Step One (COMPLETED): Create a virtual IP address map according to user class:

    Class            Virtual IP range       Allowed Services  
    employees            https
    administrator            ssh, https  

Step Two (COMPLETED): In /etc/openvpn/server.conf,

    define the Employee IP address pool:

    Add a route for the System Administrator IP range:

    Specify client configuration directory to assign a fixed IP forAdministrator:
    client-config-dir ccd

Step Three (COMPLETED): In a new directory /etc/openvpn/ccd and new config file /etc/openvpn/ccd/sysadmin:

    Define the fixed IP address for the Administrator VPN client:

        mkdir ccd
        cd ccd
        nano sysadmin1
        type the following into /etc/openvpn/ccd/sysadmin1:


    First, define a static unit number for our tun interface:

        dev tun0  //where does this go?

    Establish firewall rules for the employees and administrator (convert these to firewalld):
        # Employee rule // MUST ONLY BE ALLOWED TO https
        iptables -A FORWARD -i tun0 -s -d -j ACCEPT

        # Sysadmin rule //MUST BE ALLOWED TO ssh AND https
        iptables -A FORWARD -i tun0 -s -d -j ACCEPT

Note: When I type firewall-cmd --list-all, the sum total of the entire firewalld configuration so far is defined as follows:

public (default, active)
  interfaces: enp3s0
  services: dhcpv6-client openvpn smtp
  masquerade: yes
  rich rules: 

I would like to change the firewall configuration in any way required to provide optimal security for this use case.

How do I modify the above to get this working?


After reading @garethTheRed's helpful answer, I have three questions/observations:

1.) There is no `tun` device on the firewall, but yet I am able  
    to connect to the VPN from the client with  
    `openvpn --config /path/to/client.ovpn` with the firewall  
    configured only as shown by the results of `firewall-cmd --list-all`.
    So why is it necessary to define a `tun` device in the firewall?  

2.) `ip addr` shows that I was logged in as  How can I 
    force being logged in as a fixed address, such as defined  
    in Step Three above?  

3.) What privileges/access does a user really have when they log in to the  
    server via OpenVPN when the firewall is configured as shown in the  
    results of `firewall-cmd --list-all` above?  Are they be able to do  
    anything other than https without a password anyway?  ssh would  
    require knowledge of both a password and a username.  


In the internal zone defined in @garethTheRed's very helpful answer, it would seem that the users of the internal zone have access to the following services dhcpv6-client, ipp-client, mdns, samba-client, and ssh. The use case in this posting would also include https.

Therefore, it would seem that the solution to this posting would involve:

1.) setting up rules blocking the `` ip range from  
    `dhcpv6-client`, `ipp-client`, `mdns`, `samba-client`, and `ssh`,  
    while allowing access to `https`.  

2.) retaining access by the `` ip range to all services  
    defined in the internal zone.  

3.) creating and installing separate client certificates for the  
    two classes of users (administrator and user)? Each class,  
    and therefore each certificate, must have a Canonical Name (CN)  
    that matches the names of config files added to `/etc/openvpn/ccd`.  
    Openvpn should then use the config file whose name matches the CN.  
    This config file should be set to configure the network address  
    that will be allocated to the clients in that class
    @garethTheRed's words are used here in #3.  

But are these 3 things what are still required to complete this requirement? And how do I accomplish these 3 things?

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – terdon
    Feb 20, 2015 at 22:49
  • @terdon Please move these comments back to comments. This site does not allow me to log into chat no matter what I try. This is documented in a meta posting which still has not resolved the problem. Here is the link: meta.unix.stackexchange.com/questions/3405/cannot-log-into-chat
    – CodeMed
    Feb 20, 2015 at 23:02
  • @garethTheRed Since you mentioned the .ovpn files, I just added both of them to my OP. Does this help determine how to allow employees and administrators to use https inside OpenVPN?
    – CodeMed
    Feb 20, 2015 at 23:04
  • Ugh! Sorry, I had no idea. The system raises an automatic flag when there are more than X comments posted and we really try to avoid excessive comments. Unfortunately, I don't think I can bring them back but I'll see what I can do. On the bright side, an SE dev edited your question so presumably they're trying to fix it.
    – terdon
    Feb 20, 2015 at 23:05
  • No, I can't move them back. If I understand your meta post, you can read them but not answer. Is that correct? If not, I can copy them or take a screenshot if you need them for reference. I also tried super pinging you in chat, please let me know if 1) you got the notification and 2) if that let you log in.
    – terdon
    Feb 20, 2015 at 23:08

1 Answer 1


You could modify the zone and add a Rich Rule which blocks all ssh traffic other than from a certain range - the Employee subnet.

Find which zone your tun interface is in by listing all zones:

firewall-cmd --list-all-zones | less

In the output you should see something similar to:

internal (active)
  interfaces: tun0
  services: dhcpv6-client ipp-client mdns samba-client ssh
  masquerade: no
  rich rules:

You may find that the tun device (tun0 in the example above) is in the same zone as your ethernet adapter. While this will work, it will be easier to manage if you separate them.

It would be wise to remove the service that you don't need from the internal zone - in your case, remove all but ssh and also add http:

firewall-cmd --zone=internal --permanent --add-service=http
firewall-cmd --zone=internal --permanent --remove-service=dhcpv6-client

Repeat the last command with the other services you want to remove. Make sure you don't remove ssh! While you're at it, remove redundant services from your external zone too.

Copy the zone definition file from the zone where the tun interface is located to /etc/firewalld/zones. For example, if the tun device is in the Internal zone:

sudo cp /usr/lib/firewalld/zones/internal.xml /etc/firewalld/zones

Edit the copied file and add the following just before the closing </zone>:

<rule family="ipv4">
    <source invert="True" address=""/>
    <service name="ssh"/>

Finally, run firewall-cmd --reload to apply the rule.

Warning: You may lock yourself out if this doesn't work :-o

Alternative Options:

Another, simpler option, would be to configure sshd to only accept connections from a given network address -

An even simpler option would be to abandon the VPN altogether and only use the firewall. If (and only if) your employees (or your external router) have a static IP address then simply configure Rich Rules to allow only their IP address or network address to reach the ssh service while rejecting all other IP addresses.

  • Thank you. Please see the EDIT at the end of my OP with follow up questions.
    – CodeMed
    Feb 19, 2015 at 19:47
  • This is working in my CentOS 7 devbox. Thank you and +1. But I am having trouble setting up a way for non-technical windows users to use a GUI to login to the VPN and then https through the vpn. I made another posting for that problem. Are you willing to help me with it? Sorry for so many follow ups. I am learning this as I am going, and clear instructions seem scarce. Here is the link: serverfault.com/questions/670320/…
    – CodeMed
    Feb 21, 2015 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .