当我运行 lxd init 时,我选择此设置。
Would you like to create a new network bridge (yes/no)? no
因为我在 /etc/network/interfaces 中创建了自己的 br0
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
address x.x.50.2
netmask 255.255.252.0
broadcast x.x.x.255
network x.x.x.0
gateway x.x.53.254
dns-nameservers 8.8.8.8
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
iface eth0 inet manual
然后我启动 lxd centos 并运行
lxc config device add first eth0 nic nictype=bridged parent=br0
lxc config device set first eth0 ipv4.address x.x.51.2
lxc config device set first eth0 security.mac_filtering true
并更改配置
/var/lib/lxd/containers/second/rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HOSTNAME=LXC_NAME
NM_CONTROLLED=no
TYPE=Ethernet
IPADDR=x.x.51.2
NETMASK=255.255.255.255
GATEWAY=x.x.53.254
DNS1=8.8.8.8
DNS2=x.x.x.x
MTU=
DHCP_HOSTNAME=x.x.50.2
当我尝试 ping 8.8.8.8 时,出现连接:网络无法访问
/etc/resolv.conf
nameserver 8.8.8.8
search lxd
nameserver x.x.x.x
我做错了什么我无法弄清楚,也许我错过了一些概念?