Raspberry Pi(Raspbian)ã«mDNSãè¨å®ãã
Raspberry Piã«ãã£ã¹ãã¬ã¤ããã¼ãã¼ããç¹ããã«é¨å±ã®é
ã£ãã«è»¢ããã¦ããã¦ãªã¢ã¼ãããã¢ã¯ã»ã¹ããã«ã¯ãIPã¢ãã¬ã¹ãç¥ããªãã¨ãããªãããã ãã©ããã£ããã®ãã¼ã¿ãã«ãªRasPiã«åºå®IPã¢ãã¬ã¹ãè¨å®ããã®ãå¾®å¦ãªæããããã®ã§ãmDNSãæ´»ç¨ãã¦ã¿ããã¨ã«ããã
Appleã好ããªã¢ã¬ãã³ã³ãã¥ã¼ã¿å.localã§ã¢ã¯ã»ã¹ã§ãããã¤ã
ã¨ãããããä»åã¯Raspberry Piããªãã¨ããããã£ãã®ã§Raspbianã®å 容ã ãã©ãCentOSã§ãUbuntuã§ãArch Linuxã§ãããã±ã¼ã¸åãéã£ãããããããã§ã ãããåãã
説æã¨ãã©ãã§ããã人åã
# ãã¹ãåããã¡ãã¨è¨å®ãã sudo -e /etc/hostname # avahi-daemonã¨nss-mdnsãã¤ã³ã¹ãã¼ã« sudo apt-get install avahi-daemon libnss-mdns # avahiã«sshãµã¼ãã¹è¿½å sudo -e /etc/avahi/services/ssh.service ä¸èº« ---------------- <?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_ssh._tcp</type> <port>22</port> </service> </service-group> ---------------- # åèµ·å sudo reboot
ãã¹ãåã®è¨å®
ã¢ã¯ã»ã¹ããããã®ãã¡ã¤ã³ã"ãã¹ãå.local"ã«ãªãã®ã§ããªã«ã¯ã¨ããããã¹ãåãè¨å®ããã
sudo -e /etc/hostname
paseraspi
avahi-daemonã¨nss-mdnsã®ã¤ã³ã¹ãã¼ã«
sudo apt-get install avahi-daemon libnss-mdns
ã¡ãªã¿ã«avahiãmDNS/DNS-SDã®å®è£
ã§ä¸»ã«responderã¨ãã¦ä½¿ãæã*1ã§ãnss-mdnsã®æ¹ã¯NSSã®hostsã§mDNSã«ããåå解決ããµãã¼ãããããã®ãã©ã°ã¤ã³ã
ãã£ããè¨ãã¨avahi-daemonããã®ãã·ã³ãmDNSã§çºè¦ãã¦ãããããã®ãµã¼ãã§ãnss-mdnsãå¥ã®ãã·ã³ãmDNSã§è¦ã¤ããããã®ã¯ã©ã¤ã¢ã³ãã¿ãããªæãã
ãªã®ã§ãä»åã®ç¨éã ã¨avahi-daemonã ãããã°ããã¦ãRasPiããã©ã£ãã¸.localã§ã¢ã¯ã»ã¹ããæ°ããªããªãlibnss-mdnsã¯ãªãã¦ãããããã
avahiã®è¨å®
/etc/avahi/servicesã«å¿çãããããµã¼ãã¹ã®è¨å®ãã¡ã¤ã«ãä½ãã
ä¾ãã°sshãªããããªæããä¸èº«ã«ã¤ãã¦ã¯man avahi.serviceã§ã
sudo -e /etc/avahi/services/ssh.service
<?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_ssh._tcp</type> <port>22</port> </service> </service-group>
ã§ãavahi-daemonåèµ·åã
sudo /etc/init.d/avahi-daemon restart
ãã¨iptablesã¨ãã§ãã¡ã¤ã¢ã¦ã©ã¼ã«ãè¨å®ãã¦ããå ´åã¯ã224.0.0.251:5353å®ã®UDPãéãå¿ è¦ãããã
ããã§"ãã¹ãå.local"ã§Raspberry Piã«ã¢ã¯ã»ã¹ã§ããããã«ãªã£ãã¯ãã
nss-mdnsã®è¨å®
/etc/nsswitch.confã®hostsé ç®ãæ¸ãæãããã ãã©ãã¤ã³ã¹ãã¼ã«ããæç¹ã§èªåçã«æ¸ãæãããã¦ãã¯ãã
sudo -e /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
åèµ·åã¨ãã¯ç¹ã«ãªãã
avahi-browse
avahi-utilsã«å ¥ã£ã¦ãavahi-browseã使ãã¨ãããã¯ã¼ã¯å ã®å©ç¨å¯è½ãªãµã¼ãã¹ãä¸è¦§è¡¨ç¤ºã§ããã
sudo apt-get install avahi-utils
avahi-browse -ar
*1:avahi-browseã¨ãããã