You are not logged in.

#1 2018-08-25 16:18:10

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Ping vm from other subnet

I have 2 real hardware machines (Toshiba Notebook and Acer Netbook) are connected to the Internet through Samsung Galaxy Tab in Wi-Fi HotSpot mode. Machines can ping each other ok. Then, create a virtual bridge interface on Toshiba Notebook and set forwarding for this bridge and real external wi-fi interface.

# Create bridge and assign its IP address
ip link add name qemu_br1 type bridge
ip link set qemu_br1 up
ip addr add 192.168.4.1/24 dev qemu_br1

# Enable packet forwarding
sysctl net.ipv4.conf.wlp5s0.forwarding=1
sysctl net.ipv4.conf.qemu_br1.forwarding=1

# Use iptables to enable NAT
iptables -t nat -A POSTROUTING -o wlp5s0 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i qemu_br1 -o wlp5s0 -j ACCEPT

Then, switch on dhcpd on Notebook.
dhcpd.conf

option domain-name-servers 8.8.8.8, 8.8.4.4;
option subnet-mask 255.255.255.0;
subnet 192.168.4.0 netmask 255.255.255.0 {
  range 192.168.4.2 192.168.4.255;
  option routers 192.168.4.1;
}
# No DHCP service for Wi-Fi network (192.168.1.0/24)
subnet 192.168.1.0 netmask 255.255.255.0 {

Then, I start QEMU with bridge-helper which creates virtual tap interface.

qemu-system-x86_64 \
	-monitor stdio \
	-enable-kvm \
	-cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time \
	-smp cpus=2 \
	-m 1G \
	-vga virtio \
	-display gtk,gl=on \
	-soundhw ac97 \
	-netdev tap,helper=/usr/lib/qemu/qemu-bridge-helper,br=qemu_br1,id=network0,vhost=on \
	-device virtio-net,netdev=network0,mac=52:54:00:00:00:02 \
	-drive file=/ehdd/qemu/arch_hw_12_08_2018/arch_shrinked.raw,format=raw,if=virtio

I can ping second real hardware machine (Acer Netbook) from QEMU virtual machine, but can't do vice versa.
What should I do to second hardware machine can see (ping) QEMU virtual machine?
Structure of my network

Offline

Board footer

Powered by FluxBB