Linux网络命名空间的Dnsmasq问题

我曾尝试使用dnsmasq作为虚拟机的名称服务器.在所有vm-s上,/ etc / resolv.conf表示vm需要访问192.168.15.3才能解析域名.但是,保存192.168.15.3的接口位于主机上的网络命名空间内.

我可以从虚拟机和主机(在网络名称空间内)ping 192.168.15.3.并且网络命名空间外的lsof -i:53显示dnsmasq正在侦听端口53.如果我在网络命名空间内运行lsof -i:53,则什么都没有.

如果我更改/etc/resolv.conf中的内容以在主机的公共命名空间中使用任何接口的ip地址,则名称解析效果很好.似乎dnsmasq进程没有出错.

我已经尝试过ip netns exec< THE NAMESPACE> systemctl在停止dnsmasq后启动dnsmasq,但只看到dnsmasq在公共名称空间内打开其端口.

如果我不想在vm中修改resolv.conf但只在主机上配置某些内容,我该怎么办?如何在网络命名空间内访问端口53?

解决方法:

http://man7.org/linux/man-pages/man8/ip-netns.8.html

A network namespace is logically another copy of the network stack,
with its own routes, firewall rules, and network devices.

所以你需要这样的东西:
Iptables to redirect DNS lookup IP and Port

上一篇:linux – 从Docker容器内部运行dnsmasq作为DHCP服务器


下一篇:使用Dnsmasq 部署GPXE 安装 Centos7