Buscar este blog

martes, 23 de junio de 2015

CentOS - Virtual Box - Multiple network interfaces

I want to have my virtual machine with three different IPs.

First, you have to configure Virtual Box in host-only mode in order to create a private network between host and guest.



In this case I also configured a NAT adapter, because I also wanted to download some packages from internet, but for the purpose of this blog, this is not required.

The Virtual Box configuration was left by default, so in my case, the IP base  will be 192.168.56.1.





In CentOS you have to configure three network interfaces in /etc/sysconfig/network-scripts dir:

ifcfg-eth1:1
DEVICE=eth1:1
HWADDR=08:00:27:6D:9D:BC
TYPE=Ethernet
UUID=c67f2833-f261-456b-ac86-ab2635ea5432
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.56.102
NETMASK=255.255.255.0

ifcfg-eth1:2
DEVICE=eth1:2
HWADDR=08:00:27:6D:9D:BC
TYPE=Ethernet
UUID=c67f2833-f261-456b-ac86-ab2635ea5432
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.56.101
NETMASK=255.255.255.0

ifcfg-eth1:3
DEVICE=eth1:3
HWADDR=08:00:27:6D:9D:BC
TYPE=Ethernet
UUID=c67f2833-f261-456b-ac86-ab2635ea5432
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.56.103
NETMASK=255.255.255.0

HWADDR represent de MAC address of the virtual machine (the same asigned by Virtual Box in the Host-only Adapter).

And last, manually enable these interfaces:

[root@localhost ~]# ifup eth1:1
[root@localhost ~]# ifup eth1:2
[root@localhost ~]# ifup eth1:3
[root@localhost ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:A0:8B:F2
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea0:8bf2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3678 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1921 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4290059 (4.0 MiB)  TX bytes:107006 (104.4 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:6D:9D:BC
          inet6 addr: fe80::a00:27ff:fe6d:9dbc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:275178 errors:0 dropped:0 overruns:0 frame:0
          TX packets:142674 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:174304706 (166.2 MiB)  TX bytes:8161346 (7.7 MiB)

eth1:1    Link encap:Ethernet  HWaddr 08:00:27:6D:9D:BC
          inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1:2    Link encap:Ethernet  HWaddr 08:00:27:6D:9D:BC
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1:3    Link encap:Ethernet  HWaddr 08:00:27:6D:9D:BC
          inet addr:192.168.56.103  Bcast:192.168.56.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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:65536  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 hay comentarios:

Publicar un comentario