PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : HILFE: iptables drop VPN pakete



Thomas Harlos
03.04.02, 16:57
Hi leute,
habe ein großes problem.
Ich haben zwei linux-router, kernel 2.4.17, mit freeswan 1.94.
Als firewall verwende ich iptables.

1. Der VPN tunnel wird einwandtfrei gestartet.

less /var/log/syslog
ipsec_setup: Starting FreeS/WAN IPsec 1.94...
ipsec_setup: KLIPS debug `all'
ipsec_setup: KLIPS ipsec0 on eth0 x.x.x.x/255.255.255.0 broadcast 1.0.2.255
ipsec__plutorun: Starting Pluto subsystem...
ipsec_setup: ...FreeS/WAN IPsec started


ipsec eroute
0 192.168.42.0/24 -> 192.168.11.0/24 => tun0x1004@217.225.125.9

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 ipsec0
192.168.11.0 x.x.x.254 255.255.255.0 UG 0 0 0 ipsec0
192.168.42.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 x.x.x.254 0.0.0.0 UG 1 0 0 eth0
Das routing scheint auch zustehen, aber ich bekomme einfach keine Pakete durch den Tunnel geschickt.

2. Der firewall läuft auch soweit.

#!/bin/sh

LAN_IP="192.168.42.165"
LAN_IP_NET="192.168.42.0/24"
LAN_BCAST_ADRESS="192.168.42.255"
LAN_IFACE="eth1"

# Internet
INET_IP="x.x.x.x"
INET_BCAST_ADRESS="x.x.x.255"
INET_IFACE="eth0"

# loopback-device
LO_IFACE="lo"
LO_IP="127.0.0.1"

# ipsec-device
IPSEC="ipsec0"

any="0.0.0.0/0"

IPTABLES="/usr/sbin/iptables"

# Setzen von Kernel-Variablen
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "0" > /proc/sys/net/ipv4/conf/ipsec0/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth0/rp_filter
# loeschen aller Regeln
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -X

# setzen der Default policies
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD DROP


# loopback interface erlauben
$IPTABLES -A OUTPUT -o lo -j ACCEPT
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A FORWARD -o lo -j ACCEPT
$IPTABLES -A FORWARD -i lo -j ACCEPT

# nat masquerading
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -s $LAN_IP_NET -j MASQUERADE

# udp port 500 freischalten
$IPTABLES -A INPUT -p udp -i $INET_IFACE --sport 500 --dport 500 -j ACCEPT
$IPTABLES -A OUTPUT -p udp -o $INET_IFACE --sport 500 --dport 500 -j ACCEPT

# Protokoll 50 und 51 freischalten
# ESP encryption
$IPTABLES -A INPUT -p 50 -j ACCEPT
$IPTABLES -A OUTPUT -p 50 -j ACCEPT

#
# AH authentication
$IPTABLES -A INPUT -p 51 -j ACCEPT
$IPTABLES -A OUTPUT -p 51 -j ACCEPT

#
# ssh freischalten
$IPTABLES -A INPUT -p TCP -i $INET_IFACE --dport 22 -j ACCEPT

################################################## ###########################
# IPsec
#
$IPTABLES -A INPUT -i $IPSEC -j ACCEPT
$IPTABLES -A OUTPUT -o $IPSEC -j ACCEPT
$IPTABLES -A FORWARD -i $IPSEC -j ACCEPT
$IPTABLES -A FORWARD -o $IPSEC -j ACCEPT

#
# tcp und udp aus dem eigenen Netz sind erlaubt
$IPTABLES -A INPUT -p tcp -s $LAN_IP_NET -j ACCEPT$IPTABLES -A INPUT -p udp -s $LAN_IP_NET -j ACCEPT

# DNS ist auch erlaubt
$IPTABLES -A INPUT -p udp --sport 53 -j ACCEPT

# icmp ist erlaubt
$IPTABLES -A INPUT -p icmp -i $INET_IFACE -s $any -j ACCEPT

# Pakete aus dem eigenen Netz werden geroutet
$IPTABLES -A FORWARD -s $LAN_IP_NET -j ACCEPT

iptables -L -n
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:500 dpt:500
ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 192.168.42.0/24 0.0.0.0/0
ACCEPT udp -- 192.168.42.0/24 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:53
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 192.168.42.0/24 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:500 dpt:500
ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

Ist auch in Ordnung

Und hier jetzt mein Problem.
Alles sieht so weit gut aus. Die Konfiguration ist in Ordnung. Ich habe sogar zweimal ICMP-Pakete durch den Tunnel
geschickt bekommen, aber ich weis einfach nicht mehr wie. Wenn ich nun mit ping Pakete an einen rechner hinter der
anderen Tunnelseite schicke so passiert folgendes, die DROP-Liste für ipsec0 wird größer.

ifconfig ipsec0
ipsec0 Link encap:Ethernet HWaddr 00:80:C8:FB:76:43
inet addr:195.50.132.211 Mask:255.255.255.0
UP RUNNING NOARP MTU:16260 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:91 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:144 (144.0 b) TX bytes:0 (0.0 b)

less /var/log/messages
Apr 3 16:15:07 Proxy2 kernel: klips_debug: IP: ihl:20 ver:4 tos:0 tlen:84 id:0 DF frag_off:0 ttl:64 proto:1 chk:9779 saddr:195.50.
132.211 daddr:192.168.11.200
Apr 3 16:15:07 Proxy2 kernel: klips_debug:ipsec_findroute: x.x.x.x->192.168.11.200
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: * See if we match exactly as a host destination
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: ** try to match a leaf, t=0xc1c782a0
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: *** start searching up the tree, t=0xc1c782a0
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: **** t=0xc1c782b8
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: **** t=0xc1148f20
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: ***** cp2=0xc113df78 cp3=0xc361df90
Apr 3 16:15:07 Proxy2 kernel: klips_debug:rj_match: ***** not found.
Apr 3 16:15:07 Proxy2 kernel: klips_debug:ipsec_tunnel_start_xmit: Original head,tailroom: 2,28
Apr 3 16:15:07 Proxy2 kernel: klips_debug:ipsec_tunnel_start_xmit: shunt SA of DROP or no eroute: dropping.
Apr 3 16:15:08 Proxy2 kernel: klips_debug:ipsec_tunnel_hard_header: skb->dev=ipsec0 dev=ipsec0.<6>klips_debug:ipsec_tunnel_hard_head
er: Revectored 0x00000000->0xc2f92248 len=84 type=2048 dev=ipsec0->eth0 dev_addr=00:80:c8:fb:76:43 <6>ip=c33284d3->c0a80bc8
Apr 3 16:15:08 Proxy2 kernel: klips_debug:ipsec_tunnel_start_xmit: >>> skb->len=98 hard_header_len:14 00:80:c8:fb:76:43:00:80:c8:fb:
76:43:08:00

x.x.x.x ist meine statische IP-Adresse im Netz.
Kann mir jemand sagen was hier genau geschieht und wie ich es mit iptables ändern kann, da ich schon seit geraumer
Zeit an dem Problem herumdoktore. Ich habe die Dokumentationen von iptables und FreeSWAN schon vorwärts und
rückwärts gelesen. Besten Dank. Ich bin die Konfiguration auch schon mehrmals schrittweise durchgegangen. Habe
auch firewallscripte von anderen zeilenweise durchgelesen und analysiert.

Thomas