vti の中身
DESCRIPTION
VYATTA USERS MEETING Spring 2013 の資料です。TRANSCRIPT
VTI の中身浅間 正和 @ 有限会社 銀座堂
VTI とは?
• Virtual Tunnel Interface の略で Vyatta ( Network
OS | Core ) 6.5R1 から実装された中身が暗号化される IP-IP tunnel のようなモノ
Benefits
• They are capable of having traffic routed to them • They are capable of passing routing protocols over
them • They do not require local or remote subnets to be
specified • They operate as if the peer interfaces are directly
connected
(Vyatta VPN Reference Guide 6.5R1 v01 より引用)
vpn { ipsec { site-to-site { peer 172.16.1.2 { default-esp-group ESP-G ike-group IKE-G local-address 172.16.1.1 tunnel 1 { local { prefix 192.168.1.0/24 } remote { prefix 192.168.2.0/24 } } } } }}
interfaces { vti vti0 { }}protocols { static interface-route 192.168.2.0/24 { next-hop-interface vti0 { } } }}vpn { ipsec { site-to-site { peer 172.16.1.2 { ike-group IKE-G local-address 172.16.1.1 vti { bind vti0 esp-group ESP-G } } } }}
従来 VTI
Vyatta configuration の違い
conn peer-172.16.1.2-tunnel-1 left=172.16.1.1 right=172.16.1.2 leftsubnet=192.168.1.0/24 rightsubnet=192.168.2.0/24 leftsourceip=192.168.1.1 ike=aes256-sha1! ikelifetime=28800s esp=aes256-sha1! keylife=3600s rekeymargin=540s type=tunnel pfs=yes compress=no authby=secret auto=start keyingtries=%forever
conn peer-172.16.1.2-tunnel-vti left=172.16.1.1 right=172.16.1.2 leftsubnet=0.0.0.0/0 rightsubnet=0.0.0.0/0 ike=aes256-sha1! ikelifetime=28800s esp=aes256-sha1! keylife=3600s rekeymargin=540s type=tunnel pfs=yes compress=no authby=secret mark=2415919105 leftupdown="/usr/lib/ipsec/vti-up-down.sh vti0" auto=start keyingtries=%forever
従来 VTI
/etc/ipsec.conf の違い
src 192.168.1.0/24 dst 192.168.2.0/24 dir out priority 1859 tmpl src 172.16.1.1 dst 172.16.1.2 proto esp reqid 16384 mode tunnelsrc 192.168.2.0/24 dst 192.168.1.0/24 dir fwd priority 1859 tmpl src 172.16.1.2 dst 172.16.1.1 proto esp reqid 16384 mode tunnelsrc 192.168.2.0/24 dst 192.168.1.0/24 dir in priority 1859 tmpl src 172.16.1.2 dst 172.16.1.1 proto esp reqid 16384 mode tunnel
src 0.0.0.0/0 dst 0.0.0.0/0 dir out priority 2051 mark -1879048191/0xffffffff tmpl src 172.16.1.1 dst 172.16.1.2 proto esp reqid 16384 mode tunnelsrc 0.0.0.0/0 dst 0.0.0.0/0 dir fwd priority 2051 mark -1879048191/0xffffffff tmpl src 172.16.1.2 dst 172.16.1.1 proto esp reqid 16384 mode tunnelsrc 0.0.0.0/0 dst 0.0.0.0/0 dir in priority 2051 mark -1879048191/0xffffffff tmpl src 172.16.1.2 dst 172.16.1.1 proto esp reqid 16384 mode tunnel
従来 VTI
ip xfrm policy list 実行結果の違い
設定時の流れ• /opt/vyatta/sbin/vpn-config.pl が実行される• /etc/ipsec.conf の生成と ipsec start の実行• /opt/vyatta/sbin/vyatta-vti-config.pl が実行される• sudo /opt/vyatta/sbin/cfgvti add name $tunName
key $mark remote $remote local $local の実行• sudo iptables -t mangle -D PREROUTING -s
$remote -d $local ( -p esp | -p udp --dport 4500 )
-j MARK --set-mark $mark の実行
/opt/vyatta/sbin/cfgvti
• git repo の build-iso/pkgs/vyatta-cfg-vpn/src/cfgvti.c • … C で書かれたプログラム…なぜ…?• なななんと実は VTI は net/ipv4/ipip.ko ではなく
net/ipv4/ip_vti.ko だった…。
commit 1181412c1a671ed4e8fb1736f17e6ec617c68059Author: Saurabh <[email protected]>Date: Tue Jul 17 09:44:54 2012 +0000
net/ipv4: VTI support new module for ip_vti. New VTI tunnel kernel module, Kconfig and Makefile changes. Signed-off-by: Saurabh Mohan <[email protected]> Reviewed-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
net/ipv4/ip_vti.ko
• Linux kernel の main line には v3.6 から merge
• (Vyatta 6.5R1 は v3.3 なので backport?)• net/ipv4/ipip.ko を元にしているが xfrm の esp
が処理してくれる encap/decap は省かれている• 一番重要な違いは xmit 時に mark を付けることで xfrm policy に引っ掛けるようにしていること
送受信時の流れ• 送信時の流れ• net/ipv4/ip_vti.ko の vti_tunnel_xmit が呼ばれる• VTI を一意に表す mark を付け xfrm に流す• xfrm が encap し暗号化• 受信時の流れ• Netfilter が mask を付ける• mark から xfrm policy が判明し復号化と
decap 処理
まとめ• Dynamic routing や QoS と組み合わせて使えるのはかなり便利?• もとは Cisco さんが最初にやった方式?
Vyatta VPN Reference にも compatible with 3rd
party VTI/route-based VPN connections と書かれているので相互接続性もバッチリ?• ちなみに … and is sometimes required for
connectivity with pubic cloud offerings だそうです…