The sharing screen would suggest it's a problem with your router, but I don't think that would explain the problem with the Terminal. Still, just to make sure I'd probably try disconnecting the computer from the router (and the internet all together) and rebooting while it's disconnected.
I've seen something like that where I work. If the IP address given to the Mac reverse-lookups to a DNS name, that DNS name (even if it's different from the Mac's actual hostname) will show up in the terminal. Happens on some Linux boxes here too.