Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to setup a multi machine VPN with the following characteristics:

  • 1 hub ( which is the base of the VPN
  • 20 users (
  • 5 administrators (

The first part, the hub and the 20 users, are working as I need. In this setup I need to:

  • Connect from the hub to every user
  • Connect from every user to the hub
  • Reject connection between users.

Plain vanilla OpenVPN configuration without using client-to-client.

Now I want to add the 5 administrators with some superpowers of connection. In this new setup I need to:

  • Connect from the administrators to the hub.
  • Connect from every administrator to every user (perhaps need to eventually restrict certain administrators to certain users).
  • Reject connection between users and administrators (except the ones originated from the administrators).
  • Reject connection between administrators.

I think that to get this granularity of control I need to enable the client-to-client in the server.conf. When doing this I already have users (170.0.0/16) and administrators ( talking. The problem is that I need to enforce the restrictions above. I'm sure that this should be an iptables problem but I've been trying for more hours that I care to admit and can't make it work. So far my iptables.conf looks like this:

:INPUT DROP [1000:900000]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 389 -j ACCEPT
-A INPUT -p udp -m udp --dport 1194 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -m icmp --icmp-type 13 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -m icmp --icmp-type 30 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT 
-A FORWARD -j REJECT --reject-with icmp-port-unreachable 

I think the forwards in the same subnet are the problem... but don't even know where to start.

share|improve this question
Why kind of services on the client end do you need to connect to? Is this something that could be addressed by running a proxy on your HUB and allowing only your administrators to access it and use it to connect to the clients? – Zoredache Jul 27 '10 at 1:37
I need to hit web pages on the user servers (I guess this could be done via a proxy on the hub) and I need to ssh into user servers. – rmarimon Jul 27 '10 at 2:37
up vote 1 down vote accepted

This could get rather complicated. The "client-to-client" option in OpenVPN simply shortcuts what otherwise can be accomplished with routing, so I would actually not use that at all, as it will give you more control.
When a client connects using OpenVPN, this effectively creates a tunnel with its own, 4-address-wide subnet. The lowest address is the network address, then you have one address each for the two sides and finally the broadcast address. So in that case enabling traffic flow from the administrators to the users, but not the other way around is a simple question of putting a rule like this in place:


This ensures that any traffic from the users back to the admins is only accepted if it is in response to a packet that came the other way. So that fixes that. You may need some routing rules, for this, too, but generally they should be put in place by the OpenVPN daemon automatically. Since you are still not using "client-to-client", admins can't see each other, either.
So far so good. The tricky bit now is to enable connections between some admins, but not others. For this you will probably have to establish pre-determined address allocations for each machine connecting to the VPN, and then put specific firewall rules in place to enable/disable traffic between them (based on the above as a template).

share|improve this answer
Worked perfectly. Except that I had to change the first rule to not accept new connections (-m state --state ESTABLISHED, RELATED). – rmarimon Jul 27 '10 at 14:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.