There are two ways.

1) change bind-interfaces to bind-dynamic. It is able to wait until
requested address/interface becomes available.

2) change systemd unit, add After=network-online.target to dnsmasq
[Unit]. Starts dnsmasq after network interfaces are configured.

Cheers,

Petr

On 2/13/22 18:20, Chris Green wrote:
> I want to configure a system to listen on an address that it doesn't
> actually have until I add the address to the network interface.
>
> It works OK on Raspberry Pi systems but apparently not on a pretty
> standard ubuntu Linux system.
>
> When I try to start dnsmasq I get this error:-
>
>     root@esprimo# systemctl status dnsmasq.service
>     × dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
>          Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor 
> preset: enabled)
>          Active: failed (Result: exit-code) since Sun 2022-02-13 16:56:27 
> GMT; 1min 46s ago
>         Process: 3839 ExecStartPre=/etc/init.d/dnsmasq checkconfig 
> (code=exited, status=0/SUCCESS)
>         Process: 3847 ExecStart=/etc/init.d/dnsmasq systemd-exec 
> (code=exited, status=2)
>             CPU: 19ms
>
>     Feb 13 16:56:27 esprimo systemd[1]: Starting dnsmasq - A lightweight DHCP 
> and caching DNS server...
>     Feb 13 16:56:27 esprimo dnsmasq[3847]: dnsmasq: failed to create 
> listening socket for 192.168.1.2: Cannot assign requested address
>     Feb 13 16:56:27 esprimo dnsmasq[3847]: failed to create listening socket 
> for 192.168.1.2: Cannot assign requested address
>     Feb 13 16:56:27 esprimo dnsmasq[3847]: FAILED to start up
>     Feb 13 16:56:27 esprimo systemd[1]: dnsmasq.service: Control process 
> exited, code=exited, status=2/INVALIDARGUMENT
>     Feb 13 16:56:27 esprimo systemd[1]: dnsmasq.service: Failed with result 
> 'exit-code'.
>     Feb 13 16:56:27 esprimo systemd[1]: Failed to start dnsmasq - A 
> lightweight DHCP and caching DNS server.
>
>
> In the dnsmasq man page it has:-
>
>     -z, --bind-interfaces
>           On  systems  which support it, dnsmasq binds the wildcard address, 
> even when it
>           is listening on only  some  interfaces.  It  then  discards  
> requests  that  it
>           shouldn't reply to. This has the advantage of working even when 
> interfaces come
>           and go and change address. This option forces dnsmasq to really 
> bind  only  the
>           interfaces  it is listening on. About the only time when this is 
> useful is when
>           running another nameserver (or another instance of dnsmasq)  on  
> the  same  ma‐
>           chine.  Setting  this  option  also enables multiple instances of 
> dnsmasq which
>           provide DHCP service to run in the same machine.
>
> I thought this would mean I could do what I want which is to have:-
>
>     listen-address=192.168.1.2,127.0.0.1 
>
> ... and only actually create the IP 192.168.1.2 on the network interface
> when I want this system to be the DHCP/DNS server.
>
> Does the error mean that Ubuntu Linux isn't among "systems  which support it"?
>
> Is there any other way to get the result I want?  That is dnsmasq running but 
> not
> actually being visible as a server on the LAN until I do something to "switch 
> it
> on"?
>
-- 
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemen...@redhat.com
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB


_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to