马春杰杰博客
致力于深度学习经验分享!

LXD容器使用桥接br0网络之后,仍然无法获取动态IP的解决方案

目前有四台机器,其中一台按照上次的全流程配置之后,容器可以正确获取到动态IP

全流程:Linux系统安装LXD容器,并利用宿主机的网卡配置单网卡双IP

但是其他三台都不行,死活获取不到:

一度以为是上游路由器的问题,因为DHCP一直没有答复:

经过多方查询之后,发现是系统把二层桥转到 iptables/nft 处理,这就可能把 DHCP 吃掉,所以,临时关闭 bridge→iptables 钩子:

sudo sysctl -w net.bridge.bridge-nf-call-iptables=0
sudo sysctl -w net.bridge.bridge-nf-call-ip6tables=0

然后重新测试DHCP

可以看到,DHCP已经成功,容器可以正确获取IP了~

但是目前还只是临时生效,若要重启之后依然生效,需要进行持久化操作,如下:

让内核在早期就加载 br_netfilter

echo br_netfilter | sudo tee /etc/modules-load.d/br_netfilter.conf
sudo modprobe br_netfilter

然后保留 sysctl 配置为 0,并立即应用:

printf "net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-ip6tables=0
" | sudo tee /etc/sysctl.d/99-bridge-nf.conf

sudo systemctl restart systemd-modules-load
sudo systemctl restart systemd-sysctl
sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables

输出应该都为0~

赞(1) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《LXD容器使用桥接br0网络之后,仍然无法获取动态IP的解决方案》
文章链接:https://www.machunjie.com/linux/1883.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

:smile: :sad: :arrow: :cool: :confused: :cry: :eek: :evil: :exclaim: :idea: :lol: :mad: :mrgreen: :neutral: :question: :razz: :redface: :rolleyes: :surprised: :wink: :biggrin: :twisted: