[OS X] DHCP ã§åå¾ãã DNS ãµã¼ãã使ãã¤ã¤ dnsmasq ã使ã
æ¤è¨¼ãéçºã®ããã« OS X ãã¼ã«ã«ã§ dnsmasq ã使ãã¨ãã
- ãªã¾ã«ãã®åãå ãå¤ããããã«ãã¡ãã¡ãããã¯ã¼ã¯ç°å¢è¨å®ãéãã®ãé¢å (ã³ãã³ãã§ãã§ãããã©)
- æå®ãã¡ã¤ã³å以å¤ã¯é常éãåå解決ããã
ã¨æã£ã¦ãã人ã®ããã«ã
TL;DR
/etc/resolver é ä¸ã«æå®ãã¡ã¤ã³åã§ãã¡ã¤ã«ãä½ãã°è¯ãã
æ¹æ³
æå®ãã¡ã¤ã³ã®ãªã¾ã«ããå¤æ´
è¨å®
$ sudo mkdir /etc/resolver
$ sudo chown <USER>:wheel /etc/resolver
$ echo 'nameserver 127.0.0.1' > /etc/resolver/example.com
OS X ã§ã¯ /etc/resolver é
ä¸ã«ãã¡ã¤ã³åã§ãã¡ã¤ã«ãä½ã (æ¸å¼ã¯ resolv.conf ã¨åã) ã¨ããã®ãã¡ã¤ã³ã® DNS ãµã¼ããå¤æ´ãããã¨ãã§ããã
ä»åã¯ãã¼ã«ã«ã® dnsmasq ã«åããã®ã§ãnameserver 127.0.0.1
ã¨ãã¦ããã
ããã«ãã£ã¦é常éã /etc/resolv.conf ã使ãã¤ã¤ããæå®ã®ãã¡ã¤ã³ã®ã¿ 127.0.0.1 ã使ã£ã¦ãããããã«ãªãã
å ´æ移åçã§ãDHCP ã§åå¾ãã DNS ãµã¼ããå¤ãã£ã¦ãæ°ã«ããªãã§è¯ããªãã
ãã¡ãã¡ sudo ããªãã¦è¯ãããã«ã/etc/resolver ã®ãªã¼ãã¼ããã°ã¤ã³ã¦ã¼ã¶ã«ãã¦ããã¨è¯ãã
確èª
$ scutil --dns
...snip...
resolver #2
domain : example.com
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : Reachable,Local Address
...snip...
dnsmasq
ã¤ã³ã¹ãã¼ã«
$ brew install dnsmasq
è¨å®
/usr/local/etc/dnsmasq.conf
listen-address=127.0.0.1
user=<USER>
conf-dir=/usr/local/etc/dnsmasq.d
resolv-file=/etc/resolv.conf
/usr/local/etc/dnsmasq.d/example.com
address=/www.example.com/10.0.0.101
resolv-file 㧠/etc/resolv.conf ãæå®ãããã¨ã§ãæå®ã®ãã¡ã¤ã³ã®ä¸ã§ã dnsmasq ã«ã¦ãããããªãã£ããã®ã¯ã/etc/resolv.conf ã® DNS ãµã¼ãã«åãåãããããã«ãªãã
èµ·åã»èªåèµ·åè¨å®
$ sudo cp -a /usr/local/opt/dnsmasq/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
$ sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
åèµ·åã»ãªãã¼ã
$ pkill dnsmasq
user ãæå®ãã¦ããã®ã§ããã°ã¤ã³ã¦ã¼ã¶ã§ kill ãã¦åèµ·åã§ããã(launchctl ãå©ãã®ã¯é¢å)
ãããã«
/etc/resolver é ä¸ã«ãã¡ã¤ã«ãç½®ãã¦ãããå®éã« dnsmasq ã«èãã«è¡ã£ã¦ãããããã«ãªãã¾ã§ 2,3 åã®ã©ã°ãããæ°ãããã
- å稿 (Mon Dec 8 20:24:07 JST 2014)