自宅向けdnsmasq

dnsmasqを自宅向けに使うメモ。

  • 外のDNS : 8.8.8.8
  • gateway IP : 192.168.0.1
  • サーバーIP : 192.168.0.8/16
  • 自宅ドメイン : homenetwork.local

Uninstall

NetworkManagerとかAvahiとかは全部消す。

Debianの非デスクトップインストールあたりから始めよう。

 

/etc/network/interfaces

static-IPに設定。

auto lo
iface lo inet loopback

auto enp2s0
iface enp2s0 inet static
    address 192.168.0.8
    netmask 255.255.0.0
    network 192.168.0.0
    gateway 192.168.0.1
    dns-search homenetwork.local

/etc/resolv.conf

自分→外 で設定。

dnsmasq がリレーの為に resolv.conf を参照するが、自分のIPの nameserver はスキップする。

domain homenetwork.local
search homenetwork.local.
nameserver 192.168.0.8
nameserver 8.8.8.8
search homenetwork.local

/etc/dnsmqsq.conf

listen-address=192.168.0.8      # listen address for DNS
interface=enp2s0                # listen interface for DHCP
no-hosts                        # skip /etc/hosts
#no-resolv                      # skip resolv.conf ... skipすると 8.8.8.8 へリレーしなくなる
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
ipset=/yahoo.com/google.com/vpn,search
domain=homenetwork.local
expand-hosts

dhcp-range=192.168.0.100,192.168.0.199,255.255.0.0,12h

dhcp-option=option:netmask,255.255.0.0
dhcp-option=option:router,192.168.0.1
dhcp-option=option:dns-server,192.168.0.8
dhcp-option=option:domain-search,homenetwork.local

# 固定IP
address=/dnsmasq.homenetwork.local/192.168.0.8

# DHCPによる固定IPの貸し出し, ホスト名を指定
dhcp-host=xx:xx:x:x:x:x,www,192.168.0.9,12h

# DHCPによる動的IPの貸し出し, ホスト名を指定
dhcp-host=xx:xx:x:x:x:x,www,,12h

その他は dnsmasq インストール直後の /etc/dnsmasq.conf を参照しよう。