我正在尝试找到一种方法来使我的网络服务正常工作,因此网络服务重新启动工作。
我该如何设置这 20 个 IP,使用 2 个不同的网关,但只有 1 个 NIC?使用 2 个 NIC 不会有任何问题,但使用 1 个 NIC 可以吗?
这是我尝试使用以下命令重新启动它时得到的结果systemctl restart networking.service
:
Feb 06 22:37:40 v4033 ifup[1276]: ifup: failed to bring up eth0:16
Feb 06 22:37:40 v4033 ifup[1276]: RTNETLINK answers: File exists
Feb 06 22:37:40 v4033 ifup[1276]: ifup: failed to bring up eth0:17
Feb 06 22:37:40 v4033 ifup[1276]: RTNETLINK answers: File exists
Feb 06 22:37:40 v4033 ifup[1276]: ifup: failed to bring up eth0:18
Feb 06 22:37:40 v4033 ifup[1276]: RTNETLINK answers: File exists
Feb 06 22:37:40 v4033 ifup[1276]: ifup: failed to bring up eth0:19
Feb 06 22:37:40 v4033 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Feb 06 22:37:40 v4033 systemd[1]: networking.service: Failed with result 'exit-code'.
Feb 06 22:37:40 v4033 systemd[1]: Failed to start Raise network interfaces.
对IPS的解释:
45.XX.XX.XX are the first IP's from subnet 1 with Gateway 45.XX.XX.1
5.XX.XX.XX are the second IP's subnet 2 with Gateway 5.XX.XX.1
我的/etc/network/interfaces
样子是这样的:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 45.XX.XX.XX
gateway 45.XX.XX.1
netmask 255.255.255.0
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
auto eth0:1
iface eth0:1 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:2
iface eth0:2 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:3
iface eth0:3 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:4
iface eth0:4 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:5
iface eth0:5 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:6
iface eth0:6 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:7
iface eth0:7 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:8
iface eth0:8 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:9
iface eth0:9 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:10
iface eth0:10 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:11
iface eth0:11 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:12
iface eth0:12 inet static
address 45.XX.XX.XX
netmask 255.255.255.0
auto eth0:13
iface eth0:13 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:13 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.1 dev eth0:13 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX9/32 table rt2
auto eth0:14
iface eth0:14 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:14 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:14 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
auto eth0:15
iface eth0:15 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:15 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:15 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
auto eth0:16
iface eth0:16 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:16 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:16 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
auto eth0:17
iface eth0:17 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:17 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:17 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
auto eth0:18
iface eth0:18 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:18 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:18 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
auto eth0:19
iface eth0:19 inet static
address 5.XX.XX.XX
netmask 255.255.255.0
post-up ip route add 5.XX.XX.0/24 dev eth0:19 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:19 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
我有一个/etc/iproute2/rt_tables
如下所示的内容:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 rt2
提前致谢!
答案1
我认为问题在于你重复
post-up ip route add 5.XX.XX.0/24 dev eth0:16 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0:16 table rt2
post-up ip rule add from 5.XX.XX.XX/32 table rt2
post-up ip rule add to 5.XX.XX.XX/32 table rt2
对于所有别名接口。我认为你应该只使用一次,并且不带别名标识符:
post-up ip route add 5.XX.XX.0/24 dev eth0 src 5.XX.XX.XX table rt2
post-up ip route add default via 5..XX.XX.XX.1 dev eth0 table rt2
post-up ip rule add from 5.XX.XX.XX/24 table rt2
post-up ip rule add to 5.XX.XX.XX/24 table rt2