Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to edit my host file to see how it works. But with no success. I enter this in my /etc/host file:

173.194.66.103 www.youtube.com

And when I type 173.194.66.103 on the browser I get redirected to Google (which it is!) instead of YouTube. Anything I am missing out?

Did try this one too but with no success dscacheutil -flushcache

share|improve this question

migrated from stackoverflow.com Feb 8 '13 at 8:44

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Hostnames are intended to abstract the user from IP addresses. You've got the abstraction backwards.

You can see this quite clearly with a tool like ping:

anew@Wintermute:~$ ping google.ca
PING google.ca (74.125.226.24): 56 data bytes
64 bytes from 74.125.226.24: icmp_seq=0 ttl=57 time=11.224 ms
64 bytes from 74.125.226.24: icmp_seq=1 ttl=57 time=18.605 ms
^C
--- google.ca ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 11.224/14.915/18.605/3.690 ms

Now if I add

127.0.0.1 google.ca

to my /etc/hosts file, when I execute ping I see:

anew@Wintermute:~$ ping google.ca
PING google.ca (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.051 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.104 ms
^C
--- google.ca ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.051/0.077/0.104/0.026 ms
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.