Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenVPN and iptables firewall rules [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
deboeck
Tux's lil' helper
Tux's lil' helper


Joined: 13 Jan 2004
Posts: 92

PostPosted: Mon Jan 16, 2006 4:20 pm    Post subject: OpenVPN and iptables firewall rules [SOLVED] Reply with quote

Hi,

I'm running an OpenVPN server to which different clients connect. When starting the OpenVPN service on the server, I use the 'up' parameter in the openvpn config file to add some rules to my firewall. The rules do the following:

1) Open the VPN port (1194) on my external interface.
2) Define which traffic is allowed through the created TUN interface.

This works fine. However, when shutting down the OpenVPN service, I'd like these rules to be removed. I tried doing this using the 'down' parameter, but it doesn't work because OpenVPN is running as user nobody. The results is that the rules are still present. When starting OpenVPN again, they are added a second time.

I thought of the following solutions to solve this problem:

1) Run OpenVPN as root. Last resort really, seems like a bad idea.
2) Create a new user openvpn, let OpenVPN run as that user and use sudo so the user can execute my firewall script as root. Anyone using this approach ?
3) Modify the /etc/init.d/openvpn script to add and remove the firewall rules.

Anyone else having this problem ? Suggestions are very welcome :-)

Steven


Last edited by deboeck on Tue Jan 17, 2006 4:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
tuxmin
l33t
l33t


Joined: 24 Apr 2004
Posts: 838
Location: Heidelberg

PostPosted: Mon Jan 16, 2006 7:11 pm    Post subject: Reply with quote

As you resumed: #1 is a bad idea


I'd go for #3. One suggestion though: you could create a chain for your openvpn rules, then, upon startup simply flush/delete that chain first and insert your rules again. This would prevent the rules from multiplying.

Hth, Alex!!!
_________________
ALT-F4
Back to top
View user's profile Send private message
deboeck
Tux's lil' helper
Tux's lil' helper


Joined: 13 Jan 2004
Posts: 92

PostPosted: Tue Jan 17, 2006 4:54 pm    Post subject: @Alex Reply with quote

Thanks for the answer. I've already gone for solution 2 :-) Seems to be working. Putting the VPN rules in a chain is a good idea though, thanks for that one.

Steven
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum