linux网络配置文件

# 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服务器

一dhcp一static 配置方案

两个static 配置方案

之后结合路由测试命令测试
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值