Skip to main content
added 32 characters in body
Source Link

According to KVM's docs, it is not possible to use a bridge with a wireless NIC. I do not know the reason why even though I used to bridge the guest on VirtualBox.

I have spent some few hours to figure out how to connect the guest to the host's wireless network and I found out the easiest way to do it is using a TAP device. The only disadvantage of this method is that you can't use DHCP on the guest and you have to manually give it an IP address from the wireless network subnet (Which may cause IP conflicts or inconvenience in case of deploying lots of VMs).

Here are the steps to connect the guest on the host's wireless network using a TAP device:

0/ Enable IPv4 routing for the Linux kernel

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

1/ Create a tap device named tap0 accessible from user guest (Replace with your username) without sudo:

sudo ip tuntap add mode tap tap0 user guest

2/ Assign an IP address to the tap0 device (It doesn't have to be from the wireless network subnet):

sudo ip addr add 10.10.10.10/24 dev tap0

sudo ip addr add 10.10.10.10/24 dev tap0 sudo ip link set tap0 up 

3/ Use parprouted (You might have to install it) to implement proxy arp bridging which allows bridging the guest Ethernet behind the host's wireless NIC.

sudo parprouted wlan0 tap0

(Replace wlan0 with your host's wireless interface)

4/ Adding some routing tables entries to allows packets to travel through the ends of the tap device:

sudo iptables -A INPUT -i tap0 -j ACCEPT sudo iptables -A FORWARD -i tap0 -j ACCEPT sudo iptables -A FORWARD -o tap0 -j ACCEPT 

On the guest assign a static IP address from the host's wireless network subnet. For example if your wlan0 is on 192.168.1.0/24 then the guest can be configured with

sudo ip addr add 192.168.1.30/24 dev eth0

(eth0 is your guest's NIC)

or permanently in /etc/network/interfaces with:

auto eth0 iface eth0 inet static address 192.168.1.30 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.25 

Launch your guest with:

kvm -hda guest.img -m 512 -net nic -net tap,ifname=tap0,script=no 

Now pinging works between all machines connected on your wireless network and the guests.

According to KVM's docs, it is not possible to use a bridge with a wireless NIC. I do not know the reason why even though I used to bridge the guest on VirtualBox.

I have spent some few hours to figure out how to connect the guest to the host's wireless network and I found out the easiest way to do it is using a TAP device. The only disadvantage of this method is that you can't use DHCP on the guest and you have to manually give it an IP address from the wireless network subnet (Which may cause IP conflicts or inconvenience in case of deploying lots of VMs).

Here are the steps to connect the guest on the host's wireless network using a TAP device:

0/ Enable IPv4 routing for the Linux kernel

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

1/ Create a tap device named tap0 accessible from user guest (Replace with your username) without sudo:

sudo ip tuntap add mode tap tap0 user guest

2/ Assign an IP address to the tap0 device (It doesn't have to be from the wireless network subnet):

sudo ip addr add 10.10.10.10/24 dev tap0

3/ Use parprouted (You might have to install it) to implement proxy arp bridging which allows bridging the guest Ethernet behind the host's wireless NIC.

sudo parprouted wlan0 tap0

(Replace wlan0 with your host's wireless interface)

4/ Adding some routing tables entries to allows packets to travel through the ends of the tap device:

sudo iptables -A INPUT -i tap0 -j ACCEPT sudo iptables -A FORWARD -i tap0 -j ACCEPT sudo iptables -A FORWARD -o tap0 -j ACCEPT 

On the guest assign a static IP address from the host's wireless network subnet. For example if your wlan0 is on 192.168.1.0/24 then the guest can be configured with

sudo ip addr add 192.168.1.30/24 dev eth0

(eth0 is your guest's NIC)

or permanently in /etc/network/interfaces with:

auto eth0 iface eth0 inet static address 192.168.1.30 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.25 

Launch your guest with:

kvm -hda guest.img -m 512 -net nic -net tap,ifname=tap0,script=no 

Now pinging works between all machines connected on your wireless network and the guests.

According to KVM's docs, it is not possible to use a bridge with a wireless NIC. I do not know the reason why even though I used to bridge the guest on VirtualBox.

I have spent some few hours to figure out how to connect the guest to the host's wireless network and I found out the easiest way to do it is using a TAP device. The only disadvantage of this method is that you can't use DHCP on the guest and you have to manually give it an IP address from the wireless network subnet (Which may cause IP conflicts or inconvenience in case of deploying lots of VMs).

Here are the steps to connect the guest on the host's wireless network using a TAP device:

0/ Enable IPv4 routing for the Linux kernel

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

1/ Create a tap device named tap0 accessible from user guest (Replace with your username) without sudo:

sudo ip tuntap add mode tap tap0 user guest

2/ Assign an IP address to the tap0 device (It doesn't have to be from the wireless network subnet):

sudo ip addr add 10.10.10.10/24 dev tap0 sudo ip link set tap0 up 

3/ Use parprouted (You might have to install it) to implement proxy arp bridging which allows bridging the guest Ethernet behind the host's wireless NIC.

sudo parprouted wlan0 tap0

(Replace wlan0 with your host's wireless interface)

4/ Adding some routing tables entries to allows packets to travel through the ends of the tap device:

sudo iptables -A INPUT -i tap0 -j ACCEPT sudo iptables -A FORWARD -i tap0 -j ACCEPT sudo iptables -A FORWARD -o tap0 -j ACCEPT 

On the guest assign a static IP address from the host's wireless network subnet. For example if your wlan0 is on 192.168.1.0/24 then the guest can be configured with

sudo ip addr add 192.168.1.30/24 dev eth0

(eth0 is your guest's NIC)

or permanently in /etc/network/interfaces with:

auto eth0 iface eth0 inet static address 192.168.1.30 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.25 

Launch your guest with:

kvm -hda guest.img -m 512 -net nic -net tap,ifname=tap0,script=no 

Now pinging works between all machines connected on your wireless network and the guests.

Source Link

According to KVM's docs, it is not possible to use a bridge with a wireless NIC. I do not know the reason why even though I used to bridge the guest on VirtualBox.

I have spent some few hours to figure out how to connect the guest to the host's wireless network and I found out the easiest way to do it is using a TAP device. The only disadvantage of this method is that you can't use DHCP on the guest and you have to manually give it an IP address from the wireless network subnet (Which may cause IP conflicts or inconvenience in case of deploying lots of VMs).

Here are the steps to connect the guest on the host's wireless network using a TAP device:

0/ Enable IPv4 routing for the Linux kernel

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

1/ Create a tap device named tap0 accessible from user guest (Replace with your username) without sudo:

sudo ip tuntap add mode tap tap0 user guest

2/ Assign an IP address to the tap0 device (It doesn't have to be from the wireless network subnet):

sudo ip addr add 10.10.10.10/24 dev tap0

3/ Use parprouted (You might have to install it) to implement proxy arp bridging which allows bridging the guest Ethernet behind the host's wireless NIC.

sudo parprouted wlan0 tap0

(Replace wlan0 with your host's wireless interface)

4/ Adding some routing tables entries to allows packets to travel through the ends of the tap device:

sudo iptables -A INPUT -i tap0 -j ACCEPT sudo iptables -A FORWARD -i tap0 -j ACCEPT sudo iptables -A FORWARD -o tap0 -j ACCEPT 

On the guest assign a static IP address from the host's wireless network subnet. For example if your wlan0 is on 192.168.1.0/24 then the guest can be configured with

sudo ip addr add 192.168.1.30/24 dev eth0

(eth0 is your guest's NIC)

or permanently in /etc/network/interfaces with:

auto eth0 iface eth0 inet static address 192.168.1.30 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.25 

Launch your guest with:

kvm -hda guest.img -m 512 -net nic -net tap,ifname=tap0,script=no 

Now pinging works between all machines connected on your wireless network and the guests.