2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mDNSを無効化する方法

Last updated at Posted at 2024-04-22

はじめに

自宅オンプレミス環境にはDNSサーバがあり,mDNS機能を使うことがない.また,mDNSを有効にしていると常に5353ポートの通信を行うのでファイアウォールのログがその通信ばかりになり他の通信が埋もれてしまい解析しずらかった.なのでmDNS機能を無効化した.

無効化手順

Avahiの無効化

  1. ターミナルでAvahiを無効化する方法
sudo systemctl stop avahi-daemon.socket
sudo systemctl disable avahi-daemon.socket
sudo systemctl mask avahi-daemon.socket
sudo systemctl stop avahi-daemon
sudo systemctl disable avahi-daemon
sudo systemctl mask avahi-daemon
  1. AnsibleでAvahiを無効化する方法
- name: disable avahi-daemon
  systemd:
    name: avahi-daemon
    state: stopped
    enabled: false
    daemon_reload: yes
    masked: true
  become: true

- name: disable avahi-daemon.socket
  systemd:
    name: avahi-daemon.socket
    state: stopped
    enabled: false
    daemon_reload: yes
    masked: true
  become: true

systemd-resolvedのmDNS機能を無効化

Avahiを無効化してもArch LinuxのPCから5353ポートの通信が発信され続けていた.この通信を発しているプロセスを調べたところsystemd-resolvedだった.

  1. ターミナルでsystemd-resolvedのmDNS機能を無効化にする方法
echo "MulticastDNS=no" >> /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved
  1. Ansibleでsystemd-resolvedのmDNS機能を無効化にする方法
tasks/main.yml
    - name: Set up resolved.conf
      template:
        src: templates/resolved.conf.j2
        dest: "/etc/systemd/resolved.conf"
        owner: "root"
        group: "root"
        mode: 0644
      become: true
      notify: restart systemd-resolved
templates/resolved.conf.j2
[Resolve]
MulticastDNS=no
handlers/main.yml
- name: restart systemd-resolved
  systemd:
   name: systemd-resolved
   state: restarted
   daemon_reload: yes
  become: true
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?