There are several possible causes for this behavior.
1. Two (or more) computers on the local network have the same Bonjour name, such as "X's-MacBook-Pro.local". Resolve the name conflict by renaming one or more of them in the Sharing preference pane.
2. You have two simultaneous connections to the same local network: probably Ethernet and Wi-Fi. If applicable, disconnect the Ethernet cable or turn off Wi-Fi.
3. A Mac wakes from sleep due to network traffic. This is a bug in OS X that may only affect some models. You can avoid it as follows:
Open the Energy Saver pane in System Preferences and unlock the settings, if necessary. Select the Power Adapter tab, if there is one. Uncheck the box marked
Wake for Wi-Fi network access
if it's checked.
4. A device that gets its network address from the router wakes from sleep, and the address it was using before has been assigned to another device.
5. A third-party wireless router has incompatible settings or firmware. In that case, refer to the manufacturer or ISP for support. Restarting the router may help, temporarily.
6. If the router is an Apple device, it may need to be restarted.
7. A third-party Bonjour device on the network is malfunctioning. Finding out which is a process of elimination.
8. There is more than one DHCP server on the network. Typically, there would be two or more wireless access points configured to act as routers.
9. See this support article.
10. Back up all data. Make notes of your settings in the Network preference pane.
Triple-click the line below on this page to select it:
/Library/Preferences/SystemConfiguration
Right-click or control-click the highlighted line and select
Services ▹ Reveal
from the contextual menu.* A folder should open with an item named "SystemConfiguration" selected. Move the selected item to the Trash. You may be prompted for your administrator password.
Restart the computer and empty the Trash. You will need to recreate the network settings.
*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
Go ▹ Go to Folder...
from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.