Filed under: Cool tools, How-tos, Airport
Using DHCP Reservations to overcome Bonjour woes
I love everything about my MacBook Pro, but for some reason it does not like to share its screen. It appears under the "Shared" section of the sidebar in Finder, and file sharing works perfectly, but for some reason screen sharing won't work. The "Connecting To 'MacBookPro'" panel will pop up and then disappear a few moments later (as if it is about to connect), but at least 90% of the time no screen sharing window appears.
Fellow TUAW writer Aron Trimble suggested that I go into Finder and try "Go > Connect to Server" and then put in "vnc://10.0.x.x" (where 10.0.x.x is my MacBook Pro's IP address). That worked immediately, and every time.
This confirmed that it wasn't a firewall setting (Screen Sharing is explicitly on) or trouble accessing the MacBook Pro over the LAN (file sharing already worked perfectly). For some reason the screen sharing connection was just not being made over Bonjour.
The only drawback to this direct-IP method is that my network, like most, uses dynamic addresses with DHCP, meaning that the IP addresses change from time to time, especially on a network with multiple devices which are not always turned on. My first thought was to create a static IP for the MacBook Pro in System Preferences > Network, but then I realized that my office LAN uses IPs which start with 192.168.x.x. I could create a new network "Location" but that would also involve manually switching it back and forth, or using a third-party program.
What I really needed was a way to make sure that my MacBook Pro is given the same IP every time it connects to my home LAN. Fortunately, Apple's Airport Extreme will allow me to do just that using DHCP Reservations.
A DHCP Reservation tells the Airport Extreme to reserve a certain IP address for certain computers, as determined either by a "DHCP Client ID" or the computer's MAC address. A DHCP Client ID is easier to remember than a MAC address, but the MAC address will never change unless you swap out the logic board or Airport card of your Mac. I'll show you how to set it up using either method.
Launch System Preferences, then open the Network panel. You have different MAC addresses for AirPort and Ethernet, so choose whichever one you want to configure. Then click the "Advanced..." button.
If you want to use a DHCP Client ID, you will see a field for it in the TCP/IP tab. Enter a name in there. I prefer to keep it simple: Macbook, iMac, MacBookPro. Copy whatever you enter there into the clipboard.
If you want to use the MAC Address, click the "Ethernet" tab and select and copy to clipboard all the letters and numbers next to the "Ethernet ID" (in System Preferences, Mac OS X also refers to MAC address as the "Ethernet ID", perhaps to avoid confusion between "Mac" and "MAC". However, in Airport Utility, it is referred to as the MAC Address.)
Launch AirPort Utility. Select your AirPort base station and click the "Manual Setup" button. When the settings load, click the "Internet" icon from the top toolbar, and then click the DHCP tab. You will see a spot for "DHCP Reservations." Click the + and then add a description (this can be anything you want). Next to "Reserve address" choose either MAC Address or DHCP Client ID (whichever you chose above). Click "Continue" and paste the information into the next window. Then select the IPv4 address you want to use for that computer (I chose 10.0.1.51).
Click Done, and the window will close. Click update in Airport Utility and the Airport Base Station will reboot to use the new settings.
OK, but how do I get Screen Sharing to use that IP instead of the Bonjour name? We're going to create a "vncloc" file. When double-clicked, it will automatically start a screen sharing session. The file format is quite simple:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>URL</key> <string>vnc://10.0.1.51</string> </dict> </plist>
Obviously the IP address in the file should be the same as the one that was chosen earlier. I saved the file as "Macbookpro.vncloc" and saved it in ~/Library/Application Support/Screen Sharing/ (although you can save it anywhere you want). I then dragged the vncloc into the "Places" sidebar in Finder.
Since setting up this method, I have had a 100% success rate at connecting to my MacBook Pro.
Bonus: If you have no problems using screen sharing over Bonjour and want to make a quick shortcut to screensharing, you can simply create a .vncloc file like this (for my iMac which is named, uncreatively "iMac"):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>URL</key> <string>vnc://imac.local.</string> </dict> </plist>
Drag that file to your Places sidebar (or your Desktop, or the Documents section of your Dock), and have quick access to screen sharing anywhere.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
Curly Eric said 10:14AM on 10-16-2009
Nice workaround, but it sounds like there is a more fundamental problem here. Is there anything like mobileme or VPN's involved in this setup? Have you tried connecting to VNC by name vnc://computer.local/ ?
Reply
THJ said 10:22AM on 10-16-2009
Probably a dumb question, excuse my ignorance: will this help with the 'double-nat' problem that prevents BTMM from working? I recently installed an Ooma hubphone that I can't seem to shut off NAT. Since NAT is also provided by an AP Extreme, no more BTMM. Everything else I've tried works (haven't tried video chat though), and BTMM works when it's after the AP extreme, but then the phone doesn't work. Every time I switch back, it’s a ~15 min call to to the ISP for a new lease, making troubleshooting incredibly tedious.
Reply
Dave said 1:34PM on 10-16-2009
You can turn off NAT on the Airport Extreme. That should fix your issue.
THJ said 1:50PM on 10-16-2009
I think you're right. I did play with the AP Extreme settings a bit, but as soon as I turned off NAT, I lost connection to the outside for everything except the Ooma. Probably just needs some more trial and error to get working properly w/ NAT turned off on the Ap Extreme. Thanks :)
Frank Owen said 10:38AM on 10-16-2009
It's great that you have found a workaround for your problem, but I use Bonjour based screen sharing all the time with 4 different Macs, and have never had any problems connecting. Maybe there is something more fundamentally wrong with your network? The whole point of Bonjour is to simplify. You have clearly shown how not-simple things can get without it!
Reply
interconnect said 10:52AM on 10-16-2009
Welcome to the world of networking. That is called a "Static DHCP Lease" and can be found on higher end routers and in custom firmwares. I actually use Static DHCP Leases on all the laptops in my house. It makes it easy if you do anything that involves port forwarding on those machines and then if you take the laptop elsewhere, your settings are still setup to automatically obtain an IP and you won't have to manually change between "locations".
Reply
Jeff said 5:24AM on 10-17-2009
+1
It is even on the cheapies, In fact it has been on every router I have every owned (lots).
It is even on my $15 compusa branded one (really a pretty good router actually).
matt said 3:05PM on 10-16-2009
You may have a problem with how the IPv6 is configured.
Bonjour seems to prefer IPv6 connection over IPv4 connections.
The best approach is to us the name MacBookPro.local, as indicated in a previous post, as no IPv4 address is required. This will also tend towards IPv6, so if it does not work, that points at your IPv6 configuration. With "automatic" IPv6 configurations I've never had a problem.
Reply
markmalone720 said 1:29PM on 10-16-2009
Problem may be related to the DNS caching issues in SL. I have DNS issues all of the time, on the mac only, PC works fine. I can clear the issue temporarily by flushing the mac DNS cache. Anyone else have that problem?
Reply
Paul said 1:49PM on 10-16-2009
I have a similar problem, only both my Macs have static IPs. I have to go to my mini and untick then retick screen sharing to get it to work.
Got bored of that so now I just use Vine Server and Chicken of the VNC. Works every time. Even when my Mini file share doesn't show up.
Reply
mech said 6:58PM on 10-17-2009
vine server and chicken are neat as a proof of concept but damn is VNC slow for doing any actual work. it almost makes you not want to screen share over the network. I'd persist and find a solution that relies on Bonjour.
I'm currently SSing from a leopard imac to 4 different tiger machines without any issues, all on the local network, static IPs. VNC over the LAN was just impossible to work with.
Reply
Thargok said 10:23PM on 10-17-2009
It seems like a preference issue, I've had this happen before and it can typically be fixed by deleting (back up just in case) the following files:
com.apple.newtworkindentification.plist
NetworkInterfaces.plist
from
/Library/Preferences/SystemConfiguration/
and restarting. It will take what seems like a month for it to be recreated when you restart the Network Prefpane under System Preferences, but once you got everything back, it should work fine.
It should be noted that the problem is on the computer you are connecting to (check Console.app) not the computer you are connecting from.
Reply
TJ Luoma said 6:21AM on 10-18-2009
I've tried all the various suggestions, including turning IPv6 to automatic or off completely, and none of them seems to help.
The static IP works perfectly, and it has been helpful for other reasons as well, i.e. when I plug the MacBook Pro into a wired ethernet connection (i.e. it is connected via Wi-Fi and cat-6) I can make sure that I transfer files over the faster connection by making sure that I am connecting to the wired IP number.
Reply
Ondroo said 7:20PM on 10-18-2009
No need for a static IP... just use the hostname?
Reply
TJ Luoma said 9:30AM on 10-19-2009
In the VERY FIRST PARAGRAPH I explained that using the hostname DID NOT WORK.
x23 said 8:08AM on 10-19-2009
there is also the massively simpler method of just manually assigning your computer a static IP address above x.x.x.200.
anything from x.x.x.200 -> x.x.x.255 range has been set up to work this way on Airports for literally years and years now.
you do this with "Configure IPv4 : Using DHCP with a manual address" ... you *used* to have to do this with "Manually"... that appears to have changed in 10.6 and having you actually use the logically named "Using DHCP with a manual address" method.
i suppose make sure your DHCP pool ends at .200 i suppose in the DHCP tab on the Airport. unlikely you'd ever get anywhere near that high a number on a home network anyway.
way easier than writing down MAC addresses and all that unneeded nonsense.
Reply
TJ Luoma said 9:28AM on 10-19-2009
@x23: If you read the 4th paragraph, you'll see that I addressed why this was NOT a good solution for a laptop.
If you assign a static IP for your Mac and then bring it onto another network, it will attempt to use that IP on the new network. Two reasons this is a bad idea:
1. If you go onto a crowded LAN somewhere else, even that "over 200" IP address may be in use.
2. Apple's routers default to 10.0.x.x IPs. Linksys and other routers tend to use 192.168.x.x. So what happens when you try to add your Mac with a static 10.0.1.200 network to a network which uses 192.168.1.x? You're not going to be able to use the network, and you're probably not going to know why unless you have a really good memory.
DHCP Reservations for a specific network are a much better solution to this problem, because it only effects the connections I make to that particular router/network.
Setting up a DHCP Reservation is really not that difficult, especially if you use the DHCP Client ID, but even using the MAC address is a one-time setup which shouldn't take more than a couple of minutes.