怎样在oracle virtualbox里添加网卡

我想在oracle virtualbox里添加一块儿网卡,用于内部网络,和另一台机器做Heartbeat心跳测试。

怎样添加呢?

关闭虚拟机,添加一块虚拟网卡:


启动虚拟机后,此时还查看不到新加的网卡:

[root@slave2 ~]# ifconfig

eth0     Link encap:Ethernet  HWaddr08:00:27:04:05:16 
         inet addr:10.192.200.202 Bcast:10.192.200.255 Mask:255.255.255.0
         inet6 addr: fe80::a00:27ff:fe04:516/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST MTU:1500  Metric:1
         RX packets:321 errors:0 dropped:0 overruns:0 frame:0
         TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:33576 (32.7 KiB)  TXbytes:5508 (5.3 KiB)
 
lo       Link encap:Local Loopback 
         inet addr:127.0.0.1 Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING MTU:16436  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:0 (0.0 b)  TX bytes:0(0.0 b)

[root@slave2 ~]#cd /etc/sysconfig/network-scripts/

[root@slave2 network-scripts]# cp ifcfg-eth0 ifcfg-eth1

[root@slave2 network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated bythe /lib/udev/write_net_rules
# program, run by thepersistent-net-generator.rules rules file.
#
# You can modify it, as long as you keepeach rule on a single
# line, and change only the value of theNAME= key.
 
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*",ATTR{address}=="08:00:27:04:05:16", ATTR{type}=="1",KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*",ATTR{address}=="08:00:27:3a:ec:3c", ATTR{type}=="1", KERNEL=="eth*",NAME="eth1"
 

[root@slave2 network-scripts]# vi ifcfg-eth1

改下DEVICE,HWADDR,IPADDR,删除GATEWAY

修改后:

[root@slave2 network-scripts]# cat ifcfg-eth1

DEVICE=eth1
HWADDR=08:00:27:3a:ec:3c
TYPE=Ethernet
#UUID=a4610b15-fc38-4984-875d-208599054e37
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.0.0.2
NETMASK=255.255.255.0

注意:用于内连的网卡不能设置网关,否则会连不上网。

注意:MAC地址HWADDR一定得和/etc/udev/rules.d/70-persistent-net.rules文件中的eth1保持一致,否则servicenetwork restart会报错:

Bringing up interface eth1:  Device eth1 does not seem to be present,delaying initialization.

                                                          [FAILED]


 [root@slave2network-scripts]# service network restart

Shutting down interface eth0:                              [  OK  ]

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth0:  Determining if ip address 10.192.200.202 isalready in use for device eth0...

                                                          [  OK  ]

Bringing up interface eth1:  Determining if ip address 10.0.0.2 is alreadyin use for device eth1...

                      

                                   [  OK  ]

 [root@slave2 network-scripts]# ifconfig

eth0      Link encap:Ethernet  HWaddr 08:00:27:04:05:16  
          inet addr:10.192.200.202  Bcast:10.192.200.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe04:516/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3303 errors:0 dropped:0 overruns:0 frame:0
          TX packets:343 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:339469 (331.5 KiB)  TX bytes:49274 (48.1 KiB)


eth1      Link encap:Ethernet  HWaddr 08:00:27:3A:EC:3C  
          inet addr:10.0.0.2  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe3a:ec3c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:636 (636.0 b)


lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值