Now, you could pinged the network router, yet, you couldn’t access
google.com
. It’s because the way internet runs is by using IP, not names. So, when you type google.com, actually your system is trying to translate it into IP.
There are two ways of setting it.
#1 Using
/etc/hosts
This is an ARPANET legacy and still holds true. Although nowadays we are using DNS, but this file still can be used to point in some site. This is what it looks like:
127.0.0.1 localhost rajagukguk-laptop
It binds IP 127.0.0.1 to localhost and rajagukguk-laptop. So, when you type localhost, you would be directed into 127.0.0.1
#2 Using DNS
There are ways to set DNS, but the default standard is using
/etc/resolv.conf
. Here’s my
/etc/resolv.conf
:
nameserver 152.118.24.2
search ui.ac.id
The first line is the DNS server that we would be using to query IP. The second line is about our home network name. So, when we type http://www/ the address will be rewritten as http://www.ui.ac.id/, or if we enter “webmail”, then it would be rewritten as webmail.ui.ac.id. Neat, eh?
Now, here’s some bonuses tips.
1 If you are a web developer
When we entered an address, the system will looked into /etc/hosts first then your DNS. So, you could set your own version of something.com before you published it with real IP. For example, smartcard.ui.ac.id is situated on 152.118.24.116. But, we are going to pimp that one out. Instead of pimp it online and pissed people, I could set another box in 192.168.1.68 and then set my development PC to point into that address. So, in order to do that, I add my web development PC’s /etc/hosts as following line:
192.168.1.68 smartcard.ui.ac.id smartcard
So, everytime I access http://smartcard.ui.ac.id/ from my browser in that computer, it would go into 192.168.1.68 instead of the real one.
2 You are an anti-ad
WARNING: I don’t recommend this, because ad is something that some people lived from. But, sometimes a site is awfully slow because of these ad sites keeps pushing bad javascript.
[Gah! This is left as an excercise for the reader. HINT: Point them to localhost]