2

I simply want that my QEMU VMs have a public IP so I can run multiple servers in the same machine. I've read a lot of wikis, guides, tutorials, forum threads and anything related to this but still no useful answer. I already know about the bridges thing and I did all of what most tutorials do.

1) Create the bridge with iproute2 (say br0)
2) Create the TAP interface (say tap0)
3) Bridge eth0 (in my case enp2s0) and tap0 to br0

But the only thing I've got is (besides a headache) to make the VM be recognized as another machine in the internal network, but what I want is that the external network sees my machine with its own public IP address, not the same as the rest of the physical machines connected to the router.

Pages I've looked into:
- https://wiki.archlinux.org/index.php/QEMU#Networking
- https://wiki.archlinux.org/index.php/Network_bridge
- KVM - Adding public IP over bridge
- http://blog.elastocloud.org/2015/07/qemukvm-bridged-network-with-tap.html
- https://wiki.qemu.org/Documentation/Networking
- http://nairobi-embedded.org/a_qemu_tap_networking_setup.html
- https://en.wikibooks.org/wiki/QEMU/Networking

My QEMU cmd args:

qemu-system-x86_64 \
    -monitor stdio \
    -soundhw ac97 \
    -k es \
    -machine accel=kvm \
    -m 2024 \
    -hda /mnt/hdd/Desarrollo_Eficiente_HDA.img \
    -boot once=c,menu=on \
    -net nic,vlan=0,macaddr=00:c6:cd:1a:5e:83,model=virtio \
    -net tap,vlan=0,ifname=tap0,script=no \
    -rtc base=localtime \

Other command outputs:

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.003067a647ca       no              enp2s0
                                                        tap0
$ ip address 
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 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 00:30:67:a6:47:ca brd ff:ff:ff:ff:ff:ff
    inet6 fe80::da85:a46d:3e50:2642/64 scope link 
       valid_lft forever preferred_lft forever
9: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:30:67:a6:47:ca brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.3/24 brd 192.168.0.255 scope global noprefixroute br0
       valid_lft forever preferred_lft forever
    inet 192.168.50.14/24 brd 192.168.50.255 scope global noprefixroute br0
       valid_lft forever preferred_lft forever
    inet6 fe80::230:67ff:fea6:47ca/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
10: tap0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN group default qlen 100
    link/ether 16:51:80:cd:dd:6b brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1451:80ff:fecd:dd6b/64 scope link 
       valid_lft forever preferred_lft forever

Host System info:
- OS: Parabola GNU/Linux-libre (Arch-based)
- Architecture: x86_64

Have I missed something? an iptables rule? a sysctl command? Thanks in advance for the help.

Megver83
  • 221
  • 2
  • 4
  • 10
  • Do yourself a favor, use libvirt / virt-manager. It can automatically add the VM's network interface to the bridge for you. And it relieves you of the burden of manually creating qemu command lines. – Michael Hampton Mar 20 '18 at 17:25
  • I'd like that, but virt-manager fails on my system https://unix.stackexchange.com/questions/430066/cpu-mode-custom-for-x86-64-kvm-domain-on-x86-64-host-is-not-supported-by-hyper – Megver83 Mar 20 '18 at 18:32
  • In that case, I recommend you follow my previous advice. – Michael Hampton Mar 20 '18 at 19:10

0 Answers0