[Why] Generally, dnsmasq is used for a internal network lab, and as the number of machines in the lab increases, we need an internal dns server to perform dns relay and forward function.
[How] 1. open dns function: - set 'port=53'; 2. set the upstream dns server of dnsmasq: - add param: 'resolv-conf'; - add resolv.conf and mount it to container.
Signed-off-by: Yu Chuan 13186087857@163.com --- container/dnsmasq/conf/etc/resolv.conf | 1 + container/dnsmasq/dnsmasq.d/dnsmasq.conf | 7 ++++++- container/dnsmasq/start | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 container/dnsmasq/conf/etc/resolv.conf
diff --git a/container/dnsmasq/conf/etc/resolv.conf b/container/dnsmasq/conf/etc/resolv.conf new file mode 100644 index 000000000000..bad8aa25de25 --- /dev/null +++ b/container/dnsmasq/conf/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 114.114.114.114 diff --git a/container/dnsmasq/dnsmasq.d/dnsmasq.conf b/container/dnsmasq/dnsmasq.d/dnsmasq.conf index 6141faf0436b..877216d8abdb 100644 --- a/container/dnsmasq/dnsmasq.d/dnsmasq.conf +++ b/container/dnsmasq/dnsmasq.d/dnsmasq.conf @@ -1,4 +1,9 @@ -port=0 +# open dns function +port=53 + +# setup the upstream dns server of dnsmasq +resolv-file=/etc/resolv.conf + interface=br0
enable-tftp diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..a75ff209e64f 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -27,6 +27,7 @@ cmd=( --publish 67:67/udp --publish 69:69/udp -v ${WORKSPACE}/dnsmasq.d:/etc/dnsmasq.d + -v ${WORKSPACE}/conf/etc/resolv.conf:/etc/resolv.conf:ro # specify the upstream dns server of dnsmasq -v ${DNSMASQ_CONF_DIR}/lease_dir:/var/lib/misc # persist the dhcp lease file -v /etc/localtime:/etc/localtime:ro -v /tftpboot:/tftpboot:ro