1. 程式人生 > >怎樣在oracle virtualbox裡新增網絡卡

怎樣在oracle virtualbox裡新增網絡卡

我想在oracle virtualbox裡新增一塊兒網絡卡,用於內部網路,和另一臺機器做Heartbeat心跳測試。

怎樣新增呢?

關閉虛擬機器,新增一塊虛擬網絡卡:


啟動虛擬機器後,此時還檢視不到新加的網絡卡:

[[email protected] ~]# 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)

[[email protected] ~]#cd /etc/sysconfig/network-scripts/

[[email protected] network-scripts]# cp ifcfg-eth0 ifcfg-eth1

[[email protected] 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"
 

[[email protected] network-scripts]# vi ifcfg-eth1

改下DEVICE,HWADDR,IPADDR,刪除GATEWAY

修改後:

[[email protected] 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]


 [[email protected]]# 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  ]

 [[email protected] 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)

相關推薦

no