111*_*--- 5 networking debian gateway
简单的设置在这里。我有一台带有多个网络接口的机器,例如两个 -eth0
和eth1
.
eth0
有一个静态地址并分配了一个默认网关。
eth1
具有静态地址,并且在该接口的网络地址范围内没有网关。
在上面的示例中,我是否需要在网络配置文件 ( /etc/network/interfaces
) 中为gateway
在其网络上没有网关的接口上的选项添加一个条目eth1
?
如果我做这样的事情:
gateway 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
这会产生不良影响吗?这个接口现在是否有办法到达网关,或者使用环回接口作为网关是否无效(即与gateway
完全关闭该选项相同)?
/etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# Interface 1
allow-hotplug eth0
iface eth0 inet static
address 10.1.10.200
netmask 255.255.255.0
gateway 10.1.10.1
# Interface 2
allow-hotplug eth1
iface eth1 inet static
address 192.168.100.1
netmask 255.255.0.0
gateway 127.0.0.1 # This is the line in question
Run Code Online (Sandbox Code Playgroud)
你不需要gateway
任何NIC,你不想使用它的冲突域(在这种情况下,192.168 / 16),以达到网络没有进入。如果您不想要该 NIC 的网关,则可以省略该行。
我不确定如果您尝试使用环回作为网关会发生什么,但我不希望它是快乐的时光。