Click here to subscribe for more videos like this!
Hey guys, in this video we’re going to talk about hosts briefly, so in terms of our local host actually. So, there’s two parts to this video, the first we’re going to cover is the hosts file and we briefly touched on that in a previous video I think when we were, when we were deploying I think our Meteor application with Apache 2. We went into our hosts file to create some routes for the, for the application. So, basically the host file is in “/etc/hosts” so we can go ahead and open that up just type “sudo nano /etc/hosts” and hit enter. Put in your password and this is our hosts file. So, we actually did we were in here for app.localhost, subdomain in python, so the virtual hosts, and Python deployment, and Meteor deployment we were in here, and I didn’t really explain to what extent you can use this file. So, as I explained in the networking introduction video, a DNS server basically hold records of what domains point to what IP addresses. Think of this file as an internal DNS lookup functionality. So, when I go to apt.localhost the first place my computer checks for a route is the hosts file. If it doesn’t find an entry for a domain in the hosts file, then it goes out to the router, and then your ISP, and then a DNS server, and it checks there if there’s any records for it. So, by adding entries here we can actually override default behavior of known domains that we want to change. So, what I’m going to do is open up Firefox here for a moment, and I’m going to go to a website that will allow us to get the IP address of google.com, because we’re going to be using that. Just gonna go to network-tools.com and I’m gonna type in here google.com, and we can see that this IP address is the one we’re looking for. So, I’m going to copy this here and I’m gonna jump back into this file. Now, this file can take three columns and we’ve only discussed two so far, so let’s go ahead and cover all the columns here in great detail. So, the first one is the IP address that we want a route to. The second column is gonna be the domain or the host’s name that we want to route to that. So, let’s just type in go.com and then the third column is an alias, so we can just type “go”. And, so when we save this file what we’re gonna is when we go to go, it’s going to go to google.com and their their servers have actually, their not ok so they’re doing a lot of internal routing there. Let’s try YouTube. So, what we’re gonna do again, we’re gonna get actually let’s try something that we know is going to work. So, I’m just gonna type in my own server name here, and grab that IP address, jump back into our hosts file, and I’m gonna paste that there. Now I’m gonna save this again and go to go.com. It’s saying it’s not found, weird this just worked.