Rah*_*tam 7 routing dns dynamic-dns
在我的电脑上,我有两个网卡。两者都使用不同的互联网提供商服务。
两个互联网服务提供商都有不同的 DNS 服务器,我知道他们的 IP 地址。
我想确保在nslookup
发送查询时,它完全通过指定的接口。
就像是:
ping -I eth1 google.com
nslookup -I eth1 google.com
无论如何都是可能的,我知道没有-I
选择,我什至不希望它仅以这种方式具体。
我该怎么做?
这并不完全是nslookup
特定的,但应该在一般情况下工作(如果您的机器上有 root 访问权限)。它使用 IP 网络堆栈来确保您使用的是一个接口而不是另一个接口。在调用 nslookup 之前,只需通过特定的网络接口添加到您的 DNS 服务器 IP 地址的路由。
如果您有 2 个接口 (eth0
和eth1
),并且您的默认网关是通过eth0
(192.168.0.1),并且您想通过eth1
访问 Internet 的方式 192.168.1.1来查询 Google DNS (8.8.8.8) ,您可以执行以下操作:
ip route add 8.8.8.8/32 via 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
添加dev eth1
到命令没有用,因为应该只有一种方法可以访问 192.168.1.1。
完成后,您应该删除路由以恢复默认路由:
ip route del 8.8.8.8/32
Run Code Online (Sandbox Code Playgroud)
在curl中也有同样的选项。请告诉我们您想要实现什么目标?
你也可以使用dig @ipaddress yourquery
--interface <name>
Perform an operation using a specified interface. You can enter interface name, IP address or host name. An example
could look like:
Run Code Online (Sandbox Code Playgroud)