这是我的网络配置在运行 Ubuntu v16.04.3 LTS 的笔记本电脑上:
luis@Hipatio:~$ ifconfig
enp2s0 Link encap:Ethernet direcciónHW 68:f7:28:d2:a4:ce
Direc. inet:192.168.11.119 Difus.:192.168.11.255 Másc:255.255.255.0
Dirección inet6: fe80::6af7:28ff:fed2:a4ce/64 Alcance:Enlace
ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST MTU:1500 Métrica:1
Paquetes RX:1330 errores:0 perdidos:0 overruns:0 frame:0
Paquetes TX:915 errores:0 perdidos:0 overruns:0 carrier:0
colisiones:0 long.colaTX:1000
Bytes RX:121080 (121.0 KB) TX bytes:85100 (85.1 KB)
enx3c18a00b753d Link encap:Ethernet direcciónHW 3c:18:a0:0b:75:3d
Direc. inet:192.168.11.2 Difus.:192.168.11.255 Másc:255.255.255.0
Dirección inet6: fe80::4c9d:de01:a97a:fd42/64 Alcance:Enlace
ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST MTU:1500 Métrica:1
Paquetes RX:10 errores:0 perdidos:0 overruns:0 frame:0
Paquetes TX:38 errores:0 perdidos:0 overruns:0 carrier:0
colisiones:0 long.colaTX:1000
Bytes RX:2203 (2.2 KB) TX bytes:5468 (5.4 KB)
lo Link encap:Bucle local
Direc. inet:127.0.0.1 Másc:255.0.0.0
Dirección inet6: ::1/128 Alcance:Anfitrión
ACTIVO BUCLE FUNCIONANDO MTU:65536 Métrica:1
Paquetes RX:24 errores:0 perdidos:0 overruns:0 frame:0
Paquetes TX:24 errores:0 perdidos:0 overruns:0 carrier:0
colisiones:0 long.colaTX:1
Bytes RX:1925 (1.9 KB) TX bytes:1925 (1.9 KB)
我如何 ping,比如说,Internet(8.8.8.8
),从第二个接口(enx3c18a00b753d
)?
已测试失败:
luis@Hipatio:~$ ping -I enx3c18a00b753d -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.22.51 enx3c18a00b753d: 56(84) bytes of data.
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms
主适配器工作正常:
luis@Hipatio:~$ ping -I enp2s0 -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.11.119 enp2s0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=51.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=52.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=50.9 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=50.8 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=55 time=51.0 ms
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 50.812/51.498/52.995/0.826 ms
luis@Hipatio:~$ ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=51 time=57.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=51 time=57.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=51 time=57.0 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=51 time=57.1 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=51 time=57.6 ms
这是我的路由表:
luis@Hipatio:~$ sudo route
Tabla de rutas IP del núcleo
Destino Pasarela Genmask Indic Métric Ref Uso Interfaz
default Router- 0.0.0.0 UG 0 0 0 enp2s0
default 192.168.22.1 0.0.0.0 UG 100 0 0 enx3c18a00b753d
link-local * 255.255.0.0 U 1000 0 0 enp2s0
192.168.11.0 * 255.255.255.0 U 0 0 0 enp2s0
192.168.22.0 * 255.255.255.0 U 100 0 0 enx3c18a00b753d
进一步说明:
- 这种 ping 方法适用于v14.04。也许我配置错误了。
- 此 ping 方法适用于 KaliLinux v2。
- 这个答案这里接近答案,但停在“用谷歌搜索”。
答案1
尝试ip route get 8.8.8.8 from 192.168.22.51
检查你的路由表。它可能会显示enp2s0
。