View previous topic :: View next topic |
Author |
Message |
hypeboyz n00b
Joined: 26 Feb 2012 Posts: 24
|
Posted: Sun Mar 23, 2014 5:37 am Post subject: Cannot get tun/tap work for qemu |
|
|
Hi
I'm learning to set up network for qemu manually. My guest OS is openindiana, or the descendant of opensolaris if you think the former name is too weird.
My laptop is connected to the WIFI network so I add -b parameter to enable the wifi interface bridging for wpa_supplicant and this is my /etc/conf.d/net:
Code: |
modules="wpa_supplicant"
config_enp6s0="dhcp"
config_wlp2s0="dhcp"
wpa_supplicant_wlp2s0="-b br0 -D wext -d -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf"
routes_wlp2s0="192.168.1.1"
|
After boot I add the bridge br0 interface with brctl utility as rc-update is not able to initialize the bridge interface (don't know why)
and bring up the tun/tap kernel module by modprobe tun
Then I started the qemu with the following script:
Code: |
qemu-system-x86_64 -cpu host -hda ./oi_hd.qcow2 -m 1G -sdl\
-cdrom oi-dev-151a8-live-x86.iso -boot c -enable-kvm \
-monitor stdio \
-device e1000,netdev=hn0 \
-netdev tap,id=hn0,helper=/usr/libexec/qemu-bridge-helper
|
No warning prompts so I assume the nic is connected to tap device. And with the qemu-bridge-helper I don't have to null out my physical device's IP address.
And my ifconfig after virtual machine was started:
Code: |
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.52.197 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::e9:83ff:fe90:4596 prefixlen 64 scopeid 0x20<link>
ether fe:09:5a:a7:f7:c7 txqueuelen 0 (Ethernet)
RX packets 57 bytes 8800 (8.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 54 bytes 9338 (9.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp6s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:13:77:9e:0c:d5 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19
tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.244.113 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::fc09:5aff:fea7:f7c7 prefixlen 64 scopeid 0x20<link>
ether fe:09:5a:a7:f7:c7 txqueuelen 500 (Ethernet)
RX packets 24 bytes 4184 (4.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 40 bytes 8188 (7.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.105 netmask 255.255.255.0 broadcast 255.255.255.255
inet6 fe80::216:eaff:fe61:e6e2 prefixlen 64 scopeid 0x20<link>
ether 00:16:ea:61:e6:e2 txqueuelen 1000 (Ethernet)
RX packets 230 bytes 20609 (20.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 58 bytes 7379 (7.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
wlp2s0 is my WIFI device and enp6s0 is the wired network adapter (I deleted loopback devices info). Both tap and br possess an IP address having a netmask of 16 bits. But in the guest os network preference the default route was blanked out and I have no idea about which IP address shall I fill in. I tried both IP address of tap and br, neither works. DHCP cannot allocate the IP address for me.
I wondered if anyone could draw a picture or describe the relationship between tap, bridge and guest network interface
Any answers are appreciated! Thank you! |
|
Back to top |
|
|
Mad Merlin Veteran
Joined: 09 May 2005 Posts: 1155
|
Posted: Thu Mar 27, 2014 5:44 pm Post subject: |
|
|
I'm going to assume you're not using your wired interface here, and that you're only using the wireless interface.
Multiple problems:
1) Your wireless interface still has an IP address assigned to it. If you try to bridge it this way, it absolutely will not work. After bridging, this IP address should be on the bridge, with no IP assigned to the wireless interface.
2) It doesn't look like you've bridged wlp2s0 into br0. tap0 bridged into br0 at this point will go nowhere.
3) You cannot, in general, use wireless adaptors with bridging, 802.11 does not like multiple MAC addresses coming from one device.
4) Your tap device is assigned an IP address. Taps should not have an IP address assigned to them, that network configuration is done in the guest.
5) You're trying to configure the guest network on the host. The guest network is configured in the guest, and cannot have any of the same IP or MAC addresses as on the host. _________________ Game! - Where the stick is mightier than the sword! |
|
Back to top |
|
|
hypeboyz n00b
Joined: 26 Feb 2012 Posts: 24
|
Posted: Wed Apr 02, 2014 7:58 am Post subject: |
|
|
Mad Merlin wrote: | I'm going to assume you're not using your wired interface here, and that you're only using the wireless interface.
Multiple problems:
1) Your wireless interface still has an IP address assigned to it. If you try to bridge it this way, it absolutely will not work. After bridging, this IP address should be on the bridge, with no IP assigned to the wireless interface.
2) It doesn't look like you've bridged wlp2s0 into br0. tap0 bridged into br0 at this point will go nowhere.
3) You cannot, in general, use wireless adaptors with bridging, 802.11 does not like multiple MAC addresses coming from one device.
4) Your tap device is assigned an IP address. Taps should not have an IP address assigned to them, that network configuration is done in the guest.
5) You're trying to configure the guest network on the host. The guest network is configured in the guest, and cannot have any of the same IP or MAC addresses as on the host. |
Ah, thanks. I didn't try the wired bridging and on the qemu tutorial there's no need to manually null the ip address out with bridgehelper. I'll try that later with the script that zero the ip address. This is also what I want to ask, why shall we set the network IP to 0 for bridging? Assuming I access internet by that wired interface, my default router cannot even find my computer if the ip was set to 0.
And yes I know the wireless interface cannot be added to the bridge. But what if I add -b br0 to the wpa_supplicant startup arguments? For now the wireless interface is brought up automatically even it's not listed in rc default list. Hardly can I find a way to disable the wireless interface since I don't know where it was enabled after all. If I can do so, I think adding -b argument could be a solution to the problem that wireless interface was not attached to the bridge.
Thank you! |
|
Back to top |
|
|
Mad Merlin Veteran
Joined: 09 May 2005 Posts: 1155
|
Posted: Wed Apr 02, 2014 1:19 pm Post subject: |
|
|
hypeboyz wrote: | Mad Merlin wrote: | I'm going to assume you're not using your wired interface here, and that you're only using the wireless interface.
Multiple problems:
1) Your wireless interface still has an IP address assigned to it. If you try to bridge it this way, it absolutely will not work. After bridging, this IP address should be on the bridge, with no IP assigned to the wireless interface.
2) It doesn't look like you've bridged wlp2s0 into br0. tap0 bridged into br0 at this point will go nowhere.
3) You cannot, in general, use wireless adaptors with bridging, 802.11 does not like multiple MAC addresses coming from one device.
4) Your tap device is assigned an IP address. Taps should not have an IP address assigned to them, that network configuration is done in the guest.
5) You're trying to configure the guest network on the host. The guest network is configured in the guest, and cannot have any of the same IP or MAC addresses as on the host. |
Ah, thanks. I didn't try the wired bridging and on the qemu tutorial there's no need to manually null the ip address out with bridgehelper. I'll try that later with the script that zero the ip address. This is also what I want to ask, why shall we set the network IP to 0 for bridging? Assuming I access internet by that wired interface, my default router cannot even find my computer if the ip was set to 0.
And yes I know the wireless interface cannot be added to the bridge. But what if I add -b br0 to the wpa_supplicant startup arguments? For now the wireless interface is brought up automatically even it's not listed in rc default list. Hardly can I find a way to disable the wireless interface since I don't know where it was enabled after all. If I can do so, I think adding -b argument could be a solution to the problem that wireless interface was not attached to the bridge.
Thank you! |
If you use the wired interface for bridging, then it doesn't matter what the state of the wireless interface is.
The reason you clear the IP address from the bridged interface is because that interface must pass traffic through to the bridge for all traffic, not just traffic matching the assigned IP address. This is why the bridge interface takes the IP address normally assigned to the wired interface.
When using wireless, the typical setup is to use NAT. You bridge all your VMs into one bridge and use a distinct private IP range on that bridge (both for the host and guests), from there you set the default gateway in the guests to the IP address of the bridge and add iptables rules on the host to NAT the outbound traffic accordingly. In this setup, your wireless interface setup would not need to change. _________________ Game! - Where the stick is mightier than the sword! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|