据我所知,基本网络配置进入/etc/network/interfaces
,系统根据这些信息生成路由表。我还被教导,通常/etc/network/interfaces
是永久添加自定义命令来操作路由表的地方(有时也建议/etc/rc.local
使用自定义脚本/etc/network/if-up.d/
)。此外,可以指定自定义路由表/etc/iproute2/rt_tables
。
- 是否有其他地方会影响(主要)路由表?
- 特别是除了
/etc/network/interfaces
手动添加/删除路线之外还有其他可能性吗?
- 特别是除了
- 具有多个NIC的系统是否具有主要和次要网络接口的概念,或者这些仅用于帮助用户的措辞?(在设置过程中,必须选择主要的if和
/etc/network/interfaces
将包含适当的注释。)如果存在这样的概念,它可以在哪里配置? - Debian Squeeze和Debian Jessie之间的路由表概念有什么不同吗?
我的问题的背景是我有一个遗留的Debian Squeeze系统和一个新的Debian Jessie系统,它使用不同的路由表启动但是(据我所知)配置相同。我可以手动操作路由表以满足我的需求并使更改永久使用,/etc/network/interfaces
但我想了解发生了什么。
编辑
以下是两台机器的配置文件。出于隐私原因,我更改了每个IP地址的第一部分。但是,子网和各个网络的地址部分没有改变。在/etc/network/interfaces.d/
该杰西机器上的目录是空的。
/etc/iproute2/rt_tables
在Jessie
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
/etc/iproute2/rt_tables
在Squeeze
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
/etc/rc.local
在Jessie
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
/etc/rc.local
在Squeeze
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
/etc/network/interfaces
在Jessie
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address 143.103.155.254
netmask 255.255.255.0
network 143.103.155.0
gateway 143.103.155.254
# The primary network interface
auto eth2
iface eth2 inet static
address 27.126.19.194
netmask 255.255.255.248
network 27.126.19.192
broadcast 27.126.19.199
gateway 27.126.19.193
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 143.103.5.1
dns-search subdomain.domain.de
/etc/network/interfaces
在Squeeze
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 143.103.155.254
netmask 255.255.255.0
network 143.103.155.0
gateway 143.103.155.254
auto eth2
iface eth2 inet static
address 27.126.19.194
netmask 255.255.255.248
network 27.126.19.192
broadcast 27.126.19.199
gateway 27.126.19.193
ip route show table main
Jessie的输出
default via 143.103.155.254 dev eth1
143.103.155.0/24 dev eth1 proto kernel scope link src 143.103.155.254
27.126.19.192/29 dev eth2 proto kernel scope link src 27.126.19.194
ip route show table main
Squeeze的输出
27.126.19.192/29 dev eth2 proto kernel scope link src 27.126.19.194
143.103.155.0/24 dev eth0 proto kernel scope link src 143.103.155.254
default via 27.126.19.193 dev eth2
default via 143.103.155.254 dev eth0 scope link
route -n
Jessie的输出
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 143.103.155.254 0.0.0.0 UG 0 0 0 eth1
143.103.155.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
27.126.19.192 0.0.0.0 255.255.255.248 U 0 0 0 eth2
route -n
Squeeze的输出
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
27.126.19.192 0.0.0.0 255.255.255.248 U 0 0 0 eth2
143.103.155.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 27.126.19.193 0.0.0.0 UG 0 0 0 eth2
0.0.0.0 143.103.155.254 0.0.0.0 UG 0 0 0 eth0
gateway
选项时,它意味着通过该接口的默认路由。您确定要通过2个接口进行默认路由吗?同样对于eth0 / eth1,网关就是你的服务器本身......为什么?
gateway 143...
从Jessie中删除时,它根本没有任何默认路由条目route -n
或ip route
?