使用 strongswan 和 xl2tpd 从 Ubuntu 连接到 Meraki 客户端 VPN

使用 strongswan 和 xl2tpd 从 Ubuntu 连接到 Meraki 客户端 VPN

我有一个运行 Ubuntu 14 的虚拟设备,我想通过 Meraki Client VPN 连接到远程网络。

我找到了在 Ubuntu 16 上安装和配置 strongswan 和 xl2tpd 的说明,这些说明帮助我完成了大部分工作,但在建立 VPN 后,我似乎无法建立路由。

目标是允许从这单个 Ubuntu VM 的流量通过 VPN 到远程 LAN 上的子网。

(Ubuntu 192.168.5.99/32)=VPN>(Meraki 设备 20.20.20.20)=>(子网 192.168.1.0/24)

https://gist.github.com/psanford/42c550a1a6ad3cb70b13e4aaa94ddb1c http://www.jasonernst.com/2016/06/21/l2tp-ipsec-vpn-on-ubuntu-16-04/

/etc/ipsec.conf:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
        # strictcrlpolicy=yes
        # uniqueids = no

# Add connections here.

# Sample VPN connections

conn %default
        ikelifetime=60m
        keylife=20m
        rekeymargin=3m
        keyingtries=1
        keyexchange=ikev1
        authby=secret
        ike=aes128-sha1-modp1024,3des-sha1-modp1024!
        esp=aes128-sha1-modp1024,3des-sha1-modp1024!

conn meraki-vpn
     keyexchange=ikev1
     left=%defaultroute
     auto=add
     authby=secret
     type=transport
     leftprotoport=17/1701
     rightprotoport=17/1701
     # set this to the ip address of your meraki vpn
     right=20.20.20.20

/etc/xl2tpd/xl2tpd.conf:

[lac meraki]
lns = 20.20.20.20
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd.client
length bit = yes

我可以启动 VPN:

root@zzz:~# ipsec up meraki-vpn
...
connection 'meraki-vpn' established successfully

登录:

echo "c meraki [email protected] mypassword" > /var/run/xl2tpd/l2tp-control

但我无法设置路由。尝试按照魔法配方操作会导致错误。我不知道这是 xl2tpd 配置问题,还是我无法找到添加路由的正确语法。任何见解都将不胜感激。

root@zzz:~# ip route add 192.168.1.0/24 dev ppp0
Cannot find device "ppp0"

ipsec 状态全部:

Status of IKE charon daemon (strongSwan 5.1.2, Linux 4.2.0-42-generic, x86_64):
  uptime: 20 hours, since Oct 19 19:30:38 2016
  malloc: sbrk 2433024, mmap 0, used 352240, free 2080784
  worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 4
  loaded plugins: charon test-vectors aes rc2 sha1 sha2 md4 md5 rdrand random nonce x509 revocation constraints pkcs1 pkcs7 pkcs8 pkcs12 pem openssl xcbc cmac hmac ctr ccm gcm attr kernel-netlink resolve socket-default stroke updown eap-identity addrblock
Listening IP addresses:
  192.168.5.99
Connections:
  meraki-vpn:  %any...20.20.20.20  IKEv1
  meraki-vpn:   local:  [192.168.5.99] uses pre-shared key authentication
  meraki-vpn:   remote: [20.20.20.20] uses pre-shared key authentication
  meraki-vpn:   child:  dynamic[udp/l2f] === dynamic[udp/l2f] TRANSPORT
Security Associations (1 up, 0 connecting):
  meraki-vpn[4]: ESTABLISHED 8 minutes ago, 192.168.5.99[192.168.5.99]...20.20.20.20[20.20.20.20]
  meraki-vpn[4]: IKEv1 SPIs: 2121ded4dc4dc94e_i* 3d5d1cc8bf935f19_r, pre-shared key reauthentication in 48 minutes
  meraki-vpn[4]: IKE proposal: 3DES_CBC/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024
  meraki-vpn{5}:  INSTALLED, TRANSPORT, ESP in UDP SPIs: c330d0b3_i 06749ffa_o
  meraki-vpn{5}:  3DES_CBC/HMAC_SHA1_96, 0 bytes_i, 0 bytes_o, rekeying in 8 minutes
  meraki-vpn{5}:   192.168.5.99/32[udp/l2f] === 20.20.20.20/32[udp/l2f]

ifconfig 命令:

eth0      Link encap:Ethernet  HWaddr 00:0c:29:5f:9c:73  
          inet addr:192.168.5.99  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe5f:9c73/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:459939 errors:0 dropped:0 overruns:0 frame:0
          TX packets:362145 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:78969068 (78.9 MB)  TX bytes:52179997 (52.1 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:427152 errors:0 dropped:0 overruns:0 frame:0
          TX packets:427152 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:25278435 (25.2 MB)  TX bytes:25278435 (25.2 MB) 

谢谢!

答案1

您有时需要禁用 xl2tpd,因为它运行并占用端口 1701,而 VPN 客户端通常仅在需要时在 1701 上启动服务。

我在关注时发现了这一点这个答案引述如下其中提到的博客文章从 Ubuntu 16.04 建立与 Meraki 的连接。

存在针对 network-manager-l2tp 的 PPA:

您可以使用

sudo add-apt-repository ppa:nm-l2tp/network-manager-l2tp  
sudo apt-get update  
sudo apt-get install network-manager-l2tp

为 Ubuntu 16.04 安装支持 L2TP 的网络管理器 l2tp

从源代码构建的演练:http://blog.z-proj.com/enabling-l2tp-over-ipsec-on-ubuntu-16-04/

相关内容