Wireless Hacks Free Open Book

Wireless Hacks

Previous Section Next Section

Hack 28 Rendezvous Service Advertisements in Linux

figs/moderate.giffigs/hack28.gif

Let your users know what services are available on your network, even if you aren't running OS X.

Since I'm running a node on SeattleWireless (as well as a streaming jukebox that I'm developing), I'd like to let people know what local services are available. Sure, most visitors just jump straight to their favorite web site or check their email (or their popularity) when they hit my node, but perhaps they'd like to enjoy some local content at a whopping 11 Mbps?

This is one reason why I love multicast DNS service (http://www.multicastdns.org/) advertisements (and Rendezvous, in particular). My Linux Jukebox and Wiki are now announcing themselves like an old-time barker at the county fair. Wireless users at the cafe across the street (or anywhere within a block or so) can find my local services any time just by looking at available Rendezvous sites (Figure 3-23). As if that weren't enough, my streamer is even advertising itself as a daap stream, so iTunes 4 users can see that it's available from inside iTunes.

Figure 3-23. Users can easily find advertised services using a Rendezvous-enabled browser.
figs/wh_0323.gif

To advertise Rendezvous services, you need a multicast DNS advertiser. I think Apple's own Posix implementation is more than adequate. (Download it after a free registration on Apple's site at http://www.opensource.apple.com/projects/rendezvous/source/Rendezvous.tar.gz.) The application you're after is mDNSProxyResponderPosix, in the mDNSPosix/ directory. It builds cleanly and without so much as a warning under Linux 2.4.20. Once it's built, install it somewhere handy (such as /usr/local/bin, for example).

Next, figure out which services you want to advertise. They don't even have to be local services, since the Proxy server will obligingly hand out whatever IP addresses you care to throw at it, local or not. I'm advertising my local Wiki, the Jukebox, and the NoCat web site, just for fun.

The mDNSProxyResponderPosix program expects the following arguments:

mDNSProxyResponderPosix [IP] [Host] [Title] [Service type] [Port] [Optional text]

The first argument is the IP address you'd like to advertise. The second should be a simple name that will be resolved as a .local address in multicast DNS. The Service title should be enclosed in double quotes, and should be a descriptive name for what is being advertised.

The Service type field is a little tricky. It takes the form:

_service._transport.

where service is a well-known IANA service name (i.e., something out of /etc/services) and transport is the actual transport (such as _tcp. or _udp.). The Port argument is simply the port number, and the optional text field supplies additional information to the application receiving the advertisements (more on this later).

For example, here's how I advertise my local music jukebox:

$ mDNSProxyResponderPosix 10.15.6.1 muzik "Music Jukebox" _http._tcp. 80 &

This creates a muzik.local address that resolves to 10.15.6.1. It is an HTTP service, running on tcp port 80. Also notice the & at the end of the line. This is necessary because mDNSProxyResponderPosix doesn't auto-daemonize (hey, it's just example code, after all). As it listens on UDP port 5353, it doesn't need any special privileges to run, so I recommend running it as a nonprivileged user.

This is all well and good for the jukebox, but what if you need to go to a particular URL? For example, to get to my Wiki, you need to go to http://florian.local/wiki, not just http://florian.local/. This is where the optional text field at the end comes in. Safari accepts a path= argument in this field that gets appended to the URL line. For example:

$ mDNSProxyResponderPosix 10.15.6.1 florian "About this node" _http._tcp.80[RETURN] 
path=/wiki &

And there you have it. Incidentally, if you're using VirtualHosts in Apache, you'll have to tell Apache to respond to the name you're advertising (florian.local in the above example.) This is done easily with the ServerAlias directive from within your <VirtualHost> stanza:

ServerName florian.rob.swn 
ServerAlias florian.local

What about advertising nonlocal services, like other web sites? Just specify their IP address as normal:

$ mDNSProxyResponderPosix 216.218.203.211 nocat "NoCatNet" _http._tcp. 80 & 

Finally, since we have music available, it would be nice to advertise directly to iTunes' sharing feature. Since iTunes is simply expecting advertisements to the daap service (as opposed to HTTP), this is a piece of cake:

$ mDNSProxyResponderPosix 10.15.6.1 squeal "http://muzik.rob.swn/" [RETURN]
_daap._tcp. 80

Unfortunately, you can't play the stream directly from the "shared" play list, as Apple uses a proprietary protocol to handle the streaming. So, since I can't easily stream directly to the user (yet), I do the next best thing: just spam the user with the relevant URL. If the user is curious enough to browse to the URL that automagically pops up in their iTunes playlist, they'll be presented with my streamer.

Of course, mDNSProxyResponderPosix isn't nearly as efficient as it could be. After all, you're starting a separate instance for each service you want to advertise, and there is not even a simple configuration file. But keep in mind that this application is just example code from Apple, and in due time more sophisticated multicast DNS advertisement tools will come along. The full source (as well as the complete spec, and some other great documents) are available, just waiting for someone to write the killer Linux/BSD/Windows Rendezvous app.

    Previous Section Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Z]


         Main Menu
    Main Page
    Table of content
    Copyright
    Credits
    Foreword
    Preface
    Chapter 1. The Standards
    Chapter 2. Bluetooth and Mobile Data
    Chapter 3. Network Monitoring
    3.1 Hacks #20-42
    Hack 20 Find All Available Wireless Networks
    Hack 21 Network Discovery Using NetStumbler
    Hack 22 Network Detection on Mac OS X
    Hack 23 Detecting Networks Using Handheld PCs
    Hack 24 Passive Scanning with KisMAC
    Hack 25 Establishing Connectivity
    Hack 26 Quickly Poll Wireless Clients with ping
    Hack 27 Finding Radio Manufacturers by MAC Address
    Hack 28 Rendezvous Service Advertisements in Linux
    Hack 29 Advertising Arbitrary Rendezvous Services in OS X
    Hack 30 'Brought to you by' Rendezvous Ad Redirector
    Hack 31 Detecting Networks with Kismet
    Hack 32 Running Kismet on Mac OS X
    Hack 33 Link Monitoring in Linux with Wavemon
    Hack 34 Historical Link State Monitoring
    Hack 35 EtherPEG and DriftNet
    Hack 36 Estimating Network Performance
    Hack 37 Watching Traffic with tcpdump
    Hack 38 Visual Traffic Analysis with Ethereal
    Hack 39 Tracking 802.11 Frames in Ethereal
    Hack 40 Interrogating the Network with nmap
    Hack 41 Network Monitoring with ngrep
    Hack 42 Running ntop for Real-Time Network Stats
    Chapter 4. Hardware Hacks
    Chapter 5. Do-It-Yourself Antennas
    Chapter 6. Long Distance Links
    Chapter 7. Wireless Security
    Appendix A. Deep Dish Parabolic Reflector Template
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele