LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-23-2011, 01:42 PM   #1
User-N@me
Member
 
Registered: May 2011
Distribution: Cent0S, Fedora, Ubuntu, Debian
Posts: 32

Rep: Reputation: 0
Question How to only allow OpenVPN connections with IPtables ?


Hello, I'd like to configure IPtables to make sure I can only access the internet through an openvpn connection (so when the connection is down I have no way to access the internet but to connect to the vpn again).

I know how to do this with Firestarter (restrictive outgoing policy and I only allow the vpn server IPs) but Firestarter seems to be stupid : for some reason eth0 was changed to eth1 and Firestarter can't work properly anymore, even though that probably can be fixed with Firestarter I'm no more interested in this program and I'd better like to know how to apply the same policy using IPtables.

I've tried a few things already but it failed each time ... how can I effectively allow my computer to connect to the VPN while everything else is blocked ?
 
Old 05-23-2011, 04:39 PM   #2
User-N@me
Member
 
Registered: May 2011
Distribution: Cent0S, Fedora, Ubuntu, Debian
Posts: 32

Original Poster
Rep: Reputation: 0
Question

Code:
iptables -A INPUT -s xx.xxx.xx.xx -j ACCEPT
iptables -A OUTPUT -d xx.xxx.xx.xx -j ACCEPT
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
Why isn't this working ? What should I add ?

Edit, oops I forgot :

Code:
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A OUTPUT -o tun+ -j ACCEPT
Silly me ...

Last edited by User-N@me; 05-23-2011 at 05:11 PM.
 
Old 05-23-2011, 07:06 PM   #3
User-N@me
Member
 
Registered: May 2011
Distribution: Cent0S, Fedora, Ubuntu, Debian
Posts: 32

Original Poster
Rep: Reputation: 0
Unhappy

Turns out the problem isn't solved, my current set of rules work when I activate them when I'm already connected to the VPN but it won't let me connect to the VPN if I load the rules at boot.

My rules :

Code:
# Generated by iptables-save v1.4.10 on Mon May 23 18:02:08 2011
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT 
-A INPUT -i tun+ -j ACCEPT 
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -s xx.xxx.xx.xx -j ACCEPT 
-A INPUT -j DROP 
-A OUTPUT -o tun+ -j ACCEPT 
-A OUTPUT -d xx.xxx.xx.xx -j ACCEPT 
-A OUTPUT -j DROP 
COMMIT
# Completed on Mon May 23 18:02:08 2011
What should I change ?
 
Old 05-25-2011, 05:13 AM   #4
User-N@me
Member
 
Registered: May 2011
Distribution: Cent0S, Fedora, Ubuntu, Debian
Posts: 32

Original Poster
Rep: Reputation: 0
*bump*
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow openvpn in IPTables jhmdev Linux - Networking 9 07-30-2009 02:48 PM
IPCop OpenVPN drops connections sdouglaspe Linux - Networking 0 03-27-2009 07:46 AM
OPENVPN /IPTABLES help woodson2 Fedora 2 11-07-2008 07:54 AM
OPENVPN /IPTABLES help woodson2 Linux - Networking 3 11-06-2008 02:10 PM
Slackware, openvpn and two wan connections! planoru Slackware 0 06-21-2007 09:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration