欢迎来到代码驿站!

当前位置:首页 >

Ubuntu虚拟机多网卡配置

时间:2021-07-30 08:14:03|栏目:|点击:

 本文为大家分享了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)系统实现多网段各自通信,每次启动修改默认网关

上一篇:在docker中运行mariadb程序的方法

栏    目:

下一篇:docker 容器上编译 go 程序提示找不到文件问题

本文标题:Ubuntu虚拟机多网卡配置

本文地址:http://www.codeinn.net/misctech/162696.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有