Vpn

openSwan VPN 已啟動無法 ping 遠端子網

  • April 29, 2016

當我執行命令 ipsec auto status 時,我得到以下輸出:

......           
172.16.255.1/32===104.131.13.155<104.131.13.155>:17/1701...41.203.65.124<41.203.    65.124>===10.100.108.51/32; erouted; eroute owner: #13
.......
000 #13: "globacom-vpn":500 STATE_QUICK_I2 (sent QI2, IPsec SA established);     EVENT_SA_REPLACE in 2243s; newest IPSEC; eroute owner; isakmp#10; idle; import:admin initiate
000 #13: "globacom-vpn" esp.e5adc724@41.203.65.124 esp.7b33a369@104.131.13.155 tun.0@41.203.65.124 tun.0@104.131.13.155 ref=0 refhim=4294901761
000 #10: "globacom-vpn":500 STATE_MAIN_I4 (ISAKMP SA established); EVENT_SA_REPLACE in 79407s; newest ISAKMP; lastdpd=10s(seq in:15699 out:0); idle; import:admin initiate
000

服務 ipsec 狀態

IPsec running  - pluto pid: 14150
pluto pid 14150
1 tunnels up
some eroutes exist

ip xfrm 策略

src 172.16.255.1/32 dst 10.100.108.51/32 proto udp sport 1701
   dir out priority 2080
   tmpl src 104.131.13.155 dst 41.203.65.124
           proto esp reqid 16405 mode tunnel
src 10.100.108.51/32 dst 172.16.255.1/32 proto udp dport 1701
   dir fwd priority 2080
   tmpl src 41.203.65.124 dst 104.131.13.155
           proto esp reqid 16405 mode tunnel
src 10.100.108.51/32 dst 172.16.255.1/32 proto udp dport 1701
   dir in priority 2080
   tmpl src 41.203.65.124 dst 104.131.13.155
           proto esp reqid 16405 mode tunnel
src ::/0 dst ::/0
   socket out priority 0
src ::/0 dst ::/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
   socket out priority 0

ping 10.100.108.51

PING 10.100.108.51 (10.100.108.51) 56(84) bytes of data.
From 104.131.13.155 icmp_seq=1 Destination Host Unreachable
From 104.131.13.155 icmp_seq=2 Destination Host Unreachable
From 104.131.13.155 icmp_seq=3 Destination Host Unreachable

我究竟做錯了什麼?

終於解決了這個問題。

這是我所做的:

  1. 在 ipsec.conf 文件中,我必須註釋掉設置為的 leftprotoport
leftprotoport=17/1701

這實質上限制了使用 UDP 埠 1701 與 L2TP 的 vpn 連接。檢查 ip xfrm 策略顯示源埠和目標埠設置為 1701。這意味著我無法通過 TCP 發送任何流量。唯一允許的流量來自 UDP 埠 1701。 2. 當我在 eth0 上執行 tcpdump 時,我注意到有一些 udp 校驗和錯誤。顯然這是 debian 設置為使用硬體 TCP/UDP 校驗和解除安裝的結果。以下命令將其禁用。

$ ethtool --offload  eth0  rx off  tx off
$ ethtool -K eth0 gso off

現在,當我對遠端主機/網路執行跟踪路由時,我只看到一跳,而配置了錯誤的 ipsec 策略時為 11。我還看到 ESP(spi=0XXXX, seq=xxxx) 數據包是從 tcpdump 到遠端主機的輸出的一部分,同時以 ping/telnet 的形式發送流量。

引用自:https://serverfault.com/questions/755359