View previous topic :: View next topic |
Author |
Message |
vastchen n00b
Joined: 22 Apr 2016 Posts: 55
|
Posted: Tue Jun 07, 2022 1:58 pm Post subject: [ SLOVE]How qemu Virt-manager systemd bridge net static ip |
|
|
Code: |
systemd
Create the bridge:
FILE /etc/systemd/network/vmbridge.netdev
[NetDev]
Name=vmbridge
Kind=bridge
Configure the bridge's address:
FILE /etc/systemd/network/10-vmbridge.network
[Match]
Name=vmbridge
[Network]
Description=Your awesome VM bridge
Address=10.0.42.1/24
FILE /your/path/to/qemu/stuff/addtobridge.sh
#!/usr/bin/env bash
# Bring the QEMU TAP device up and add it to the bridge
ip link set "$1" master vmbridge
ip link set "$1" up
|
Code: |
<interface type="bridge">
<mac address="22:52:00:1d:5d:79"/>
<source bridge="vmbridge"/>
<target dev="vnet0"/>
<model type="virtio"/>
<alias name="net0"/>
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>
|
no use how to set systemd qemu bridge network?
I use
Code: |
/bin/bash
vde_switch -tap tap0 -daemon -mod 660 -group users
ip link set tap0 up
brctl addbr br0
brctl addif br0 enp3s0
brctl addif br0 tap0
dhcpcd br0
|
can connect internet but can't set staic
change dhcpcd br0 to ip addr add 192.168.1.29 no work.
I know OpenRC set net bu in systemd how to set Virt-manager br0 ? _________________ gentoo user
Last edited by vastchen on Wed Jun 08, 2022 1:58 am; edited 1 time in total |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Tue Jun 07, 2022 5:04 pm Post subject: |
|
|
You need to set a simple bridge containing an ethernet interface as a slave.
Then In virt -manager you assign this bridge to the guest VM.
When the VM boots it will be assigned an ip by dhcp,together with routing and dns info.
When you log into the guest you use its network config to set the Ip to static.
To create a bridge on the host via networkd you need three files
Something like
Code: |
1.
/etc/systemd/network/br0.netdev
###containing
[NetDev]
Name=br0
Kind=bridge
2.
/etc/systemd/network/eth0.network
###containing
[Match]
Name=eth0
[Network]
Bridge=br0
3.
/etc/systemd/network/br0.network
### containing
[Match]
Name=br0
[Network]
Address=192.168.0.2/24
Gateway=192.168.0.1
DNS=192.168.0.1
|
Then enable systemd-networkd.
Thats it.
Then in the host you will be using br0 as your interface and you will be able to assign this bridge to any VM that needs to share host LAN , as opposed to being assigned a NAT internal network which is the virt-manager default.
Quote: |
I use
Code:
/bin/bash
vde_switch -tap tap0 -daemon -mod 660 -group users
ip link set tap0 up
brctl addbr br0
brctl addif br0 enp3s0
brctl addif br0 tap0
dhcpcd br0
|
plz dont do that.It is completely unnecessary and complicated. _________________
|
|
Back to top |
|
|
vastchen n00b
Joined: 22 Apr 2016 Posts: 55
|
Posted: Wed Jun 08, 2022 1:57 am Post subject: |
|
|
alamahant wrote: | You need to set a simple bridge containing an ethernet interface as a slave.
Then In virt -manager you assign this bridge to the guest VM.
When the VM boots it will be assigned an ip by dhcp,together with routing and dns info.
When you log into the guest you use its network config to set the Ip to static.
To create a bridge on the host via networkd you need three files
Something like
Code: |
1.
/etc/systemd/network/br0.netdev
###containing
[NetDev]
Name=br0
Kind=bridge
2.
/etc/systemd/network/eth0.network
###containing
[Match]
Name=eth0
[Network]
Bridge=br0
3.
/etc/systemd/network/br0.network
### containing
[Match]
Name=br0
[Network]
Address=192.168.0.2/24
Gateway=192.168.0.1
DNS=192.168.0.1
|
Then enable systemd-networkd.
Thats it.
Then in the host you will be using br0 as your interface and you will be able to assign this bridge to any VM that needs to share host LAN , as opposed to being assigned a NAT internal network which is the virt-manager default.
Quote: |
I use
Code:
/bin/bash
vde_switch -tap tap0 -daemon -mod 660 -group users
ip link set tap0 up
brctl addbr br0
brctl addif br0 enp3s0
brctl addif br0 tap0
dhcpcd br0
|
plz dont do that.It is completely unnecessary and complicated. |
Thanks a lot. At last night i saw this https://wiki.gentoo.org/wiki/Network_bridge and slove. _________________ gentoo user |
|
Back to top |
|
|
|