LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 06-04-2023, 02:46 PM   #1
Chewbakka
LQ Newbie
 
Registered: Dec 2004
Posts: 5

Rep: Reputation: 0
Qemu/KVM Bridging


Hello,
I have a host machine running a FreeBSD vm, which i need to provide with Internet connectivity.

I tried the following:
On my host machine i created a bridged ip link add bridge0 type bridge, secondly i created a tap interface to be used by the vm. ip tuntap add tap0 type tap, next i associated the tap device with the bridge interface: ip link set tap0 master bridge0. The vm is given an address in the bridged network 172.16.10.0/24.

When launching the vm, i give the following parameters to qemu "-netdev tap,id=net1,ifname=tap0 -device virtio-net-pci,netdev=net1"

Next i added iptables rules to the host machine:
iptables -t nat -A POSTROUTING -s 172.16.10.0/24 -o eno1 -j MASQUERADE where eno1 is the host machines interface.

Enable routing:
sysctl -w net.ipv4.ip_forward=1

#Allow traffic and related/established connections on the Forwarding chain:
iptables -A FORWARD -i bridge0 -o eno1 -j ACCEPT
iptables -A FORWARD -s 172.16.10.0/24 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

The vm is able to ping the host machines bridge0 on 172.16.10.100, but no Internet connectivity.
Any idea what i am missing here?
 
Old 06-06-2023, 08:41 AM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,020

Rep: Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630
Where did you get this example to use?

https://wiki.qemu.org/Documentation/Networking#Tap

Make it easier maybe by starting with -nic tap??
 
Old 06-06-2023, 12:59 PM   #3
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 798

Rep: Reputation: 256Reputation: 256Reputation: 256
What's the routing table look like?

Code:
ip -c route show
default via 74.x.x.1 dev eth0 proto dhcp src 74.x.x.131 metric 1002 
74.x.x.0/19 dev eth0 proto dhcp scope link src 74.x.x.131 metric 1002 
127.0.0.0/8 dev lo scope link 
192.168.20.0/24 dev br0 proto kernel scope link src 192.168.20.1
Code:
ip link add name br0 type bridge
ip link set br0 type bridge stp_state 1
ip tuntap add dev tap0 mode tap
ip link set dev tap0 master br0
I usually forward everything, net.ipv4.conf.all.forwarding = 1, and run a DHCP server servicing br0.
Code:
INTERNAL_NETWORK="192.168.20.0/24"
iptables -t nat -A POSTROUTING -m comment --comment "Masquerading LAN rfc1918 addresses" -s $INTERNAL_NETWORK -j MASQUERADE
Code:
qemu-system-i386 -m 512m -cdrom windows_me_115_oem_full.iso -cpu pentium3 -boot order=c,menu=on -rtc base=localtime -device pci-serial-4x -vga cirrus -device ich9-intel-hda -device hda-output,audiodev=snd0 -device AC97,audiodev=snd0 -audiodev pa,id=snd0  -device pcnet,netdev=net0,mac=52:54:00:12:34:57 -netdev tap,ifname=tap7,id=net0,script=no,downscript=no -hda c_harddisk_me_sf.img -serial pty -daemonize
Note Qemu syntax has changed radically over the years. This is 8.0.2.

taps6-8 aren't in use right now.
Code:
ip -c link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 6c:4b:90:17:7c:1d brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 60:14:b3:6f:a3:bf brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether aa:00:04:00:01:04 brd ff:ff:ff:ff:ff:ff
5: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 42:b6:75:ba:10:d3 brd ff:ff:ff:ff:ff:ff
6: tap1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 4a:80:2e:b0:c6:06 brd ff:ff:ff:ff:ff:ff
7: tap2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 3e:fd:17:41:5f:e7 brd ff:ff:ff:ff:ff:ff
8: tap3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 6a:a9:5a:71:f1:84 brd ff:ff:ff:ff:ff:ff
9: tap4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether e2:69:d1:cf:8c:7e brd ff:ff:ff:ff:ff:ff
10: tap5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 2a:c6:57:e1:10:03 brd ff:ff:ff:ff:ff:ff
11: tap6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 6a:14:62:8f:d9:40 brd ff:ff:ff:ff:ff:ff
12: tap7: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT group default qlen 1000
    link/ether c6:d4:7f:06:9d:af brd ff:ff:ff:ff:ff:ff
13: tap8: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN mode DEFAULT group default qlen 1000
    link/ether b6:38:5f:33:11:62 brd ff:ff:ff:ff:ff:ff
 
Old 06-06-2023, 03:02 PM   #4
Chewbakka
LQ Newbie
 
Registered: Dec 2004
Posts: 5

Original Poster
Rep: Reputation: 0
So i figured out the issue ...
The problem was that i had nftables running concurrently with iptables and update-alternatives pointed to nft..sigh.
Anyways i appreciate the help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "No KVM, No qemu-kvm" Available error while trying to install KVM on CentOS 6.3 sriramdas Linux - Virtualization and Cloud 5 01-01-2013 10:46 AM
LXer: Set up qemu-kvm-1.0+noroms as spice enabled qemu server vs qemu-kvm-spice on Ubuntu Precise LXer Syndicated Linux News 0 05-26-2012 07:41 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM
LXer: Attempt of qemu-kvm-0.14 patching via Gerd’s Hoffmann “spice/qxl: locking fix for qemu-kvm” on LXer Syndicated Linux News 0 03-14-2011 01:20 PM
VMWare's bridging vs Window's bridging - routing is messed up when Windows bridging brenan99 General 0 05-04-2008 10:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration