Unable to resolve computer name but able to resolve using ip address on my mac?

0

On my mac it resolve the computer-name or localhost or ipaddress of course. But i'm trying to use my phone to access the server setup on my machine but I can only resolve it using my mac's ip address but not the mac's computer name. Any reason on why this is? Also I have modified the /etc/hosts file to map my computer's ip address to name like mypc.dev. And tried to access mypc.dev/ on my phone but it cannot resolve the dns as well. Any advice on how to proceed?

dchhetri

Posted 2012-12-24T05:49:19.517

Reputation: 103

This is off-topic as it is not a programming problem. However, you should also include the model of your phone, and it's operating system. – RB. – 2012-12-24T12:07:34.543

Answers

2

Whatever you set in your /etc/hosts only works for your local machine, not for any other machine, not even when it's in the same network.

So what you have to do in order to get the name to work is use/set the actual hostname for the machine. I'm no OSX guru, but I believe it's pretty similar to Debian systems, so it should be under /etc/hostname. You can also temporarily change it with the hostname command, like:

hostname mypc

After you've done that, you also need to make your webserver "listen" on this hostname. By default, it only listens to IP or localhost connections. You'll have to tell it that it should listen on the mypc name. There should be something like this in the default Apache configuration:

ServerName localhost

Either change that to your desired name, or add an alias for mypc right underneath that line, like this:

ServerAlias mypc

Then restart Apache and it should start listening on that name.

Oldskool

Posted 2012-12-24T05:49:19.517

Reputation: 654