子网到子网libreswan ipsec vpn

我正在使用libreswan在两台Centos 7服务器之间configuration一个“子网到子网VPN”。 每个服务器都有两个nic,如下图所示。

我会允许子网172.18.0.0/16和172.19.0.0/16之间使用172.17.0.0/16networkingbuild立一个VPN的安全通信,但我有问题,允许这两个子网之间的stream量。

我遵循https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Securing_Virtual_Private_Networks.html#Site-To-Site_VPN_Using_Libreswan中的redhat官方文档

其实我在两个节点上都停止了firewalld。

我检查了IPSec的先决条件:

[root@node2 ~]# ipsec verify Verifying installed system and configuration files Version check and ipsec on-path [OK] Libreswan 3.8 (netkey) on 3.10.0-123.el7.x86_64 Checking for IPsec support in kernel [OK] NETKEY: Testing XFRM related proc values ICMP default/send_redirects [OK] ICMP default/accept_redirects [OK] XFRM larval drop [OK] Pluto ipsec.conf syntax [OK] Hardware random device [N/A] Two or more interfaces found, checking IP forwarding [OK] Checking rp_filter [OK] Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for IKE/NAT-T on udp 4500 [OK] Pluto ipsec.secret syntax [OK] Checking NAT and MASQUERADEing [TEST INCOMPLETE] Checking 'ip' command [OK] Checking 'iptables' command [OK] Checking 'prelink' command does not interfere with FIPSChecking for obsolete ipsec.conf options [OK] Opportunistic Encryption [DISABLED] 

ipsec.conf的内容是:

 config setup protostack=netkey conn mytunnel leftid=@node1 left=172.17.0.101 leftrsasigkey=0sAQPXn... rightid=@node2 right=172.17.0.102 rightrsasigkey=0sAQPxv... authby=rsasig conn mysubnet also=mytunnel leftsubnet=172.18.0.0/16 rightsubnet=172.19.0.0/16 auto=start 

我在两个节点上启动ipsec服务。 然后我检查“ipsec状态”(这里有输出http://pastebin.com/LYA9uqfJ ),我没有发现任何错误。

node1的路由表为:

 [root@node1 ~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eno16777736 172.18.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eno33554992 

如果试图ping node1的IP地址172.19.0.101,我得到errror“connect:Network is unreachable”

在我的configuration中是否有缺失? 我可以尝试什么来允许这两个子网之间的安全stream量?

检查sysctl net.ipv4.ip_forward设置。

或者你可以尝试在双方运行tcpdump,看看会发生什么。

例:

 tcpdump -n -i interface esp or udp port 500 or udp port 4500 

另外尝试添加iptables规则是这样的:

 -A FORWARD -i EXTIF -o INIF -j ACCEPT -A FORWARD -i INIF -o EXTIF -j ACCEPT -A POSTROUTING -s YOURNET1 ! -d YOURNET2 -j MASQUERADE 

关于上述内容的更多细节:

  • EXTIF是你的172.17.0.0/16接口

  • INIF是另一个172.18.0.0或172.19.0.0

我用它是如何,我的networking正在工作,但不发送keepalive包。 Strongswan没有麻烦