Vpn

需要創建路由以繞過將全部流量分配為預設路由的 VPN

  • April 24, 2019

我有 2 個 VPN:utun0 和 ppp0。

ip r s
default via 175.15.105.123 dev utun0
default via 192.168.0.1 dev en0
127.0.0.0/8 via 127.0.0.1 dev lo0
169.254.0.0/16 dev en0  scope link
10.0.15.0/24 via ppp0 dev ppp0

當我連接到 utun0 時,ppp0 停止工作,因為它為自己分配了完整的網路連接。

但我希望 ppp0 服務仍然可用,即 10.0.15.0/24

當我嘗試創建路線時

ip route add 10.0.15.0/24 via 10.0.15.100 dev en0

它沒有幫助,所有請求仍然無效

更新

ip l s
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
   options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
   nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1300
   ether 60:f8:1d:b1:f8:5c 
   nd6 options=201<PERFORMNUD,DAD>
   media: autoselect
   status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
   ether 02:f8:1d:b1:f8:5c 
   media: autoselect
   status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
   ether ea:3a:29:c1:d5:a3 
   nd6 options=201<PERFORMNUD,DAD>
   media: autoselect
   status: active
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
   options=60<TSO4,TSO6>
   ether 72:00:07:7c:d8:b0 
   media: autoselect <full-duplex>
   status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
   options=60<TSO4,TSO6>
   ether 72:00:07:7c:d8:b1 
   media: autoselect <full-duplex>
   status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
   options=63<RXCSUM,TXCSUM,TSO4,TSO6>
   ether 72:00:07:7c:d8:b0 
   Configuration:
       id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
       maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
       root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
       ipfilter disabled flags 0x2
   member: en1 flags=3<LEARNING,DISCOVER>
           ifmaxaddr 0 port 8 priority 0 path cost 0
   member: en2 flags=3<LEARNING,DISCOVER>
           ifmaxaddr 0 port 9 priority 0 path cost 0
   nd6 options=201<PERFORMNUD,DAD>
   media: <unknown type>
   status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1200
   nd6 options=201<PERFORMNUD,DAD>
ip a s
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
   inet 127.0.0.1/8 lo0
   inet6 ::1/128
   inet6 fe80::1/64 scopeid 0x1
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1300
   ether 60:f8:1d:b1:f8:5c
   inet6 fe80::60:f174:65a8:ec30/64 secured scopeid 0x5
   inet 192.168.0.141/24 brd 192.168.0.255 en0
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
   ether ea:3a:29:c1:d5:a3
   inet6 fe80::e83a:29ff:fec1:d5a3/64 scopeid 0x7
ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1080
   inet 10.0.15.100 --> 10.0.15.0/24 ppp0
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1200
   inet 175.15.105.123 --> 175.15.105.123/32 utun0

自己解決了。

sudo route add -net 192.168.0.141/24 gw en0

現在可以了。

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