虚拟机linux双网卡,Ubuntu虚拟机多网卡配置

本文为大家分享了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<

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)系统实现多网段各自通信,每次启动修改默认网关

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值