{"id":6016,"date":"2016-06-15T16:14:45","date_gmt":"2016-06-15T08:14:45","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6016"},"modified":"2016-07-07T08:44:43","modified_gmt":"2016-07-07T00:44:43","slug":"ubuntu-server%e4%b8%ad%e9%85%8d%e7%bd%aevpn%e8%bf%9e%e6%8e%a5","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6016.html","title":{"rendered":"Ubuntu Server\u4e2d\u914d\u7f6evpn\u8fde\u63a5"},"content":{"rendered":"<p>\u5b89\u88c5pptp\u5ba2\u6237\u7aef\u8f6f\u4ef6<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo apt-get install pptp-linux\r\n<\/pre>\n<p>\u67e5\u770b\u7f51\u7edc\u914d\u7f6e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ ifconfig\r\neth0      Link encap:Ethernet  HWaddr 08:00:27:90:e8:19\r\n          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0\r\n          inet6 addr: fe80::a00:27ff:fe90:e819\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:74 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:64 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:8112 (8.1 KB)  TX bytes:8542 (8.5 KB)\r\n\r\nlo        Link encap:Local Loopback\r\n          inet addr:127.0.0.1  Mask:255.0.0.0\r\n          inet6 addr: ::1\/128 Scope:Host\r\n          UP LOOPBACK RUNNING  MTU:16436  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n\r\n~ route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0\r\n192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0\r\n\r\n~ ip route\r\ndefault via 192.168.1.1 dev eth0  metric 100\r\n192.168.1.0\/24 dev eth0  proto kernel  scope link  src 192.168.1.200\r\n<\/pre>\n<p>\u521d\u59cb\u5316\u4e00\u4e2aVPN\u7684\u8fde\u63a5\u901a\u9053\uff1amyvpn<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo pptpsetup --create myvpn --server xxx.xxx.xxx.xxx --username xx1--password xx2--encrypt --start\r\n\r\nUsing interface ppp0\r\nConnect: ppp0  \/dev\/pts\/1\r\nCHAP authentication succeeded\r\nMPPE 128-bit stateless compression enabled\r\nlocal  IP address 10.10.10.3\r\nremote IP address 10.10.10.1\r\n<\/pre>\n<p>\u6210\u529f\u8fde\u63a5\u5230\u8fdc\u7a0bVPN\u670d\u52a1\u5668\u3002<\/p>\n<p>\u901a\u8fc7\u521a\u624d\u7684\u521b\u5efa\u811a\u6b65\uff1a<\/p>\n<p>\u5728\/etc\/ppp\/peers\u76ee\u5f55\u4e0b\u9762\uff0c\u4f1a\u751f\u6210\u4e00\u4e2a\u53ebmyvpn\u7684\u6587\u4ef6\u3002<br \/>\n\u5728\/etc\/ppp\u76ee\u5f55\u4e0b\u9762\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u4f1a\u5199\u5728chap-secrets\u6587\u4ef6\u4e2d\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo vi \/etc\/ppp\/peers\/myvpn\r\n\r\n# written by pptpsetup\r\npty &quot;pptp xxx.xxx.xxx.xxx --nolaunchpppd&quot;\r\nlock\r\nnoauth\r\nnobsdcomp\r\nnodeflate\r\nname conan2\r\nremotename myvpn\r\nipparam myvpn\r\nrequire-mppe-128\r\n\r\n#\u751f\u6210\u7528\u6237\u540d\u548c\u5bc6\u7801\r\n~ sudo vi \/etc\/ppp\/chap-secrets\r\nxx1 myvpn &quot;xx2&quot; *\r\n<\/pre>\n<p>\u901a\u8fc7\u7f51\u7ad9\u8def\u7531\u529f\u80fd\uff0c\u6d4b\u8bd5VPN<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#\u5b89\u88c5traceroute\r\n~ sudo apt-get install traceroute\r\n\r\n~ traceroute www.163.com\r\ntraceroute to www.163.com (101.23.128.17), 30 hops max, 60 byte packets\r\n 1  localhost (192.168.1.1)  2.222 ms  3.144 ms  3.132 ms\r\n 2  111.192.144.1 (111.192.144.1)  80.279 ms  80.632 ms  80.624 ms\r\n 3  61.148.185.69 (61.148.185.69)  9.026 ms  9.492 ms  9.479 ms\r\n 4  124.65.61.157 (124.65.61.157)  9.469 ms  9.459 ms  9.447 ms\r\n 5  202.96.12.185 (202.96.12.185)  9.829 ms  9.783 ms  9.771 ms\r\n 6  219.158.96.110 (219.158.96.110)  17.160 ms  17.210 ms  17.158 ms\r\n 7  61.182.176.178 (61.182.176.178)  30.222 ms  28.589 ms  28.077 ms\r\n 8  60.5.194.58 (60.5.194.58)  29.293 ms  29.287 ms  29.276 ms\r\n 9  60.5.197.214 (60.5.197.214)  26.617 ms  26.724 ms  26.668 ms\r\n10  101.23.255.45 (101.23.255.45)  27.672 ms  28.147 ms  26.811 ms\r\n11  101.23.128.17 (101.23.128.17)  25.890 ms  28.065 ms  28.420 ms\r\n<\/pre>\n<p>\u6211\u4eec\u53d1\u73b0\u867d\u7136VPN\u5df2\u7ecf\u8fde\u63a5\u6210\u529f\uff0c\u4f46\u662f\u8def\u7531\u6ca1\u6709\u901a\u8fc7VPN\u4e0a\u7f51\uff0c\u7b2c1\u8df3\u8fd8\u662flocalhost (192.168.1.1)<\/p>\n<p>\u518d\u6b21\u67e5\u770b\u7f51\u7edc\u8fde\u63a5\u914d\u7f6e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ ifconfig\r\neth0      Link encap:Ethernet  HWaddr 08:00:27:90:e8:19\r\n          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0\r\n          inet6 addr: fe80::a00:27ff:fe90:e819\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:175 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:162 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:16817 (16.8 KB)  TX bytes:19723 (19.7 KB)\r\n\r\nlo        Link encap:Local Loopback\r\n          inet addr:127.0.0.1  Mask:255.0.0.0\r\n          inet6 addr: ::1\/128 Scope:Host\r\n          UP LOOPBACK RUNNING  MTU:16436  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n\r\nppp0      Link encap:Point-to-Point Protocol\r\n          inet addr:10.10.10.3  P-t-P:10.10.10.1  Mask:255.255.255.255\r\n          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1496  Metric:1\r\n          RX packets:7 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:3\r\n          RX bytes:70 (70.0 B)  TX bytes:76 (76.0 B)\r\n\r\n~ route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0\r\n10.10.10.1      0.0.0.0         255.255.255.255 UH    0      0        0 ppp0\r\n50.116.27.194   192.168.1.1     255.255.255.255 UGH   0      0        0 eth0\r\n192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0\r\n\r\n~ ip route\r\ndefault via 192.168.1.1 dev eth0  metric 100\r\n10.10.10.1 dev ppp0  proto kernel  scope link  src 10.10.10.3\r\n50.116.27.194 via 192.168.1.1 dev eth0  src 192.168.1.200\r\n192.168.1.0\/24 dev eth0  proto kernel  scope link  src 192.168.1.200\r\n<\/pre>\n<p>\u6211\u4eec\u53d1\u73b0\u9ed8\u8ba4\u8def\u7531\u662f\u6307\u5411eth0\u3002<\/p>\n<p>\u4e0b\u9762\u4fee\u6539\u8def\u7531\u914d\u7f6e\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#\u4fee\u6539\u8def\u7531\u547d\u4ee4\r\n~ sudo ip route del default\r\n~ sudo ip route add default dev ppp0\r\n\r\n~ route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0\r\n10.10.10.1      0.0.0.0         255.255.255.255 UH    0      0        0 ppp0\r\n50.116.27.194   192.168.1.1     255.255.255.255 UGH   0      0        0 eth0\r\n192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0\r\n\r\n~ ip route\r\ndefault dev ppp0  scope link\r\n10.10.10.1 dev ppp0  proto kernel  scope link  src 10.10.10.3\r\n50.116.27.194 via 192.168.1.1 dev eth0  src 192.168.1.200\r\n192.168.1.0\/24 dev eth0  proto kernel  scope link  src 192.168.1.200\r\n\r\n~ traceroute www.163.com\r\ntraceroute to www.163.com (101.23.128.17), 30 hops max, 60 byte packets\r\n 1  localhost (10.10.10.1)  281.093 ms  281.414 ms  280.941 ms\r\n 2  router2-dal.linode.com (67.18.7.162)  281.225 ms  281.109 ms  281.841 ms\r\n 3  xe-2-0-0.car04.dllstx2.networklayer.com (67.18.7.93)  280.882 ms  284.002 ms  283.913 ms\r\n 4  po102.dsr01.dllstx2.networklayer.com (70.87.254.81)  284.123 ms  284.087 ms  283.979 ms\r\n 5  po21.dsr01.dllstx3.networklayer.com (70.87.255.65)  284.000 ms  283.921 ms  283.839 ms\r\n 6  ae16.bbr01.eq01.dal03.networklayer.com (173.192.18.224)  283.542 ms  279.296 ms  290.455 ms\r\n 7  dls-bb1-link.telia.net (213.248.102.173)  301.426 ms  302.092 ms  302.085 ms\r\n 8  las-bb1-link.telia.net (213.155.131.77)  327.192 ms  327.350 ms  327.344 ms\r\n 9  chinaunicom-ic-151188-las-bb1.telia.net (213.248.94.126)  478.941 ms  479.089 ms  479.083 ms\r\n10  219.158.30.173 (219.158.30.173)  496.679 ms  496.673 ms  496.667 ms\r\n11  219.158.97.57 (219.158.97.57)  516.819 ms  517.035 ms  517.011 ms\r\n12  219.158.5.129 (219.158.5.129)  491.084 ms  490.018 ms  497.472 ms\r\n13  219.158.100.130 (219.158.100.130)  518.239 ms  518.216 ms  518.192 ms\r\n14  61.182.176.186 (61.182.176.186)  533.695 ms  533.673 ms  533.666 ms\r\n15  101.23.255.230 (101.23.255.230)  512.212 ms  512.500 ms  512.479 ms\r\n16  60.5.194.74 (60.5.194.74)  519.246 ms  519.815 ms  519.791 ms\r\n17  101.23.255.45 (101.23.255.45)  526.522 ms  526.907 ms  526.844 ms\r\n18  101.23.128.17 (101.23.128.17)  522.068 ms  517.535 ms  517.240 ms\r\n<\/pre>\n<p>\u67e5\u770b\u7b2c\u4e00\u8df3\uff0clocalhost (10.10.10.1)\uff0c\u5df2\u7ecf\u901a\u8fc7VPN\u5b9e\u73b0\u8def\u7531\u3002<\/p>\n<p>\u505c\u6b62VPN<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo poff myvpn\r\n\r\n~ ifconfig\r\neth0      Link encap:Ethernet  HWaddr 08:00:27:90:e8:19\r\n          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0\r\n          inet6 addr: fe80::a00:27ff:fe90:e819\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:2270 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:1991 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:207578 (207.5 KB)  TX bytes:184147 (184.1 KB)\r\n\r\nlo        Link encap:Local Loopback\r\n          inet addr:127.0.0.1  Mask:255.0.0.0\r\n          inet6 addr: ::1\/128 Scope:Host\r\n          UP LOOPBACK RUNNING  MTU:16436  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n<\/pre>\n<p>\u518dping\u7f51\u7ad9\uff0c\u53d1\u73b0\u7f51\u7edc\u51fa\u73b0\u95ee\u9898\u3002Network is unreachable<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ ping www.163.com\r\nconnect: Network is unreachable\r\n\r\n~ route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n50.116.27.194   192.168.1.1     255.255.255.255 UGH   0      0        0 eth0\r\n192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0\r\n\r\n~ ip route\r\n50.116.27.194 via 192.168.1.1 dev eth0  src 192.168.1.200\r\n192.168.1.0\/24 dev eth0  proto kernel  scope link  src 192.168.1.200\r\n<\/pre>\n<p>\u91cd\u7f6e\u8def\u7531<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo ip route add default via 192.168.1.1\r\n\r\n~ route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0\r\n50.116.27.194   192.168.1.1     255.255.255.255 UGH   0      0        0 eth0\r\n192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0\r\n\r\n~ ip route\r\ndefault via 192.168.1.1 dev eth0\r\n50.116.27.194 via 192.168.1.1 dev eth0  src 192.168.1.200\r\n192.168.1.0\/24 dev eth0  proto kernel  scope link  src 192.168.1.200\r\n\r\n#\u518d\u6b21ping\u7f51\u7ad9\uff0c\u8bbf\u95ee\u6210\u529f\uff01\r\n~ ping www.163.com\r\nPING 163.xdwscache.glb0.lxdns.com (101.23.128.17) 56(84) bytes of data.\r\n64 bytes from 101.23.128.17: icmp_req=1 ttl=54 time=25.6 ms\r\n64 bytes from 101.23.128.17: icmp_req=2 ttl=54 time=25.5 ms\r\n64 bytes from 101.23.128.17: icmp_req=3 ttl=54 time=27.8 ms\r\n<\/pre>\n<p>\u901a\u8fc7ip-up, ip-down\u914d\u7f6e\u8def\u7531<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo vi \/etc\/ppp\/ip-up.d\/route-traffic\r\n\r\n#!\/bin\/bash\r\n\/sbin\/ip route add 50.116.27.194 via 192.168.1.1\r\n\/sbin\/ip route del default\r\n\/sbin\/ip route add default dev ppp0\r\n\r\n~ sudo chmod 755 \/etc\/ppp\/ip-up.d\/route-traffic\r\n\r\n~ sudo vi \/etc\/ppp\/ip-down.d\/disableroute\r\n\r\n#!\/bin\/bash\r\n\/sbin\/ip route add default via 192.168.1.1\r\n\r\n~ sudo chmod 755 \/etc\/ppp\/ip-down.d\/disableroute\r\n\r\n<\/pre>\n<p>\u91cd\u542fVPN\u8fde\u63a5<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~ sudo pon myvpn\r\n#\u8def\u7531\u8ddf\u8e2a\u6b63\u786e\r\n~ traceroute www.163.com\r\ntraceroute to www.163.com (123.125.34.30), 30 hops max, 60 byte packets\r\n 1  localhost (10.10.10.1)  293.397 ms  293.782 ms  293.668 ms\r\n 2  router2-dal.linode.com (67.18.7.162)  293.530 ms  293.721 ms  294.223 ms\r\n 3  xe-2-0-0.car04.dllstx2.networklayer.com (67.18.7.93)  293.454 ms  293.358 ms  293.239 ms\r\n 4  po102.dsr02.dllstx2.networklayer.com (70.87.254.85)  293.749 ms  293.650 ms  293.544 ms\r\n 5  po22.dsr02.dllstx3.networklayer.com (70.87.255.69)  293.444 ms  293.339 ms  293.242 ms\r\n 6  ae17.bbr02.eq01.dal03.networklayer.com (173.192.18.230)  293.117 ms  293.525 ms  300.406 ms\r\n 7  dls-bb1-link.telia.net (80.239.195.177)  300.850 ms  300.667 ms  300.320 ms\r\n\r\n#\u6b63\u5e38\u9000\u51fa\r\n~ sudo poff myvpn\r\n\r\n#\u6d4b\u8bd5\u7f51\u7edc\u8fde\u63a5\u6b63\u5e38\r\n~ ping www.163.com\r\nPING 163.xdwscache.glb0.lxdns.com (101.23.128.17) 56(84) bytes of data.\r\n64 bytes from 101.23.128.17: icmp_req=1 ttl=54 time=28.2 ms\r\n64 bytes from 101.23.128.17: icmp_req=2 ttl=54 time=28.1 ms\r\n<\/pre>\n<p>\u5230\u8fd9\u513fVPN\u5c31\u8bbe\u7f6e\u597d\u4e86,\u5982\u679c\u8fd8\u4e0a\u4e0d\u4e86\u5916\u7f51\uff0c\u5c31\u662fDNS\u7684\u95ee\u9898\u4e86<\/p>\n<p>dns\u4fee\u6539<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# vim \/etc\/resolv.conf  \r\nnameserver 8.8.8.8  \r\nnameserver 8.8.4.4  \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5pptp\u5ba2\u6237\u7aef\u8f6f\u4ef6 ~ sudo apt-get install pptp-linux \u67e5\u770b\u7f51\u7edc\u914d\u7f6e ~  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6016","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6016"}],"version-history":[{"count":3,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6016\/revisions"}],"predecessor-version":[{"id":6026,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6016\/revisions\/6026"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}