1、配置/etc/network/interfaces
參考官方文檔地址https://pve.proxmox.com/wiki/Network_Configuration
## 真實(shí)ip
auto eno1
iface eno1 inet static
address 192.168.1.196/24
gateway 192.168.1.204
## 通過bridge 分配給虛擬機(jī)的子ip
auto vmbr0
iface vmbr0 inet static
address 192.168.2.1/24
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.2.0/24' -o eno1 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.2.0/24' -o eno1 -j MASQUERADE
post-up iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1
2、配置虛擬機(jī)的ip(我這邊是ubuntu20)
執(zhí)行nano /etc/netplan/00-installer-config.yaml,在這個(gè)文件中配置具體ip
network:
ethernets:
ens18:
addresses:
- 192.168.2.100/24
gateway4: 192.168.2.1
nameservers:
addresses:
- 8.8.8.8
重啟網(wǎng)卡執(zhí)行 netplan apply