Ubuntu虚拟机多网卡配置

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

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

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

本文链接:https://my.lmcjl.com/post/3989.html

展开阅读全文

4 评论

留下您的评论.