dnsmasq: не удалось создать прослушивающий сокет для порта 53: адрес уже используется

Я пытаюсь настроить dnsmasq для работы вместе с NetworkManager , проблема заключается в том, что я пытаюсь запустить службу, с которой она терпит неудачу:

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

Однако ничего не прослушивает 127.0.0.1:53 :

sudo ss -alpn sport = 53 src 127.0.0.1

Приведенная выше команда не имеет вывода!

Вот как выглядит мой /etc/dnsmasq.conf :

$ grep '^[^#]' /etc/dnsmasq.conf 

no-resolv
server=8.8.8.8#53
listen-address=127.0.0.1
cache-size=50

Проблема может быть решена, если я включу bind-interfaces в / etc / dnsmasq .conf .

Зачем мне это включать? в комментариях говорится, что:

Это может понадобиться вам примерно только при запуске другого сервера имен на той же машине.

Я подумал, что проблема может исходить от systemd-resolved.service , и я был уверен, что это так. после его остановки:

sudo systemctl stop systemd-resolved.service

теперь dnsmasq работает нормально без включения опции bind-interfaces .


Я использую Ubuntu 18.04.1.
Устанавливается с использованием debootstrap , и моим средством визуализации по умолчанию является NetworkManager , который работает нормально.


Мои вопросы:

  1. Почему мне нужно включать bind-interfaces ?
  2. Можно ли просто отключить службу systemd-resolved ? если это так, как мне получить dnsmasq для управления /etc/resolv.conf ?
  3. И что более важно, почему я получаю это странное сообщение об ошибке, когда ничего не слушает порт 53 ?
5
задан 5 August 2018 в 11:09

2 ответа

Вот мой рабочий пример. Я помню, у меня была такая же проблема, потому что у моего «бастера» был включен systemd-resolved.service. Однако прошло много времени с тех пор, как я использовал его в последний раз, но следующий конфиг не имеет ничего особенного внутри:

# disables dnsmasq reading any other files like /etc/resolv.conf for nameservers
no-resolv

# Interface to bind to
interface=br0

# Specify starting_range,end_range,lease_time
dhcp-range=192.168.2.181,192.168.2.230,72h 

# dns addresses to send to the clients
server=8.8.8.8
server=8.8.4.4
dhcp-option=option:ntp-server,162.159.200.123,90.187.99.165

Надеюсь, это поможет

С уважением

Саша

0
ответ дан 28 September 2020 в 01:38

По умолчанию Dnsmasq пытается привязать порт ко всем интерфейсам. Где --bind-interfaces только интерфейс, объявленный в конфигурации.

man dnsmasq

-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.

--bind-dynamic
    Enable a network mode which is a hybrid between
    --bind-interfaces and the default. Dnsmasq binds the address of
    individual interfaces, allowing multiple dnsmasq instances, but
    if new interfaces or addresses appear, it automatically listens
    on those (subject to any access-control configuration). This
    makes dynamically created interfaces work in the same way as the
    default. Implementing this option requires non-standard
    networking APIs and it is only available under Linux. On other
    platforms it falls-back to --bind-interfaces mode. 

Аналогичные случаи:

Дополнительная дополнительная тема:

1
ответ дан 24 October 2020 в 14:45

Другие вопросы по тегам:

Похожие вопросы: