Networking
刪除特定介面的預設路由的正確語法?
概括:
me@client:~$ sudo route del default ppp0 SIOCDELRT: No such process me@client:~$ sudo route del default dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default gw 10.144.15.234 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default netmask 128.0.0.0 gw 10.144.15.234 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default gw 0.0.0.0 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default netmask 255.255.255.255 gw 0.0.0.0 dev ppp0 SIOCDELRT: No such process
細節:
我正在嘗試在正在執行的筆記型電腦(稱為“客戶端”)上調試與 VPN 相關的錯誤配置
me@client:~$ cat /etc/debian_version jessie/sid me@client:~$ uname -rv 3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13) me@client:~$ gcc --version | head -n 1 gcc (Debian 4.8.2-1) 4.8.2 me@client:~$ sudo route --version [sudo] password for tlroche: net-tools 1.60 route 1.98 (2001-04-15) +NEW_ADDRT +RTF_IRTT +RTF_REJECT +I18N AF: (inet) +UNIX +INET +INET6 +IPX +AX25 +NETROM +X25 +ATALK +ECONET +ROSE HW: +ETHER +ARC +SLIP +PPP +TUNNEL -TR +AX25 +NETROM +X25 +FR +ROSE +ASH +SIT +FDDI +HIPPI +HDLC/LAPB +EUI64
在這個客戶端上,我啟動了一個 OpenVPN 客戶端(之前在雲中啟動了一個 OpenVPN 伺服器之後),登錄到一個遠端訪問網站,並使用該站點的 Web UI 連接到一個(專有的)F5 SSL VPN(我想要通過 OpenVPN 建立隧道)。(有關設計目標和問題配置的更多詳細資訊,請點擊此處。)這會產生
me@client:~$ date ; sudo ifconfig Thu Jan 22 11:48:43 EST 2015 eth0 Link encap:Ethernet HWaddr <omitted/> inet addr:192.168.1.142 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: <omitted/> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:10224715 errors:0 dropped:0 overruns:0 frame:0 TX packets:6011530 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12886933501 (12.0 GiB) TX bytes:677423768 (646.0 MiB) Interrupt:20 Memory:f2600000-f2620000 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:497 errors:0 dropped:0 overruns:0 frame:0 TX packets:497 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:51273 (50.0 KiB) TX bytes:51273 (50.0 KiB) # Note I get slightly different IP#s for interface=ppp0 each time I run this scenario. ppp0 Link encap:Point-to-Point Protocol inet addr:10.144.15.234 P-t-P:10.144.0.1 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:56 (56.0 B) TX bytes:2418 (2.3 KiB) tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.8.0.6 P-t-P:10.8.0.5 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:304 (304.0 B) TX bytes:304 (304.0 B) me@client:~$ date ; sudo route -n Thu Jan 22 11:48:48 EST 2015 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.144.15.100 128.0.0.0 UG 1 0 0 ppp0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 10.144.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0 128.0.0.0 10.144.15.100 128.0.0.0 UG 1 0 0 ppp0 134.67.15.30 10.8.0.5 255.255.255.255 UGH 1 0 0 tun0
到那時,我被指示(IIUC)刪除由 F5VPN 設置的預設路由(在 interface= 上
ppp0
,用於調試。此外,我需要快速執行此操作,因為(這是目前配置錯誤的問題) 配置錯誤導致 OpenVPN 隧道快速失敗,這打破了我想調試的情況。因此,我似乎無法找到正確的
route
語法來執行此操作,這非常令人氣憤:me@client:~$ sudo route del default ppp0 SIOCDELRT: No such process me@client:~$ sudo route del default dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default gw 10.144.15.234 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default netmask 128.0.0.0 gw 10.144.15.234 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default gw 0.0.0.0 dev ppp0 SIOCDELRT: No such process me@client:~$ sudo route del -net default netmask 255.255.255.255 gw 0.0.0.0 dev ppp0 SIOCDELRT: No such process
info route
沒有幫助,我的網路搜尋也沒有找到有用的文件。(這兩種情況都可能是由於我缺乏網路經驗。)我做錯了什麼?
根據您在問題中包含的路由表,您沒有指向 的預設路由
ppp0
,因此您無法刪除它。(“沒有這樣的過程”在這裡是指“沒有這樣的路線”)。Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.144.15.100 128.0.0.0 UG 1 0 0 ppp0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
這是指向 0.0.0.0/1 的路由(不是預設路由,預設路由是 0.0.0.0/0),指向 10.144.15.100 使用
ppp0
,以及指向 192.168.1.1 的預設路由 outeth0
。順便說一句,在 Linux 上,您應該使用
ip
命令而不是ifconfig
、route
和其他命令。使用的語法和輸出格式ip
更加直覺,易於理解和使用。您應該能夠分別看到上述兩條路線(以及所有其他路線)
ip route
並刪除它們:ip route del 0.0.0.0/1 via 10.144.15.100 ip route del default via 192.168.1.1