ubuntu 16 添加多个IP

多个不同IP段的 /etc/network/interfaces 配置文件的范例如下:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 8.8.8.2
netmask 255.255.255.248
gateway 8.8.8.1 要注意这里,多个不同IP段,只要1个gateway配置即可,其他IP不需要配置gateway
dns-nameservers 8.8.8.8 8.8.4.4

auto eth0:0
iface eth0:0 inet static
address 8.8.8.3
netmask 255.255.255.248
dns-nameservers 8.8.8.8 8.8.4.4

auto eth0:1
iface eth0:1 inet static
address 8.8.8.4
netmask 255.255.255.248
dns-nameservers 8.8.8.8 8.8.4.4

auto eth0:2
iface eth0:2 inet static
address 8.8.8.5
netmask 255.255.255.248
dns-nameservers 8.8.8.8 8.8.4.4

auto eth0:3
iface eth0:3 inet static
address 8.8.8.6
netmask 255.255.255.248
dns-nameservers 8.8.8.8 8.8.4.4

auto eth0:4
iface eth0:4 inet static
address 6.6.6.130 注意这里,虽然这是不同的IP段,但是不需要配置gateway,只需要配置netmask即可
netmask 255.255.255.224
dns-nameservers 8.8.8.8 8.8.4.4

更多ip也类似配置即可。

配置文件完成后,用命令 /etc/init.d/networking restart /reload重启网络

 转载于:https://www.cnblogs.com/qunshu/p/3236807.html

猜你喜欢

转载自www.cnblogs.com/rui517hua20/p/13405873.html