Hi Mark, Idk if this will be of help to you, but LXC has some options to
configure this.  Here is an example:

cat /etc/resolv.conf  (I use systemd-resolve but for this example I've
commented out my systemd nameserver, I've added in the IP address of the
LXC lxcbr0 bridge, and I've added "lxc" as the domain of the LXC
container).  I created a container dnstest on the lxcbr0 bridge for this
example.

orabuntu@pasadena1:/etc/default$ cat /etc/resolv.conf

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual
nameservers.
# nameserver 127.0.0.53
*nameserver 10.0.3.1*
search urdomain1.com urdomain2.com gns1.urdomain1.com *lxc*

orabuntu@pasadena1:/etc/default$ *ifconfig lxcbr0*
lxcbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.3.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::216:3eff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 16  bytes 1780 (1.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 130  bytes 16975 (16.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

orabuntu@pasadena1:/etc/default$ *cat lxc-net*
# This file is auto-generated by lxc.postinst if it does not
# exist.  Customizations will not be overridden.
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers.  Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="true"

# If you change the LXC_BRIDGE to something other than lxcbr0, then
# you will also need to update your /etc/lxc/default.conf as well as the
# configuration (/var/lib/lxc/<container>/config) for any containers
# already created using the default config to reflect the new bridge
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"
# Uncomment the next line if you'd like to use a conf-file for the lxcbr0
# dnsmasq.  For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have
# container 'mail1' always get ip address 10.0.3.100.
# LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf

# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc
# domain.  You can then add "server=/lxc/10.0.3.1' (or your actual
$LXC_ADDR)
# to your system dnsmasq configuration file (normally /etc/dnsmasq.conf,
# or /etc/NetworkManager/dnsmasq.d/lxc.conf on systems that use
NetworkManager).
# Once these changes are made, restart the lxc-net and network-manager
services.
# 'container1.lxc' will then resolve on your host.
*LXC_DOMAIN="lxc"*

orabuntu@pasadena1:/etc/default$ *sudo lxc-ls -f*
NAME       STATE   AUTOSTART GROUPS IPV4                      IPV6
afns1      RUNNING 0         -      10.209.53.2, 172.29.108.2 -
afns1-base STOPPED 0         -      -                         -
dnstest    RUNNING 0         -      10.0.3.24                 -
oel66c10   STOPPED 0         -      -                         -
ora66c10   RUNNING 0         -      10.209.53.10              -
ora66c11   RUNNING 0         -      10.209.53.11              -
ora66c12   RUNNING 0         -      10.209.53.12              -
orabuntu@pasadena1:/etc/default$ *nslookup dnstest.lxc*
Server:        10.0.3.1
Address:    10.0.3.1#53

Name:    dnstest.lxc
Address: 10.0.3.24

orabuntu@pasadena1:/etc/default$

My other containers on the 10.209.53.0/24 network use a containerized
DNS/DHCP bind9/isc-dhcp-server, that is forwarded to by systemd-resolved,
so ignore those.  I added an Ubuntu 16.04 xenial container to my setup
using the lxcbr0 bridge as the default, and as can see, by uncommenting
*LXC_DOMAIN="lxc"* in /etc/default/lxc-net and then restarting lxc-net,
dnsmasq not only provides DHCP addresses but also provides DNS lookup (has
added the record), albeit you must use the FQDN to get the lookup
(dnstest.lxc) in my example case so far.

If you want to be able to resolve shortnames, then the search has to be
changed as shown below and then the shortname can be resolved by dnsmasq.

orabuntu@pasadena1:/etc/default$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual
nameservers.
# nameserver 127.0.0.53
nameserver 10.0.3.1
# search urdomain1.com urdomain2.com gns1.urdomain1.com lxc
search lxc
orabuntu@pasadena1:/etc/default$

orabuntu@pasadena1:/etc/default$ nslookup dnstest
Server:        10.0.3.1
Address:    10.0.3.1#53

Name:    dnstest.lxc
Address: 10.0.3.24

I guess that the LXC_DOMAIN is the functionality you are probably looking
for.  As mentioned, I don't use dnsmasq directly in my Orabuntu-LXC
project, I use dnsmasq to forward lookups to the LXC containerized
isc-dhcp-server/bind9 setup, but I think you can probably setup what you
need using only dnsmasq based on this LXC example.  HTH Gilber



On Mon, Apr 16, 2018 at 9:18 AM, Mark Lehrer <leh...@gmail.com> wrote:

> Does dnsmasq have the ability to automatically add DHCP clients to DNS
> based on the client-supplied host name?
>
> I see there is a dyndns type
> of script in contrib, but it would be easier to have the dhcp part of
> dnsmasq do it if possible.
>
> Thanks
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss@lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
>



-- 
Gilbert Standen
Creator Orabuntu-LXC
914-261-4594
gilb...@orabuntu-lxc.com
_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to