ubuntu系统单网卡配置多网段IP

发布时间 2023-03-24 15:08:51作者: xujienotes

环境

系统版本:Ubuntu 16.04.5 LTS

配置

ubuntu系统网卡文件是interfaces,修改网卡配置文件vim /etc/network/interfaces添加2个IP地址:

auto eth0:1
iface eth0:1 inet static
address 192.168.7.20
netmask 255.255.255.0

auto eth0:2
iface eth0:2 inet static
address 10.10.15.1
netmask 255.255.255.0

多个IP可以在后面追加eth0:3下面是添加上2个IP的interfaces文件所有内容

source /etc/network/interfaces.d/*
# Network is managed by Network manager
auto eth0

#iface eth0 inet dhcp

iface eth0 inet static
address 192.168.6.22
netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
address 192.168.7.20
netmask 255.255.255.0

auto eth0:2
iface eth0:2 inet static
address 10.10.15.1
netmask 255.255.255.0


auto lo
iface lo inet loopback

 配置完成后,重启reboot使其生效,查看ip配置