Last-modified: 2017-03-04 (土) 17:49:20
dnsmasq/インストール

概要

dnsmasqをインストールし、ローカルリソースに名前でアクセスしつつ、インターネット上のFQDNも引けるようにします。

手順

  1. インストール
    Everything is expanded.Everything is shortened.
      1
    
     
    
    apt-get install dnsmasq
  2. /etc/hosts にレコードを追加
    Everything is expanded.Everything is shortened.
      1
      2
    
    -
    !
    
    # 例
    192.168.3.100    aaa.foo    bbb.foo
  3. 再起動
    Everything is expanded.Everything is shortened.
      1
    
     
    
    service dnsmasq restart
  4. iptables設定変更
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
    
    -
    |
    !
     
     
     
    -
    
    # 例
    # /etc/network/if-pre-up.d/iptables を編集
     
    iptables -A INPUT -p tcp --dport 53 -m state --state NEW -j ACCEPT    # DNS
    iptables -A INPUT -p udp --dport 53 -m state --state NEW -j ACCEPT    # DNS
     
    # /etc/network/if-pre-up.d/iptables を実行して反映
    
  5. 動作確認
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
    
    -
    !
    -
    !
     
     
    -
    !
    
    # 別端末からローカルリソース名とインターネット上のFQDNを引けるか動作確認
     
    # linuxなら
    host <名前> <DNSサーバー>
    dig <名前> @<DNSサーバー>
     
    # windowsなら
    nslookup <名前> <DNSサーバー>
  6. ローカルネットワークのDNSサーバー置き換え
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
    
    -
    |
    !
    -
    |
    !
    -
    !
    -
    !
    
    # ルーターのDHCPサーバーで配布する場合
    # ルーターのDHCP設定を変更
     
    # Windowsで固定IPの場合
    # ネットワークアダプタのプロパティから変更
     
    # Linuxで固定IPの場合
    vi /etc/network/interface
    # ネットワークインターフェイス毎に
    dns-nameservers <DNSサーバー(スペース区切り)>

補足

検証時の環境