Strongswan VPN 터널이 연결되었지만 트래픽이 라우팅되지 않음


15

방금 strongswan (4.5)으로 사이트 간 VPN 터널을 설정했습니다. 터널이 잘 보이고 다른쪽에 연결되어 있지만 터널을 통해 트래픽을 라우팅하는 데 문제가있는 것 같습니다.

어떤 생각?

감사!

네트워크 다이어그램

+----------------------------------+
|Dedicated server: starfleet       |                   +-----------------+
|                                  |                   |  CISCO ASA      |
|        +-------------------------|     internet      |                 |
|        |eth0: XX.XX.XX.195/29    +-------------------|  YY.YYY.YYY.155 |
|        +-------------------------|                   +------+----------+
|        |virbr1: 192.168.100.1/24 |                          |
|        +----+--------------------|                          |
|             |                    |                          |
|             |                    |                   +-----------------+
|             |                    |                   |network          |
|     +-------+                    |                   |                 |
|     |                            |                   |172.30.20.0/27   |
|     |                            |                   +-----------------+
| +------------------------------+ |
| | kvm server: enterprise       | |
| |                              | |
| |                              | |
| | eth0: 192.168.100.100/24     | |
| +------------------------------+ |
+----------------------------------+

소프트웨어

  • 데비안 wheezy
  • strongswan 4.5.2-1.5 + deb7u1
  • kvm 및 libvirt (192.168.100.x 네트워크)

/etc/ipsec.conf

root@starfleet ~ # cat /etc/ipsec.conf
# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
    plutodebug="all"
    plutostderrlog=/var/log/pluto-ipsec
    charonstart=no
    plutostart=yes

conn net-net
     ikelifetime=86400s
     keylife=3600s
     rekeymargin=3m
     keyingtries=1
     keyexchange=ikev1
     authby=secret
     ike=aes256-sha-modp1024!
     esp=aes256-sha
     right=YY.YYY.YYY.155
     rightsubnet=172.30.20.0/27
     left=XX.XX.XX.195
     leftsubnet=192.168.100.0/24
     leftfirewall=yes
     pfs=no
     auto=add

IPSUP

root@starfleet ~ # ipsec up net-net
002 "net-net" #1: initiating Main Mode
102 "net-net" #1: STATE_MAIN_I1: initiate
003 "net-net" #1: ignoring Vendor ID payload [FRAGMENTATION c0000000]
104 "net-net" #1: STATE_MAIN_I2: sent MI2, expecting MR2
003 "net-net" #1: ignoring Vendor ID payload [Cisco-Unity]
003 "net-net" #1: received Vendor ID payload [XAUTH]
003 "net-net" #1: ignoring Vendor ID payload [###############################]
003 "net-net" #1: ignoring Vendor ID payload [Cisco VPN 3000 Series]
106 "net-net" #1: STATE_MAIN_I3: sent MI3, expecting MR3
002 "net-net" #1: Peer ID is ID_IPV4_ADDR: 'YY.YYY.YYY.155'
002 "net-net" #1: ISAKMP SA established
004 "net-net" #1: STATE_MAIN_I4: ISAKMP SA established
002 "net-net" #2: initiating Quick Mode PSK+ENCRYPT+TUNNEL+UP {using isakmp#1}
110 "net-net" #2: STATE_QUICK_I1: initiate
002 "net-net" #2: sent QI2, IPsec SA established {ESP=>0x8a12ab22 <0xa01abba1}
004 "net-net" #2: STATE_QUICK_I2: sent QI2, IPsec SA established {ESP=>0x8a12ab22     <0xa01abba1}

root@starfleet ~ # ipsec status
000 "net-net":     192.168.100.0/24===XX.XX.XX.195[XX.XX.XX.195]...YY.YYY.YYY.155[YY.YYY.YYY.155]===172.30.20. 0/27; erouted; eroute owner: #2
000 "net-net":   newest ISAKMP SA: #1; newest IPsec SA: #2; 
000 
000 #2: "net-net" STATE_QUICK_I2 (sent QI2, IPsec SA established); EVENT_SA_REPLACE in 3331s; newest IPSEC; eroute owner
000 #2: "net-net" esp.8a12ab22@YY.YYY.YYY.155 (0 bytes) esp.a01abba1@XX.XX.XX.195 (0 bytes); tunnel
000 #1: "net-net" STATE_MAIN_I4 (ISAKMP SA established); EVENT_SA_REPLACE in 86050s; newest ISAKMP
000 

네트워크 정보

tun0 인터페이스는 openvpn 서버에서 사용됩니다.

virbr1 인터페이스는 kvm 네트워크입니다

root@starfleet ~ # ip -4 a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet XX.XX.XX.195/29 brd XX.XX.XX.199 scope global eth0
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
    inet 10.8.0.1 peer 10.8.0.2/32 scope global tun0
5: virbr1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    inet 192.168.100.1/24 brd 192.168.100.255 scope global virbr1

root@starfleet ~ # ip -4 r s t 0
default via XX.XX.XX.193 dev eth0 
10.8.0.0/16 via 10.8.0.2 dev tun0 
10.8.0.2 dev tun0  proto kernel  scope link  src 10.8.0.1 
XX.XX.XX.192/29 via XX.XX.XX.193 dev eth0 
XX.XX.XX.192/29 dev eth0  proto kernel  scope link  src XX.XX.XX.195 
192.168.100.0/24 dev virbr1  proto kernel  scope link  src 192.168.100.1 
local 10.8.0.1 dev tun0  table local  proto kernel  scope host  src 10.8.0.1 
broadcast XX.XX.XX.192 dev eth0  table local  proto kernel  scope link  src XX.XX.XX.195 
local XX.XX.XX.195 dev eth0  table local  proto kernel  scope host  src XX.XX.XX.195 
broadcast XX.XX.XX.199 dev eth0  table local  proto kernel  scope link  src XX.XX.XX.195 
broadcast 127.0.0.0 dev lo  table local  proto kernel  scope link  src 127.0.0.1 
local 127.0.0.0/8 dev lo  table local  proto kernel  scope host  src 127.0.0.1 
local 127.0.0.1 dev lo  table local  proto kernel  scope host  src 127.0.0.1 
broadcast 127.255.255.255 dev lo  table local  proto kernel  scope link  src 127.0.0.1 
broadcast 192.168.100.0 dev virbr1  table local  proto kernel  scope link  src 192.168.100.1 
local 192.168.100.1 dev virbr1  table local  proto kernel  scope host  src 192.168.100.1 
broadcast 192.168.100.255 dev virbr1  table local  proto kernel  scope link  srr 192.168.100.1

root@starfleet ~ # ip xfrm state
src XX.XX.XX.195 dst YY.YYY.YYY.155
    proto esp spi 0x8a12ab22 reqid 16384 mode tunnel
    replay-window 32 flag af-unspec
    auth-trunc hmac(sha1) 0x######################################## 96
    enc cbc(aes) 0x################################################################
src YY.YYY.YYY.155 dst XX.XX.XX.195
    proto esp spi 0xa01abba1 reqid 16384 mode tunnel
    replay-window 32 flag af-unspec
    auth-trunc hmac(sha1) 0x######################################## 96
    enc cbc(aes) 0x################################################################

root@starfleet ~ # ip xfrm policy
src 192.168.100.0/24 dst 172.30.20.0/27 
    dir out priority 1847 ptype main 
    tmpl src XX.XX.XX.195 dst YY.YYY.YYY.155
        proto esp reqid 16384 mode tunnel
src 172.30.20.0/27 dst 192.168.100.0/24 
    dir fwd priority 1847 ptype main 
    tmpl src YY.YYY.YYY.155 dst XX.XX.XX.195
        proto esp reqid 16384 mode tunnel
src 172.30.20.0/27 dst 192.168.100.0/24 
    dir in priority 1847 ptype main 
    tmpl src YY.YYY.YYY.155 dst XX.XX.XX.195
        proto esp reqid 16384 mode tunnel
src ::/0 dst ::/0 
    socket out priority 0 ptype main 
src ::/0 dst ::/0 
    socket in priority 0 ptype main 
src ::/0 dst ::/0 
    socket out priority 0 ptype main 
src ::/0 dst ::/0 
    socket in priority 0 ptype main 
src 0.0.0.0/0 dst 0.0.0.0/0 
    socket out priority 0 ptype main 
src 0.0.0.0/0 dst 0.0.0.0/0 
    socket in priority 0 ptype main 
src 0.0.0.0/0 dst 0.0.0.0/0 
    socket out priority 0 ptype main 
src 0.0.0.0/0 dst 0.0.0.0/0 
    socket in priority 0 ptype main 

root@starfleet ~ # ip route show table 220
root@starfleet ~ # 

root@starfleet ~ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         XX.XX.XX.193    0.0.0.0         UG    0      0        0 eth0
10.8.0.0        10.8.0.2        255.255.0.0     UG    0      0        0 tun0
10.8.0.2        0.0.0.0         255.255.255.255 UH    0      0        0 tun0
XX.XX.XX.192    XX.XX.XX.193    255.255.255.248 UG    0      0        0 eth0
XX.XX.XX.192    0.0.0.0         255.255.255.248 U     0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr1

IP 테이블

root@starfleet ~ # iptables-save 
# Generated by iptables-save v1.4.14 on Fri May 24 16:07:39 2013
*nat
:PREROUTING ACCEPT [11:368]
:INPUT ACCEPT [1:48]
:OUTPUT ACCEPT [13:1012]
:POSTROUTING ACCEPT [13:1012]
-A POSTROUTING -s 10.8.0.0/16 ! -d 10.8.0.0/16 -o virbr1 -j MASQUERADE
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -j MASQUERADE
COMMIT
# Completed on Fri May 24 16:07:39 2013
# Generated by iptables-save v1.4.14 on Fri May 24 16:07:39 2013
*mangle
:PREROUTING ACCEPT [271:19504]
:INPUT ACCEPT [261:19184]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [181:28686]
:POSTROUTING ACCEPT [181:28686]
-A POSTROUTING -o virbr1 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Fri May 24 16:07:39 2013
# Generated by iptables-save v1.4.14 on Fri May 24 16:07:39 2013
*filter
:INPUT ACCEPT [46:3380]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [36:5220]
-A INPUT -i virbr1 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i virbr1 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i virbr1 -p udp -m udp --dport 67 -j ACCEPT
-A INPUT -i virbr1 -p tcp -m tcp --dport 67 -j ACCEPT
-A FORWARD -s 172.30.20.0/27 -d 192.168.100.0/24 -i eth0 -m policy --dir in --pol ipsec --reqid 16384 --proto esp -j ACCEPT
-A FORWARD -s 192.168.100.0/24 -d 172.30.20.0/27 -o eth0 -m policy --dir out --pol ipsec --reqid 16384 --proto esp -j ACCEPT
-A FORWARD -s 10.8.0.0/16 -o virbr1 -j ACCEPT
-A FORWARD -i virbr1 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -d 192.168.100.0/24 -o virbr1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 192.168.100.0/24 -i virbr1 -j ACCEPT
-A FORWARD -i virbr1 -o virbr1 -j ACCEPT
-A FORWARD -o virbr1 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i virbr1 -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Fri May 24 16:07:39 2013

192.168.100.100에서 172.30.20.9로 TcpDumping

모든 명령이 동시에 실행 중입니다.

root@enterprise:~# ping 172.30.20.9
PING 172.30.20.9 (172.30.20.9) 56(84) bytes of data.
^C
--- 172.30.20.9 ping statistics ---
6 packets transmitted, 0 received, 100% packet loss, time 4999ms

root@enterprise:~# tcpdump -v -n dst net 172.30.20.0/27
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
16:23:48.919819 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 1, length 64
16:23:49.918949 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 2, length 64
16:23:50.918950 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 3, length 64
16:23:51.918952 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 4, length 64
16:23:52.918954 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 5, length 64
16:23:53.918951 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.100.100 > 172.30.20.9: ICMP echo request, id 2605, seq 6, length 64

root@starfleet ~ # tcpdump -v -n dst net 172.30.20.0/27
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
16:23:50.475100 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 1, length 64
16:23:51.474262 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 2, length 64
16:23:52.474280 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 3, length 64
16:23:53.474251 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 4, length 64
16:23:54.474213 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 5, length 64
16:23:55.474173 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
XX.XX.XX.195 > 172.30.20.9: ICMP echo request, id 2605, seq 6, length 64

답변:


10

스타 플릿 에서 tcpdump세션의 결과는 문제를 나타냅니다. 여기서 NAT 규칙으로 인해

-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -j MASQUERADE

소스 주소 192.168.100.100가 있는 ICMP 요청 이에 적용됩니다 xx.xx.xx.195. 협상 IPsec 정책은 트래픽에 대한이므로에서 192.168.100.0/24가 아니라 xx.xx.xx.195이러한 패킷이 암호화되지 않습니다. Netfilter를 통한 패킷 흐름 의이 회로도 에서 볼 수 있듯이 nat 테이블의 POSTROUTING 체인에있는 규칙은 IPsec 변환 ( xfrm 조회 )을 조회하기 전에 적용됩니다 .

이 문제를 해결하려면 다음 중 하나 를 수행하십시오.

  • MASQUERADE 규칙 ( ! -d 172.30.20.0/27) 에서 대상 서브넷으로의 트래픽을 명시 적으로 제외
  • MASQUERADE 규칙 앞에 명시 적 면제 규칙 추가

    -A POSTROUTING -s 192.168.100.0/24 -m policy --dir out --pol ipsec -j ACCEPT
    
  • MASQUERADE 규칙은 그대로두고 leftsubnet=xx.xx.xx.195/32대신 구성하십시오 (Cisco ASA 상자에서 구성을 조정해야하며 사이트 간 터널이 실제로 목표 인 경우에는 도움이되지 않음)


답변 주셔서 감사합니다. 세 가지 조언을 하나씩 시도했지만 작동하지 않습니다. eth0 (iptables도 청소했습니다)을 제외한 모든 인터페이스를 종료했으며 세 번째 조언을 적용했으며 트래픽은 라우팅되지 않았습니다. 어떤 생각?
telemaco

마지막으로 Cisco의 asaside에서 leftsubnet = xx.xx.xx.195 / 32 및 일부 nat 횡단 구성을 구성하면 IT가 작동합니다! :) 감사합니다
telemaco

2

내 상황은 @telemaco에서 설명한 것과 매우 유사합니다. 랩톱 컴퓨터의 KVM에서 테스트 VM을 실행하고 있습니다. 내 랩탑은 DHCP를 통해 IP 주소를 수신하므로 VPN 엔드 포인트 IP 주소는 Strongswan에 의해를 통해 내 랩탑에 할당됩니다 leftsourceip=%config.

VM은 개인 네트워크를 사용합니다 192.168.100.0/24. 내 랩탑 (KVM 호스트)은 192.168.50.2/24DHCP를 통해 IP 주소 10.0.0.10/26를, Strongswan에서 엔드 포인트 IP 주소 를받습니다.

VM은 192.168.0.0/24VPN을 통해 라우팅되는 네트워크에 액세스해야합니다 .

@ecdsa가 제공 한 답변을 기반으로 다음 규칙을 추가 하여이 작업을 수행했습니다.

-t nat -I POSTROUTING -s 192.168.100.0/24 -d 192.168.0.0/24 -j SNAT --to-source 10.0.0.10

제 경우에는 ip xfrm policy다음과 같습니다 (발췌).

src 192.168.0.0/24 dst 10.0.0.10/32 
    dir fwd priority 2851 
    tmpl src xx.xx.xx.xx dst 192.168.50.2
        proto esp reqid 5 mode tunnel
src 192.168.0.0/24 dst 10.0.0.10/32 
    dir in priority 2851 
    tmpl src xx.xx.xx.xx dst 192.168.50.2
        proto esp reqid 5 mode tunnel
src 10.0.0.10/32 dst 192.168.0.0/24 
    dir out priority 2851 
    tmpl src 192.168.50.2 dst xx.xx.xx.xx
        proto esp reqid 5 mode tunnel

즉, 로컬 IP 주소에만 10.0.0.10해당 xfrm lookup규칙이 있습니다. VM 서브넷이 IPsec에 추가되지 않는 한 NAT가 필요한 이유입니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.