为ubuntu配置多网段多个ip地址

lc@lc-virtual-machine:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback


#网卡名字
auto ens33

#将网卡设置为静态
iface ens33 inet static

#设置ip
address 192.168.0.128
#address 192.168.250.123/24

#设置子网掩码
netmask 255.255.255.0

#设置网关
gateway 192.168.0.1

#dns服务器
dns-nameserver 114.114.114.114

 


#将网卡设置为静态
iface ens33:0 inet static

#设置ip
address 192.168.250.128

---------------------------------------------------------------------------------------------------------

lc@lc-virtual-machine:~$ sudo /etc/init.d/networking restart 
[ ok ] Restarting networking (via systemctl): networking.service.
参考连接:https://wiki.ubuntu.org.cn/Quick_HOWTO_:_Ch03_:_Linux_Networking/zh

 

 

你可能感兴趣的:(随笔)