# [Solved] listening port already in use, dnsmasq

## Treborius

i have 2 network interfaces

enp6s0: inet 192.168.178.111/24 brd 192.168.178.255 scope global enp6s0

wlp1s0u1: inet 192.168.100.1/32 scope global wlp1s0u1

i want sshd to listen on : 

(1) enp6s0 on port 53 (facist firewall at work)

(2) wlp1s0u1 on port 22 (for home-subnet)

so i configured sshd (/etc/ssh/sshd_config) :

```

ListenAddress 192.168.178.111:53

ListenAddress 192.168.100.1:22

```

and i want dnsmasq to listen on port 53 in the private subnet (/etc/dnsmasq.conf)

```

interface=wlp1s0u1

listen-address=192.168.100.1

```

i can't imagine why this configuration shouldn't be possible, 

anyway dnsmasq is complaining, that port 53 is in use :

```

dnsmasq: failed to create listening socket for port 53: Address already in use

```

here is the output of netstat

```

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 192.168.178.111:53      0.0.0.0:*               LISTEN      10703/sshd

tcp        0      0 192.168.100.1:22        0.0.0.0:*               LISTEN      10703/sshd

```

any help would be highly appreciated

----------

## Zucca

192.168.100.1/32 network can only contain one address, which is invalid.

At least four addresses are needed:.0 reserved for the networkcomputer 1computer 2and broadcast address, which is usually the last one.... so maybe you meant to specify "192.168.100.1/30" instead?

I'd try to fix that first. Maybe it solves your problem?

----------

## Treborius

i missed the following option in the dnsmasq configuration :

-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 machine. Setting this option also enables multiple instances of dnsmasq which provide DHCP service to run in the same machine.

 *Zucca wrote:*   

> 192.168.100.1/32 network can only contain one address, which is invalid.
> 
> At least four addresses are needed:.0 reserved for the networkcomputer 1computer 2and broadcast address, which is usually the last one.... so maybe you meant to specify "192.168.100.1/30" instead?
> 
> I'd try to fix that first. Maybe it solves your problem?

 

this is an error too, thanks for pointing it out

----------

## mike155

You probably use OpenRC, dont you? Be prepared that binding services to interfaces won't work when you switch to Systemd. It works if you use OpenRC and there's nothing wrong with it. But since nearly the whole world uses Systemd nowadays, and thus cannot use this technique, it might not be recommendable for OpenRC as well.

----------

## Zucca

I'm now having this same problem.  :Very Happy: 

Except whatever I do, dnsmasq does listen to 0.0.0.0:domain.  :Evil or Very Mad: 

 *mike155 wrote:*   

> Be prepared that binding services to interfaces won't work when you switch to Systemd.

 Ok. Why? Is binding to interfaces a bad practice?

----------

