Como criar múltiplos VNICs no kvm?

0

Instalei o kvm no Ubuntu e criei uma máquina virtual. Eu quero criar VNIC s no mesmo. Como posso fazer isso?

    
por Aishwarya Gupte 09.09.2015 / 08:15

1 resposta

0

instalação openvswitch:

# apt-get install \
    openvswitch-controller \
    openvswitch-switch \
    openvswitch-datapath-source

Pontes Creare:

# ovs-vsctl add-br br0
# ovs-vsctl add-br br1

# ovs-vsctl show
fb28566b-aada-4cf6-8260-ca5677d8c014
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
    Bridge "br1"
        Port "br1"
            Interface "br1"
                type: internal
    ovs_version: "2.0.2"

Configure o / etc / network / interfaces:

# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto br0
iface br0 inet static
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255

auto br1
iface br1 inet static
address 192.168.1.1
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255

Up interfaces:

# ifup br0
# ifup br1

# ip -4 a show br0
4: br0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default 
    inet 192.168.0.1/24 brd 192.168.0.255 scope global br0
       valid_lft forever preferred_lft forever

# ip -4 a show br1
5: br1: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default 
    inet 192.168.1.1/24 brd 192.168.1.255 scope global br1
       valid_lft forever preferred_lft forever

Crie redes libvirt:

# cat br0.xml 
<network>
  <name>br0</name>
  <forward mode='bridge'/>
  <bridge name='br0'/>
  <virtualport type='openvswitch'/>
</network>

# cat br1.xml 
<network>
  <name>br1</name>
  <forward mode='bridge'/>
  <bridge name='br1'/>
  <virtualport type='openvswitch'/>
</network>

defina e inicie as redes:

# virsh net-define br0.xml 
# virsh net-start  br0
# virsh net-autostart  br0

# virsh net-define br1.xml 
# virsh net-start  br1
# virsh net-autostart  br1

# virsh net-list
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 br0                  active     yes           yes
 br1                  active     yes           yes

Crie vm:

# qemu-img create -f raw /opt/test.img 3G

# virt-install \
  --ram 1024 \
  --accelerate \
  --disk path=/opt/test.img \
  --name test \
  --network network:br0 \
  --network network:br1 \
  --vcpus 1 \
  --graphics vnc,listen=0.0.0.0 \
  --cdrom ubuntu-14.04.3-server-amd64.iso

Conclua a instalação, efetue login na nova vm e configure a rede:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0

auto eth1
iface eth1 inet static
address 192.168.1.2
netmask 255.255.255.0

Acima de interfaces de rede:

# ifup eth0
# ifup eth1

Verifique o ping do host:

# ping -c 1 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=1.11 ms

--- 192.168.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.118/1.118/1.118/0.000 ms

# ping -c 1 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=2.89 ms

--- 192.168.1.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.897/2.897/2.897/0.000 ms
    
por e42d3 13.09.2015 / 16:38