PVE Setup vmbr
debian 11 安装 pve的配置网桥记录
安装
可以直接安装pve官方的iso镜像。
我是在自己笔记本上安装了debian 11,再安装的pve的软件包。
https://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_11_Bullseye
按照上面的说明进行,会遇到某些文件属于其他软件包,无法安装。 解决办法:
cd /var/cache/apt/archives/
sudo dpkg -i --force-overwrite *.deb
pve依赖ifupdown2,需要手动安装。
用法比较简单:
sudo ifquery -a
sudo ifup eth0
sudo ifdown eth0
另外,pve-manager服务启动失败的问题是因为hosts和hostname配置不对:
/etc/hosts
第二行127.0.1.1改成实际的ip;
fullhostname要和hostname吻合。
例如:
192.168.2.3 debian.v2less.com debian
网卡名称改为eth0格式
vi /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
硬件直通功能
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on pcie_acs_override=downstream"
sudo update-grub
重启系统后生效。
想要直通网卡的话,可以看一下网卡id:
sudo ethtool -i eth0
导入vmdk虚拟机镜像
pve管理界面先创建一个虚拟机,然后删除硬盘,并获得虚拟机id
qm importdisk 113 vmdkfilename.vmdk ceph_pool-01 -format qcow2
openwrt 安装
https://www.10bests.com/install-openwrt-lede-on-pve/
替换软件源:
sed -i 's/downloads.openwrt.org/mirrors.ustc.edu.cn\/openwrt/g' /etc/opkg/distfeeds.conf
遇到找不到wlan0的处理
sudo apt install rfkill
sudo rfkill list all
sudo rfkill unblock 3
#下面的三条命令可以不管,如果你也用networkmanager管理无线的话
sudo ifup wlan0
sudo iwconfig
sudo iwlist wlan0 scan|grep ESSID
NetworkManager和networking公用
pve使用networking管理网卡,配置文件 /etc/network/interfaces
NetworkManager默认也会管理网卡,如果不做配置会冲突。
NetworkManager使用插件keyfile屏蔽网卡:
vi /etc/NetworkManager/NetworkManager.conf :
[main]
plugins=ifupdown,keyfile
[ifupdown]
#false的意思是在/etc/network/interfaces配置的网卡都不管了
managed=false
[keyfile]
unmanaged-devices=unmanaged-devices=interface-name:usb0,interface-name:vmbr*,interface-name:fw*,interface-name:tap*
修改后,重启NetworkManager服务。
查看管理状态
nmcli dev status
DEVICE TYPE STATE CONNECTION
wlan0 wifi disconnected --
p2p-dev-wlan0 wifi-p2p disconnected --
fwbr100i0 bridge unmanaged --
vmbr0 bridge unmanaged --
vmbr1 bridge unmanaged --
eth0 ethernet unmanaged --
fwln100i0 ethernet unmanaged --
fwpr100p0 ethernet unmanaged --
usb0 ethernet unmanaged --
lo loopback unmanaged --
tap100i0 tun unmanaged --
网卡配置
cat /etc/network/interfaces
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
auto lo
iface lo inet loopback
source /etc/network/interfaces.d/*
iface enxfa95ea8a9699 inet manual
auto eth0
iface eth0 inet manual
#vmbr0 网桥ip段和绑定的物理网卡在统一网段,设定的ip可以和物理网卡一致,也可以不同
#gateway在本配置文件只能出现一次, 本配置文件中不要配置绑定的物理网卡的ip
#不过在interfaces.d目录下还有一个物理网卡的配置usb0
auto vmbr0
iface vmbr0 inet static
address 192.168.2.3/24
gateway 192.168.2.15
bridge-ports usb0
bridge-stp off
bridge-fd 0
bridge-vlan-aware yes
bridge-vids 2-4094
#vmbr1 用于虚拟机的nat网络,并开启ip转发
auto vmbr1
iface vmbr1 inet static
address 192.168.1.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE
auto usb0
iface usb0 inet static
address 192.168.2.3/24
gateway 192.168.2.15
nameserver 58.240.57.33
nameserver 221.6.4.66
nameserver 114.114.114.114
小技巧
虚拟机配置网卡
``cat /etc/network/interfaces.d/ens18
# The primary network interface
allow-hotplug ens18
iface ens18 inet static
address 192.168.1.20/24
gateway 192.168.1.1
# 路由优先级,数字越小优先级越高
metric 100
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
当网桥使用后,再修改网桥ip或者绑定的物理网卡ip,使用 ifup vmbr0/eth0
让配置生效即可。
文档信息
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)
- 发表日期: 2022-01-15T23:13:55+08:00