1
I am trying to virtualize my home server. I want to create multiple VMs for different purposes (1 VM for nf4 share server, 1 VM for owncloud, etc.). I need to be able to access this services (in the VMs) from outside world ofc. I am using qemu/kvm for creating VMs (linux host, linux and windows guests). This is what I do: On the host I create a tap interface and a bridge. Then I remove the IPs from the tap interface and my physical interface (eth0). Then I add eth0 and tap0 interfaces to my bridge (br0). Then I add IP to my bridge (the same IP I removed from eth0) and change the default gateway on the bridge to what it was on eth0.
sysctl net.ipv4.ip_forward=1
modprobe tun
ip tuntap add dev tap0 mode tap user ivailo
ip link add name br0 type bridge stp_state 0
ip link set br0 up
ip link set enp5s1 down
ip link set enp5s1 up promisc on
ip link set tap0 up promisc on
ip addr del 192.168.0.102/24 dev enp5s1
ip link set enp5s1 master br0
ip link set tap0 master br0
ip addr add 192.168.0.102/24 brd + dev br0
ip route add default via 192.168.0.1 dev br0
After this my internet works. BUT when i start my qemu VM with
sudo qemu-system-x86_64 -drive file=/usr/share/ovmf/ovmf_code_x64.bin,format=raw,readonly=on,if=pflash -enable-kvm -machine q35 -cpu host -smp cores=4,threads=1,maxcpus=4 -m 4048 -net nic,macaddr=02:68:b3:29:da:98 -net tap,ifname=tap0,script=no,downscript=no -drive file=~/debian.iso,index=0,media=cdrom
I don't have internet access from my VM (I can't ping google.bg, the host or any pc on the LAN, "network is unreachable").
I tried doing the same thing inside VMWare:
created 2 VMs with NAT network (they can talk between each other, access my LAN and Internet, but no device on my LAN except the host can access them (as it should be)). Then in first VM did the same thing i did before on the host (created tap,bridge, added eth0 and tap0 to br0 and started the qemu VM(with same command))
and the qemu VM inside first vmware vm was able to access internet and i was able to access/ping it from the second vm. This means I did set up everything correctly before.
So I came to the conclusion that my router is the problem. So I am going to buy a new one. But does the router need to support VLAN tagging to do this (to bridge my VM's tap device to my physical device and forward ports to the VM)
Sorry but I can't understand the reason for your question about you needing a router with vlan support. I can't see that you're currently using vlans right now. So what makes you think you would need a router with vlan support? – Rui Correia – 2017-04-09T09:18:04.017
I don't think I am dealing with VLANs but I was not entirely sure because I don't really know that much about networking. I was not entirely sure if that tap0 is just another interface like eth0 for example (which as far as I understand it is) or if it creates some kind of VLAN (which doesn't make sense but ...). – FieryRider – 2017-04-09T10:47:56.150