Debian服务器配置内外双网口

debian 配置网络和其他Linux类服务器不太一样,debian主要的配置都在 /etc/network/interfaces 文件内,可以配置每个网络接口的IP获取方式和网关地址,同时也是在这里面配置路由转发等。

目前的现状:

enp6s0 连接内网
enp11s0 连接外网

希望的状态:

所有内网的请求通过enp6s0 过来的都走 enp6s0 返回,所有服务器出口的访问和更新,都走 enp11s0 出去,需要在最底部添加一条路由,告诉服务器所有内网的请求走单独的网关(gw)和设备(dev)返回,以下是我的 interfaces文件内的配置:

# 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

# Primary
auto enp6s0
iface enp6s0 inet static
address 192.168.69.84
netmask 255.255.255.0

# Second
auto enp11s0
iface enp11s0 inet static
address 192.168.1.102
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 114.114.114.114 114.114.115.115
# 下面表示,所有 192.168 开头的内网请求都走内网的网关和设备返回
up route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.69.254 dev enp6s0

标签:debian, 服务器, 双网口