One*_*ero 11 networking 11.10 ping
我有 3 个网卡,1 个 LAN(有线),1 个无线网卡和 1 个无线 USB
我如何从特定网卡ping通?
以及如何将特定网卡用于特定应用程序
例子
i want to ping google from wlan0
Run Code Online (Sandbox Code Playgroud)
特定应用示例
i want to use firefox or transmission from wan1
Run Code Online (Sandbox Code Playgroud)
Lan ip 192.168.0.2 > 工作正常
WLAN1 ip 192.168.0.3
pin -I wlan1 google.com
Run Code Online (Sandbox Code Playgroud)
尝试粘贴 route -n 和/或 ip route 的输出。在我看来 wlan1 接口没有配置有效的网关。–@Shunz 先生
one@onezero:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
172.16.221.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan1
192.168.48.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
one@onezero:~$ ip route
default via 192.168.0.1 dev eth0 proto static
169.254.0.0/16 dev eth0 scope link metric 1000
172.16.221.0/24 dev vmnet8 proto kernel scope link src 172.16.221.1
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.2 metric 1
192.168.0.0/24 dev wlan1 proto kernel scope link src 192.168.0.3 metric 2
192.168.48.0/24 dev vmnet1 proto kernel scope link src 192.168.48.1
Run Code Online (Sandbox Code Playgroud)
ping
有一个特定的开关来设置源接口:-I
。如联机帮助页中所示:
-I interface address
Set source address to specified interface address. Argument may be numeric
IP address or name of device.
When pinging IPv6 link-local address this option is required.
Run Code Online (Sandbox Code Playgroud)
举个例子
$ ping -I wlan0 8.8.8.8
Run Code Online (Sandbox Code Playgroud)
通过 wlan0 接口 ping 8.8.8.8。
为特定应用程序强制接口需要做更多的工作。您可以在这个 superuser.com 问题和答案链接的这篇文章中找到解决方案。
更新
我在此答案中公开的方法显示了如何强制 ping 使用特定接口。以及一些关于如何强制通用程序使用特定接口的文章的链接。
现在,要使所有这些工作,您必须配置一些“高级”路由。正如您从输出中看到的,route -n
您有多个网络,但只有一个通往 Internet 的网关。这很好,因为多网关路由是一个相当高级的话题,而且处理起来有些困难。
这超出了您在原始问题中提出的问题。我建议您在此处或在Server Fault上发布一个新问题,询问如何在多个网络接口上配置和管理多个 Internet 网关。
或者,更好的是,尝试使用谷歌搜索它 ;) 还可以查看LARTC 站点以获取高级 linux 路由配置。
归档时间: |
|
查看次数: |
31555 次 |
最近记录: |