Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] KVM / QEMU - Bridge interface
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
sluggeek
n00b
n00b


Joined: 21 May 2020
Posts: 36
Location: France

PostPosted: Sat Oct 23, 2021 1:15 pm    Post subject: [SOLVED] KVM / QEMU - Bridge interface Reply with quote

Hi everyone.

I try switching from Vbox to QEMU. I just have one issu.

I want my VM in the network of the host. So I need a bridge connection, like I do with Vbox.

I have delete the "default" virtual network in qemu

What I do (enp39s0 is my physical interface)

ip link add name br0 type bridge
ip link set enp39s0 master br0
ip link set br0 up

After that I proper configure VM to use br0.
And that works, my VM is on the same network : i can ssh, ping ...

BUT : my host cant use enp39s0 anymore ...

The problem is after the command
ip link set enp39s0 master br0 : after this the connection is lost.

Do you have any idea to have both the VM and the Host using enp39s0.

I apologise for my terrible english :(

Thx


Last edited by sluggeek on Sat Oct 23, 2021 4:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Oct 23, 2021 1:47 pm    Post subject: Reply with quote

I don't know the syntax of the new 'ip link' commands. But I can show you how I set up my bridge for QEMU with the traditional commands:
Code:
brctl addbr br0                  # create the bridge
brctl addif br0 eth0             # add physical interface
brctl addif br0 tap0             # add virtual interface for QEMU
brctl addif br0 tap1             # add virtual interface for QEMU
ifconfig br0 10.0.0.1/24 up      # set IP address of host
Back to top
View user's profile Send private message
sluggeek
n00b
n00b


Joined: 21 May 2020
Posts: 36
Location: France

PostPosted: Sat Oct 23, 2021 2:50 pm    Post subject: Reply with quote

I thanks to anwser.

I had always the same problem. After the brctl addif br0 enp39s0, the enp39s0 lost the connection :(
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Oct 23, 2021 3:39 pm    Post subject: Reply with quote

Without the bridge, the interface enp39s0 must be configured with your IP address.

With the bridge, the interface br0 must be configured with your IP address.

So yes, it is to be expected that you lose the connection if you add enp39s0 to your bridge. Configure br0 with your IP address after you added enp39s0 to your bridge - and you won't lose the connection. :)
Back to top
View user's profile Send private message
sluggeek
n00b
n00b


Joined: 21 May 2020
Posts: 36
Location: France

PostPosted: Sat Oct 23, 2021 4:29 pm    Post subject: Reply with quote

Hi Mike,

Thanks for the help. It works now :)

My mistake was to try to use "bridge" before understand how I works. I got it now.
Back to top
View user's profile Send private message
sluggeek
n00b
n00b


Joined: 21 May 2020
Posts: 36
Location: France

PostPosted: Sat Oct 23, 2021 4:53 pm    Post subject: Reply with quote

If somebody else have the same issu, here is the recipe :

Use sudo - Router is DHCP - physical interface in enp39s0

#Creation of bridge interface br0 and activation
ip link add name br0 type bridge
ip link set br0 up

#Activate enp39s0 if needed (you can't bridge a down interface).
ip link set enp39s0 up

#Flushing ip address on enp39s0 (if needed)
ip addr flush dev enp39s0

#Link enp39s0 to br0
ip link set eth0 master br0

#Obtain an IP for br0
dhclient -v br0

# check internet still working
ip a
ping www.google.com


After, configure the VM to use br0
-> network source : Brigde device
-> device name : br0

Launch the VM. Sometimes the VM internet connection works immediatly, sometimes it take 30s, don't panic :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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