SO: Ubuntu 16.04.3
Configurando uma ponte KVM entre minha placa ethernet (eno1), guest (s) (vnet0) e bridge (br0)
Eu tenho minha bridge funcionando corretamente com minha placa de rede para que minha máquina tenha acesso WAN ao meu roteador.
Eu tenho acompanhado estes guias:
Nenhum endereço IPv4 atribuído à VM KVM
Aqui estão as configurações da interface para br0: #interfaces (5) arquivo usado por ifup (8) e ifdown (8) auto lo iface lo inet loopback
# Ethernet
iface eno1 inet manual
# Bridge
auto br0
iface br0 inet static
hwaddress ether 40:16:7e:28:0e:60
address 192.168.1.200
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.254
broadcast 192.168.1.255
bridge_ports eno1
bridge_stp off
bridge_fd 0
dns-nameservers 192.168.1.254 8.8.8.8 8.8.8.4
Quando exposto:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether 40:16:7e:28:0e:60 brd ff:ff:ff:ff:ff:ff
3: wlp13s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 54:27:1e:97:32:16 brd ff:ff:ff:ff:ff:ff
53: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
82: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:53:24:54:a5 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
181: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 40:16:7e:28:0e:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.200/24 brd 192.168.1.255 scope global br0
valid_lft forever preferred_lft forever
inet6 2001:569:737d:a300:4216:7eff:fe28:e60/64 scope global mngtmpaddr dynamic
valid_lft 14700sec preferred_lft 14400sec
inet6 fe80::4216:7eff:fe28:e60/64 scope link
valid_lft forever preferred_lft forever
182: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
link/ether fe:57:13:a9:fb:22 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc57:13ff:fea9:fb22/64 scope link
valid_lft forever preferred_lft forever
Finalmente eu tenho isso em /etc/sysctl.d/bridge.conf
net.bridge.bridge-nf-call-ip6tables=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0
recarregado com:
sysctl -p /etc/sysctl.d/bridge.conf
Ok, no lado da VM, estou usando o terraform com um provedor de libvirt link
Eu não mostrarei o arquivo terraform como fora do escopo, mas o xml que ele gera é assim.
<domain type='kvm' id='40'>
<name>ubuntu1</name>
<uuid>4bd33601-b6a1-4863-a230-8b3ea4dfa48c</uuid>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/ubuntu-qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/commoninit.iso'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<readonly/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<controller type='ide' index='0'>
<alias name='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='ea:57:13:a9:fb:22'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/18'/>
<target type='isa-serial' port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/18'>
<source path='/dev/pts/18'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<console type='pty'>
<source path='/dev/pts/19'/>
<target type='virtio' port='1'/>
<alias name='console1'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-ubuntu1/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' port='5900' autoport='yes'>
<listen type='address'/>
</graphics>
<video>
<model type='cirrus' vram='16384' heads='1'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
<rng model='virtio'>
<backend model='random'>/dev/random</backend>
<alias name='rng0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</rng>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-4bd33601-b6a1-4863-a230-8b3ea4dfa48c</label>
<imagelabel>libvirt-4bd33601-b6a1-4863-a230-8b3ea4dfa48c</imagelabel>
</seclabel>
</domain>
Quando a VM estiver em funcionamento, isso será ip addr
returns:
E brctl show:
bridge name bridge id STP enabled interfaces
br0 8000.40167e280e60 no eno1
vnet0
docker0 8000.0242532454a5 no
e virsh addrs não mostram nada para a interface para eu conectar também:
> virsh domifaddr ubuntu1 vnet0
Name MAC address Protocol Address
-------------------------------------------------------------------------------
Espero que o endereço IP seja preenchido com base na conexão das pontes ao meu roteador. Meu roteador doméstico tem uma reserva dhcp para o host, mas eu esperaria que os convidados estivessem recebendo um ip também?
Qualquer orientação sobre como obter um IP para VM disponível na LAN seria apreciada.