一、单个网卡配置多个IP
root@ubuntu:~# vim /etc/network/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
# The primary network interface
auto eth0 //这台主机只有 eth0 这张网卡
iface eth0 inet static
address 11.11.11.1
netmask 255.255.255.0
gateway 11.11.11.254
dns-nameserver 11.11.11.254
auto eth0:0 //配置子ip eth0:0
iface eth0:0 inet static
address 11.11.11.2
netmask 255.255.255.0
auto eth0:1 //配置子ip eth0:1
iface eth0:1 inet static
address 11.11.11.3
netmask 255.255.255.0
auto eth0:2 //配置子ip eth0:2 ;接着可以依次类推
iface eth0:2 inet static
address 11.11.11.4
netmask 255.255.255.0
二、添加DNS
root@ubuntu:~# vim /etc/resolvconf/resolv.conf.d/head
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
nameserver 11.11.11.254 # 添加这一行
三、刷新DNS
root@ubuntu:~# resolvconf -u
四、重新启动网络服务
systemctl restart networking