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 06-04-2010, 06:48 PM   #1
ajayan
Member
 
Registered: Dec 2007
Posts: 89

Rep: Reputation: 16
Allowing IPSec/L2TP in Iptables


Hi all I had configured IPSEC/L2Tp on my Centos 5.4 gateway machine .For testing i had disabled firewall and Ipsec is working fine.I am able to connect from client etc...Now i want to allow Ipsec and l2tp throught Firewall.here is my Current Working Firewall.Only Openvpn is allowed and is Redirected.

#######################################################################
eth0=XXXSTATICIPXXX
eth1=192.168.1.81
OpenVpn IP Range = 172.24.0.16/4
Ipsec Ip Range = 192.168.1.0/24

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A INPUT -i eth1 -j ACCEPT
iptables -A OUTPUT -o eth1 -j ACCEPT
iptables -A OUTPUT -s 192.168.1.0/24 -o eth0 -j ACCEPT

iptables -A INPUT -i tun0 -j ACCEPT
iptables -A OUTPUT -s 172.24.0.0/16 -o eth0 -j ACCEPT

iptables -A FORWARD -i eth1 -s 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -o eth1 -d 192.168.1.0/24 -j ACCEPT

iptables -A FORWARD -i tun+ -j ACCEPT

iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT

iptables -A FORWARD -p icmp -s XXXSTATICIPXXX -j ACCEPT
iptables -A FORWARD -p icmp -d XXXSTATICIPXXX -j ACCEPT

iptables -A FORWARD -s XXXSTATICIPXXX -j ACCEPT

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to-source XXXSTATICIPXXX
iptables -t nat -A POSTROUTING -s 172.24.0.0/16 -o eth0 -j SNAT --to-source XXXSTATICIPXXX
iptables -t nat -A PREROUTING -i eth1 -d XXXSTATICIPXXX -j ACCEPT
iptables -t nat -A PREROUTING -i tun0 -d XXXSTATICIPXXX -j ACCEPT
iptables -t nat -A PREROUTING -i lo -d XXXSTATICIPXXX -j ACCEPT

iptables -t nat -A PREROUTING -p udp --dport 1194 -j DNAT --to 192.168.1.120
iptables -A FORWARD -s 192.168.1.120 -p udp --dport 1194 -j ACCEPT

iptables -A INPUT -i eth0 -p udp --dport 1194 -j ACCEPT

iptables -A OUTPUT -s 192.168.1.0/24 -o eth0 -j ACCEPT
iptables -A OUTPUT -s XXXSTATICIPXXX -o eth0 -j ACCEPT
iptables -A OUTPUT -s 172.24.0.0/16 -o eth0 -j ACCEPT

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -N LOGDROP
iptables -A LOGDROP -j LOG
iptables -A LOGDROP -j DROP
iptables -A INPUT -j LOGDROP
########################################################################

Now i had added the following rules to allow IPSec/L2TP Access.

iptables -A INPUT -i eth0 -p udp --dport 1701 -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
iptables -A INPUT -i eth0 -p esp -j ACCEPT
iptables -A OUTPUT -o ppp+ -j ACCEPT
iptables -A FORWARD -o ppp+ -j ACCEPT
iptables -A FORWARD -i ppp+ -j ACCEPT
iptables -A INPUT -i ppp+ -j ACCEPT

But i am not able to Connect to IPSec/L2TP.Even i cant Connect IPSec though.How can i resolve the Issue.

Advance Thanks.
Ajayan

Last edited by ajayan; 06-04-2010 at 06:50 PM.
 
Old 06-05-2010, 09:21 AM   #2
Jerre Cope
Member
 
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
I use Shorewall to build my firewalls. It particularly handles ipsec tunnels in a way that is easy to read (better able to verify you didn't open more than you should). The perl version is very fast. I mostly use ssh tunneling now, but at one time I had 25 or more ipsec tunnels defined.
 
  


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
Setting up L2TP over IPSec VPN server under CentOS 5.3 fantasygoat Linux - Networking 6 01-12-2016 03:41 AM
IPSEC with L2TP in linux shesha_gp Linux - Server 4 04-29-2010 09:11 AM
L2TP/IPSec/openswan server for iphone help ShadowHywind Linux - Server 3 01-25-2010 04:31 PM
IPSec/L2TP mahesh_sonawane Linux - Networking 1 06-04-2007 01:32 AM
IPsec/L2TP VPN question IPsecLearner Linux - Networking 3 04-19-2005 11:32 AM

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

All times are GMT -5. The time now is 12:49 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