Ubuntu虚拟机多网卡配置

2025-05-27 0 53

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

1、场景说明

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

2、网卡配置内容

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32
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虚拟机网卡配置后,需要解决网卡启动,多网段路由问题

?

1

2

3

4

5

6

7

8

9

10

11

12

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

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

原文链接:http://blog.csdn.net/kingredfly/article/details/53894319

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 行业资讯 Ubuntu虚拟机多网卡配置 https://www.kuaiidc.com/68621.html

相关文章

发表评论
暂无评论