服务器 
首页 > 服务器 > 浏览文章

Ubuntu虚拟机多网卡配置

(编辑:jimmy 日期: 2024/9/21 浏览:3 次 )

 本文为大家分享了Ubuntu虚拟机多网卡配置,供大家参考,具体内容如下

1、场景说明

系统平台:Ubuntu16.04
服务器:VMWare workstation 虚拟机12c
解决问题:添加4块网卡(四个网段、四个网关),第4个网卡nat上网,但是默认路由有问题

2、网卡配置内容

root@Ocommon:~# cat /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 ens32
iface ens32 inet static
address 1.1.1.2
netmask 255.255.255.0
gateway 1.1.1.1

#auto ens33
iface ens33 inet static
address 2.2.2.2
netmask 255.255.255.0
gateway 2.2.2.1

#auto ens34
iface ens34 inet static
address 3.3.3.2
netmask 255.255.255.0
gateway 3.3.3.1

#auto ens35
iface ens35 inet dhcp

注意:
但是在都添加“#auto ens3*”后启动就会出现错误,所以将#auto ens3*全部去掉,但是启动就出现不能网卡不能正常显示。

3、Ubuntu虚拟机多网卡配置补充内容

按照以上配置Ubuntu16.04虚拟机网卡配置后,需要解决网卡启动,多网段路由问题

cat >/etc/init.d/configNetwork<<EOF11
ifup ens32
ifup ens33
ifup ens34
ifup ens35
route add -net 1.1.1.0 gw 1.1.1.1
route add -net 2.2.2.0 gw 2.2.2.1
route add -net 3.3.3.0 gw 3.3.3.1
route del default gw 1.1.1.1 
route add default gw 192.168.137.2 dev ens35
EOF11
chmod 111 /etc/init.d/configNetwork
sed -i '/exit 0/i\bash /etc/init.d/configNetwork' /etc/rc.local

以上配置实现了:
1)系统启动时,运行自定义的脚本(Ubuntu16.04启动执行脚本略有差异)
2)系统启动时脚本执行启动网卡动作
3)系统实现多网段各自通信,每次启动修改默认网关

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

上一篇:Linux 下sftp配置之密钥方式登录详解
下一篇:详解阿里云CentOS Linux服务器上用postfix搭建邮件服务器
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap