FreeBSD 4.11 に mDNSResponder をインストールする時は、Ports からインストールするのが簡単です。
eden# cd /usr/ports/net/mDNSResponder/
eden# pwd
/usr/ports/net/mDNSResponder
eden#
eden# ls
Makefile distinfo files pkg-descr pkg-plist
eden# make install clean
インストール先は、こんな感じ。
eden# rehash
eden# which mdnsd
/usr/local/sbin/mdnsd
eden#
eden# pwd
/usr/local/etc/rc.d
eden# ls mdnsd.sh
mdnsd.sh
mdnsd.sh は、起動スクリプトです。vi などで開いて、以下のように変更します。
#mdnsd_enable="NO"
mdnsd_enable="YES"
起動させます。起動オプションやconfなどの設定ファイルは必要ありません。
eden# /usr/local/etc/rc.d/mdnsd.sh start
Starting mdnsd.
eden#
以下のようなネットワーク環境で動作を確認します。
+-----------------------------------------------+
| Linksys WRT54G 802.11g + Router + DHCP Server |
+-----------------------------------------------+
|有線 |有線 :無線
+-------------+ +------------+ +-------------+
|mimi | |eden | |ibg4 |
|Windows2000 | |FreeBSD4.11R| |MacOSX10.3 |
|192.168.0.100| |192.168.0.8 | |192.168.0.101|
+-------------+ +------------+ +-------------+
FreeBSDから ping してみます。
> ping eden.local
ping: cannot resolve eden.local: Unknown host
> ping mimi.local
ping: cannot resolve mimi.local: Unknown host
> ping ibg4.local
ping: cannot resolve ibg4.local: Unknown host
あれ?名前が引けない。sockstat でソケットの状態を確認してみる。mdnsd は、5353(と1037) でlisten状態なんだけど。
尚、sockstatはFreeBSDに含まれるPerlスクリプトで、待機ポートに対する実行中のコマンドを知ることができる。
MacOSXの時は、lsof -i -n -P で同様のことができる。
> sockstat
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
kenz sshd 208 5 tcp4 192.168.0.8:22 192.168.0.100:1502
root sshd 205 5 tcp4 192.168.0.8:22 192.168.0.100:1502
nobody mdnsd 157 3 udp4 *:1037 *:*
nobody mdnsd 157 4 udp4 *:5353 *:*
root cupsd 118 0 tcp4 *:631 *:*
root cupsd 118 2 udp4 *:631 *:*
root sendmail 90 4 tcp4 *:25 *:*
root sendmail 90 6 tcp4 *:587 *:*
root sshd 85 4 tcp4 *:22 *:*
root inetd 81 4 tcp4 *:21 *:*
root inetd 81 5 tcp4 *:23 *:*
root inetd 81 6 tcp4 *:110 *:*
root inetd 81 7 tcp4 *:515 *:*
root syslogd 74 5 udp4 *:514 *:*
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root sendmail 90 5 tcp46 *:25 *:*
root sshd 85 3 tcp46 *:22 *:*
root syslogd 74 4 udp6 *:514 *:*
USER COMMAND PID FD PROTO ADDRESS
kenz sshd 208 3 stream sshd[205]:4
root sshd 205 4 stream sshd[208]:3
root snort 166 4 dgram syslogd[74]:3
nobody mdnsd 157 6 stream /var/run/mDNSResponder
smmsp sendmail 93 3 dgram syslogd[74]:3
root sendmail 90 3 dgram syslogd[74]:3
root syslogd 74 3 dgram /var/run/log
次は、MacOSXから。
最初は、FreeBSD(eden)のmdnsd が起動していない状態で、
MacOSXからBonjour(Rendezvous)で使う名前を利用してpingしてみます。
ibg4:~ kenz$ ping eden.local
ping: unknown host eden.local
次は mdnsd を起動させて ping 。
ibg4:~ kenz$ ping eden.local
PING eden.local (192.168.0.8): 56 data bytes
64 bytes from 192.168.0.8: icmp_seq=0 ttl=64 time=1.271 ms
64 bytes from 192.168.0.8: icmp_seq=1 ttl=64 time=1.017 ms
64 bytes from 192.168.0.8: icmp_seq=2 ttl=64 time=1.001 ms
^C
--- eden.local ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 1.001/1.096/1.271 ms
ibg4:~ kenz$
マルチキャストDNSの機能を確認できます。
この名前を利用して、ssh や http も利用可能です。
ibg4:~ kenz$ ssh eden.local
Warning: the DSA host key for 'eden.local' differs from the key for the IP address '192.168.0.8'
Offending key for IP in /Users/kenz/.ssh/known_hosts:3
Matching host key in /Users/kenz/.ssh/known_hosts:16
Are you sure you want to continue connecting (yes/no)? yes
Password:
Last login: Tue Mar 29 21:09:12 2005 from 192.168.0.101
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 4.11-RELEASE (GENERIC) #0: Fri Jan 21 17:21:22 GMT 2005
Welcome to FreeBSD!
Windowsに Rendezvous for Windows Technology Preview 4 をインストールすれば、
Windowsからも同様の操作ができます。 Apple Developer Connection:Bonjourからダウンロードしてインストールするのみ。
コマンドプロンプトを開いて、ping します。
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\Documents and Settings\kenz>ping eden.local
Pinging eden.local. [192.168.0.8] with 32 bytes of data:
Reply from 192.168.0.8: bytes=32 time<10ms TTL=64
Reply from 192.168.0.8: bytes=32 time<10ms TTL=64
Reply from 192.168.0.8: bytes=32 time<10ms TTL=64
Reply from 192.168.0.8: bytes=32 time<10ms TTL=64
Ping statistics for 192.168.0.8:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Documents and Settings\kenz>
こっちも ssh,http はOK.
MacOSXは当然のことWindows2000もBonjour(Rendezvous)の名前で引けるのに、FreeBSDは名前が引けませんでした。
なんでだろ...
マルチキャストのレスポンスするだけなの?
mdnsd の man です。mDNSResponder と mdnsd は同じなんですね。
でも、コマンドライン上で引数をつけられないし、*.conf が無いし、
ネットワーク上にサービスを公開する機能はないらしい。
eden# man mdnsd
Formatting page, please wait...Done.
mDNSResponder(8) FreeBSD System Manager's Manual mDNSResponder(8)
NAME
mDNSResponder -- Multicast DNS daemon
SYNOPSIS
mDNSResponder
DESCRIPTION
mDNSResponder (also known as mdnsd on some systems) is a daemon invoked
at boot time to implement Multicast DNS and DNS Service Discovery.
mDNSResponder listens UDP port 5353 for Multicast DNS Query packets.
When it receives a query for which it knows an answer, mDNSResponder
issues the appropriate Multicast DNS Reply packet.
mDNSResponder also performs Multicast DNS Queries on behalf of client
processes, and maintains a cache of the replies.
mDNSResponder has no user-specifiable command-line argument, and users
should not run mDNSResponder manually.
To examine mDNSResponder's internal state, for debugging and disagnostic
purposes, send it a SIGINFO signal, and it will then dump a snapshot sum-
mary of its internal state to /var/log/system.log, e.g.
sudo killall -INFO mDNSResponder
FILES
/usr/sbin/mDNSResponder
SEE ALSO
mDNS(1)
For information on Multicast DNS, see http://www.multicastdns.org/
For information on DNS Service Discovery, see http://www.dns-sd.org/
For information on how to use the Multicast DNS and the DNS Service Dis-
covery APIs on Mac OS X and other platforms, see
http://developer.apple.com/macosx/rendezvous/
For the source code to mDNSResponder, see
http://developer.apple.com/darwin/projects/rendezvous/
BUGS
mDNSResponder bugs are tracked in Apple Radar component "mDNSResponder".
HISTORY
The mDNSResponder daemon first appeared in Mac OS X 10.2 (Jaguar).
Also available from the Darwin open source repository (though not offi-
cially supported by Apple) are mDNSResponder daemons for other platforms,
including Mac OS 9, Microsoft Windows, Linux, FreeBSD, NetBSD, Solaris,
and other POSIX systems.
Darwin March 29, 2005 Darwin
eden#