# 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
# The primary network interface
auto eth0 # 内网
iface eth0 inet static
address 192.168.0.211
netmask 255.255.255.0
post-up ip route add 106.120.184.128/27 via 192.168.0.1 dev eth0 [src 106.38.199.74] 对某个IP端路由走eth0网卡,192.168.0.1网关 src伪造IP?
pre-down ip route del 106.120.184.128/27 via 192.168.0.1 dev eth0
auto eth1 # 外网
iface eth1 inet static
address 106.38.199.75
netmask 255.255.255.248
gateway 106.38.199.73 # 多网卡也只能配置一个网关.
dns-nameservers 119.29.29.29 114.114.114.114 # dns服务器
之后结合路由测试命令测试
route命令查看
root@daduryi:~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 106.38.199.73 0.0.0.0 UG 0 0 0 eth1
106.38.199.72 * 255.255.255.248 U 0 0 0 eth1
106.120.184.128 192.168.0.1 255.255.255.224 UG 0 0 0 eth0
172.17.0.0 * 255.255.0.0 U 0 0 0 docker0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
root@daduryi-1:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 106.38.199.73 0.0.0.0 UG 0 0 0 eno1
100.64.31.16 * 255.255.255.252 U 0 0 0 bond0
106.38.199.72 * 255.255.255.248 U 0 0 0 eno1
106.38.227.0 100.64.31.17 255.255.255.224 UG 0 0 0 bond0
106.38.227.64 100.64.31.17 255.255.255.224 UG 0 0 0 bond0
106.38.252.80 100.64.31.17 255.255.255.240 UG 0 0 0 bond0
106.120.184.128 100.64.31.17 255.255.255.224 UG 0 0 0 bond0
192.168.0.0 * 255.255.255.0 U 0 0 0 bond1
192.168.2.0 * 255.255.255.0 U 0 0 0 eno2
192.168.3.0 * 255.255.255.0 U 0 0 0 eno3