Basic Home Networking 101 - Computer Stuff They Didn't Teach You #17

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey friends i'm scott hanselman this is another episode of things they didn't teach you now certainly the first comment will be but they did teach me that or i learned this in school and that's okay i learned a lot about tcpip in school but unfortunately i sat down on day one and the next thing i knew on day two i was looking at ethernet packets on wireshark and that's not what this is about this is more about basic networking what a developer what a prosumer a professional consumer or someone who's an enthusiast needs to know about basic networking if you know these things that's cool you're welcome to hang out but no pressure you can certainly vote with your feet if you do like content like this i would encourage you to try my other videos this is pick number 16 or so of a pretty good series please do subscribe i'm getting close to a hundred thousand and i'm understanding that they will give us snacks once we hit 100 000 subscribers so please check it out all right so there's a lot of great videos teaching you networking one-on-one let's try to do something a little bit different we'll do it all in one take and we'll start with a problem all right let me split my screen here so here i am in my browser and we'll go and we'll type in hanselman.com which is my blog and we'll hit enter and it says here hanselmans.com server address could not be found it looks like i'm not on the internet okay well or something's happening it says name not resolved i typed in a domain name like google or hanselman or whatever and it didn't work so what can we do well we can do a couple of things i can go out to the command line you might call it dos or bash or powershell i'm just happening to be in the windows terminal and i could say ping hanselman.com and immediately see how quickly it said nope no idea what that's about so if clearly something's not working now there's a couple of things that could potentially be not working but we have to ask ourselves which of these things are there that could be wrong well let's type in network and on windows 10 i could click on view network connections and you might see this slightly older looking thing here and you see we've got bluetooth and we have a disabled ethernet connection so for the purposes of this demo my wired connection i have removed it so i am offline right now we can also see over here that our wi-fi connection is not connected because i'm on a computer that has both wired and wireless when you go on the internet you can use either one of those you can use either or both i really recommend that if you want really reliable internet that you try things wired a wire is always more reliable than wireless that's a fair statement for the purposes of this what we're going to do is we're going to set up a router will try to get me on the internet so here is a router you may have seen one of these before there's lots of different routers okay now that term router itself is an interesting and complicated one because there are routers there are bridges there are hubs this router here is going to allow us to get from one network to another we've got a couple of things going on here we've got our wireless antennas which means we can talk to this with wi-fi okay and then if i look on the back of this here we've got a yellow section here that says when wide area network and then we've got these lan ports or local area network so this is inside my house and this is outside my house so this router also acts as a bridge of sort to let us get between here and there now you have wi-fi in your house somehow perhaps maybe you have something like this and you have a cable like coax cable big round cable with a little hole in the bottom coming from someone like comcast or xfinity or maybe you have fiber fiber optic sending light through tiny glass wires and then that comes into either a router or sometimes a bridge that turns it from that format coax cable fiber cable maybe a dsl everyone's internet's different into this wired format okay now this is not on the internet right now but this is interesting remember how we said it has lan or local area network connectors maybe we can plug into this and it will let us get on the internet and we don't need to do anything that would be interesting wouldn't it well what i did i set up a cable here i'm going to plug it in here okay before i do that let's confirm that we don't have an ip address so ip address means internet protocol address it's like a phone number just like everyone in the world that has a phone has a unique number every device every light bulb every computer every phone has an ip address that internet protocol address is a unique number that will let you talk to it but it's not always unique it's unique to a certain scope or a certain area for example you know how you call your doctor's office or you call someone and you say can i have extension number three well there could be extension three at your doctor extension three at the dmv extension three the government extension three at the pharmacy those threes are all different threes they're all still the number three but they are an extension so you have to get into the building and then go to the extension so the number that we all think about is the one that gets us to the building and then that extension gets us inside the building so this device here this router is going to give us a number that's going to allow my computer to get on the network inside my house let's see if we have an ip address right now i'm going to say ipconfig if you're on a mac or you're on linux you might say if config i'm going to say ipconfig and i'm going to look here and i see some things that you might see on a developer's machine this is a virtual switch that's from something called hyper-v you don't need to worry about it's not real this is from linux here's my wireless adapter not connected here's my local area connector here nothing is connected i do not have an ip address right now that's going to let me get on the internet and again we saw earlier when i tried to talk to hanselman.com that actually failed okay now let's connect to another location i'll just move myself over here and i'm going to click on the network and i'm going to click on hanselman demo that's called an ssid that has a address that is being broadcasted from this fellow right here councilman demo and i'm going to go ahead and connect to that it might ask me for a password if i put a password on it or if it has saved a password it's just going to connect there you go so it's saying i need to connect so i'll put in a password all right so now i am connected all right so let's switch back and let's type ipconfig again now right off the bat look at that wireless lan adapter wi-fi as an address so this is like when you go and you get assigned a phone number i just got a unique number often times in your house and you can check this yourself now by typing ipconfig in a terminal or command prompt you'll get a number like 192.168 dot something dot something and it gets more and more specific as it goes deeper into that what's called that dotted quad this number here is kind of like my my extension this is you know number 109 for whatever reason and then this part here is super interesting this default gateway 192.168 again notice the same the same scope dot 3.1 that is usually in always this guy it's the gateway to the internet that's the ip address of this so if you're ever setting up a new router and you connect to it and then you're like how do i talk to this router how do i do something how do i connect to the router usually they have a little web server on here and it's almost always that default gateway number that's the way that i number 109 i'm going to get on the internet i'm going to hop through this just like if i were an extension at a doctor's office i would press zero and then i would talk to the operator and i'd say hey can you give me an outside line that default gateway is going to let us outside these things here are for the future for more complicated videos that we'll talk about at another time now if i disconnect the wi-fi i'll just do that real quick okay i'm off the wi-fi now i type ipconfig it's gone jump on again i'm just going to press up and we're back now look at this let me see we scroll up a little bit before we got a 109 and we disconnected and then we came back and a little later we got 109. that's kind of like going to your phone store giving them back your sim card and then maybe a couple days later you go back and say hey can i get my phone number back they may or may not say yeah we'll give you your same phone number or they'll say you know somebody got here before you we gave them your old phone number we'll give you a new one they're not really giving you the phone number to own they're leasing it to you so in this case here i was just leased that ip address i was given it temporarily i don't really own it now i could ask for it to be more permanent i could say i want a static lease i always want this number and that's something we'll see in the configuration in a little bit okay cool so i have an ip address surely i can get on the internet right now well let's go and ping or go hey is anybody out there hanselman.com see if that works it's waiting longer before i remember that it just went like that and it said no immediately here it's it's hanging a little bit so we know something's happening so that must be a good sign so it tried something and then it gave up we'll try it again in the browser okay so that's not working that's interesting and since we don't know the ip address of this location or google or bing or whatever we're really not on the internet but remember when we did ipconfig there's that gateway that gateway and that gateway as we mentioned represents that first hop that first way out so let's take a chance and let's go ahead and select that and we'll put that in our clipboard and then i'm going to go and say http and i'm going to put in that number oh look at this so that's this that is this that's a little internal web server we're not talking to the internet we are talking to the intranet in this case directly to our router so i put in the password i can see a couple of cool things i can see dns domain name servers these are servers that it's trying to talk to dns domain name server when i say hanselman.com i've never heard hansel.com you don't know me well what it's going to do is it's going to call out to the internet and say hey has anybody out there heard of hanselman.com and then it's going to turn it into an address like this it'll try there first and then it'll try there first but it doesn't seem like that's working very well does it we don't have a way to get out to the internet yet so that's interesting so we'll talk more about dns in just a second and then down here we know my computer's name is ironheart because that's what we saw in our prompt you see that in my prompt i have the name ironheart so that's the name of this computer and this computer was given was least temporarily the ip address of 192 168.3.109 again you'll very often see that that 192.168. you know how uh in the movies the phone numbers in the movies are always five five five something something something because they're not real there is no number where you can just go hey five five five that that that that and then they'll answer the uh the phone they've made those fake addresses their internal their internal phone numbers to the movie theater to the movie universe okay well you might check your ip address someone who's watching this video may check theirs and say hang on i'm also 192.168.3.109. that's weird that's because that address is kind of reserved like 555. that's the internal one yours might be 10.10 or something there's lots of internal addresses just like extensions like one or two or three those are numbers that you couldn't have on the actual internet so we need that gateway to go and talk to someone that they say is upstream of us upstream of us so it looks like we've got our wireless network we've got lots of bandwidth it's ready to go it's giving out ip addresses maybe we could have someone else get on our network let's try that well this right here is a a raspberry pi a raspberry pi is a tiny computer okay got a tiny computer with a tiny connector here now i'm going to go ahead and lean over here and i'm going to give it some power it could be anything could be a laptop could be a raspberry pi it could be my phone i'm just gonna plug it in and we'll hear it make a little fan noise as it starts to spin up here okay so it's starting to think and i'm going to take this and i'm going to plug it in to our router so it's going to join our our intranet now remember i don't have anything plugged in here so how am i on this router i'm talking to this wirelessly ironheart you can see right here is talking to that wirelessly i'm going to go ahead and plug in like this okay so he's now wired my raspberry pi is now wired walk into this while i'm waiting for that raspberry pi to join our network i'm going to take my phone i'm going to join this network because that might be interesting all right so i'm going to go ahead and join my phone just like i'm joining any other wi-fi join that's thinking and it says cancel the demo up at the top there i'll hit refresh oh there we go there's my iphone that's cool so the iphone just showed up look he got a number 156 and looks like he's got 12 hours and he'll be refreshing that every once in a while hey look at that hey wow my apple watch jumped on that network because it talks to my phone so now i've got four things on my network my raspberry pi showed up my phone my apple watch and my computer that we're on right now all talking to this new network but the network is not talking to the internet okay so the network inside my house is working great and talk to we can talk to each other if i had a printer i could print to it i could talk to this raspberry pi that's cool but i want to talk to the actual internet well i need then to connect to my isp my internet service provider so i'm going to plug this in and i'm going to plug it in to the when that wan port that wide area network port this is called upstream why do that let's look in our interface here and confirm that we are in fact not talking to anyone upstream here it looks like our wan our wide area network is a different ip address it's 192 [Music] 168.1.142 so that's interesting 192 168 here 92 168 here well i've set this up in kind of an interesting way because i wanted to have a conversation about this before we do that let's check and see if hanselman.com can be hit now that looks like it can all right can i ping it can see how it knows the number of that website well that means that we are able now to reach that dns that domain name server from before we go back to our overview we scroll down these dns servers this domain name server right there that's now available and if i go and ask it questions let's go and say name server lookup and i'll say hanselman.com that worked i can say server 192.168.1.2 i can ask enhancement.com or google.com or new yorktimes.com and see how it's figuring those things out immediately yeah some locations have multiple addresses because you want to make sure if you hit a website that you have multiple options you want to make sure that that website is going to work i can also type server i could say 8.8.8.8 which i think is google and i could say enhancement.com and i could say server 1.1.1.1 which is uh cloudflare you notice how the number comes back the same right my ip address my phone number my identity doesn't change uh no matter who i ask so these dns servers are just redundant systems that are available to to anyone and as soon as we plugged in we were able to get those but notice that there was that intermediary one it asked a local server says have you heard of hanson.com maybe we don't have to leave the house to get that answer and then we said well maybe we don't know that let's see uh if another server knows or maybe another server knows dns can kind of fall back it checks dns one and then it checks dns2 etc etc having one locally is really common on a router like this because it makes things faster that way you don't have to ask the whole world for an ip address you can just get one that's been cached or been remembered which is cool okay let's take a look at what this looks like though we'll go into draw.io let's draw some squares shall we so let's say that this is my house and then we'll type in computer i'll get a couple of computers here and we'll say that's a computer and that's a computer and there's a laptop okay then we've got this router this little router that we've got before let's see if there's a picture of a router that's a nice one okay i'm going to put that on the edge here okay inside that square inside my house is 192.168.3. something dot x that's what we were seeing remember that the numbers that we were getting were 109.146. this router can hand out ip addresses to all kinds of folks maybe they have an iphone one they have a picture of an iphone cool oh that's a old iphone we'll make a little squat iphone over here all right so now i can go and say all right well this one this one gets dot you know 192 168.3.109 and this one gets dot something else doesn't matter you don't need to worry about these things this happens every single time you go to a friend's house or you go anywhere and you get a new ip address you get on their network and someone gives you a number sometimes that number changes and sometimes you can hold that number for a long time and you hold it for a long time it's usually called a a static lease you can get that ip address either via a wired cable or wireless that's totally cool now this is inside my house typically this router as we saw before when i held it up has multiple wired connectors it has inside the lan and outside the wan local versus wide area network so it has another ip address and we don't talk about that iop address because we're thinking about the inside but it might be like 50.50 dot some big number dot something we'll just make that a big a big scary number that's its external number and it's got one foot on the inside and one foot on the outside which is super interesting so it has that ip address which is its external or it's wan and then it has its lan ip address which might be like this which is the one that we hit in the browser so it's got left hand and right hand and when anyone wants to get out when this computer here says i want to get on the internet it's got to go and ask this fella and then head out okay but in my case i have done something a little interesting i put it on another network watch this time for more squares i'm going to go ahead and push that one to the back i already have a network in my house i have another router and our internal lan our internal network is 192 168.1 dot so then this router got an ip address from the other router can't remember which one that was what does it say dot 142 142 so up here that's annoying oh wait when this computer wants to get on the internet it says here's the gateway here's the gateway and then it finds its way out onto the internet and that's just for the demo purposes of what i did but for the most part most of you all will be in a situation like this i'm going to make a simpler network get rid of you we'll get rid of you it brings bring you back down here and we'll zoom back in again so everyone there is on the inside and this router is that way to get out that that bridge to get out it is a gateway okay once we have the ability to do that we have the ability to get on the network now i want to point out though this device may have gotten on wired this device was wired this was wi-fi and the phone was wi-fi we come back over here we noticed that we ended up with a wired raspberry pi and a wireless watch and a wireless phone and a wireless this computer okay but i was able to think about how that network looked i come out here to the command line i'm going to clear it out we'll say ipconfig we saw we had an ip address of 109 that was assigned to us and that default gateway of 192 168 3.1 which i was then able to visit now from a password perspective you may wonder where the password came from well most routers have a sticker on them or you can go and google for the name of your router and default password you can get that password and then hopefully change it to something that's not default because that's a little bit scary now once you've got a network like this on the inside of your house you can do all kinds of things you can have little tiny switches like this so i can take a wire that comes out of the wall upstairs and now i've got four that can be used in that room i don't want to use my wifi which is cool i can take a bunch of devices here i've got six raspberry pi's in a row and i could connect them all to a shared switch or pub and then they would all get ip addresses i can pass out in my house 250 or different ip addresses because i have all of this space all right 254 1 2 3 etc etc but i have a lot more control than that and we'll talk about that perhaps in another video because you'll notice that before i had dot 3 and then i had 1.2 inside your house you really can't run out of devices you can't run out of ip addresses i think if i looked at my personal network which is a little higher up here on my personal network it looks like i've got about 60 or 70 devices and as we zoom in we can see different devices that build out this network and i've talked about this in another video as we go from place to place so that should be a basic understanding about the kinds of things you want to think about let's review all right devices that are on the network whether they be phones or raspberry pi's all have an ip address they have a unique ip address an internet protocol address that allows you to talk to them but you have to be able to get to them even though we had an ip address that we were handed out by our little router it was an internal address we were getting 192.168.3. something addresses but we didn't have a way out we didn't have a route to the outside because we weren't connected to the actual internet when we hooked up our wan port that's the usually the yellow one on your routers and that connected out to the outside then our folks on the inside could be routed to that default gateway and then out to the world which was cool one last thing i'd like to point out is that at least on windows you can go to the windows folder and then under system32 and i believe it is drivers and what we say etsy or etc and you can say notepad and this is called the hosts file if you get into a situation where you're finding that i can't talk to a website or i want to pretend that a website is actually local for example when i'm testing my my blog i actually go into this host file and i say local.hanselman.com is actually my local computer that's a unique number it's called localhost or 127.0.0.1 it's a magic number just like five five five one two one two is a magic number magic phone number and i can say if i type local.hanselman.com it will go here okay and i can do that for the purposes of developing or doing different work that i might want to do internally so sometimes you'll be reading instructions on the internet and they'll tell you hey you should go and modify your hosts file you can do that but you want to be careful you don't want to have something like google.com in there lying to you and pointing somewhere else so definitely watch out for that you can always again go out to ns lookup you can type in server the ones that you can usually try and test on are 8.8.8.8 or 1.1.1.1 and you can type in something like your own website and confirm that it's the one you expected to get you want to make sure that the number that comes back is the one that you'd expected all right so we've talked about how names are resolved dns a little bit about that it's worth pointing out that the dns server that you may be given by your isp by your internet service provider is not one you have to use some isps have a thing where you put in a search and if the ip address doesn't work they automatically send you their search page they're doing what's called dns hijacking you misspell something and instead of just saying no i don't have it they send you their weirdo search engine you can set the dns on your system the way that you want to you can tell your computer to pass out to everyone else and i want you to use this specific dns and in fact i've done that myself i'll show you a little trick as this video gets just a little bit longer than i'd like it to be i've set up something that's called a pie hole a pie hole is a raspberry pi that does dns servers for you and what it does is it blocks things it actually blocks advertisement because i can put my own domain name server up there i can block traffic right now 10 of the traffic that comes into my house is blocked if i want it to be i can just go here and say login and i will enable it all right you see there and then if i wanted to hit something like an advertising web page you can see that none of the ads happened because the name was not resolved you can really take control of your network once you understand a little bit about how these things work all right now again your router might look different i just happen to use this one here called open wrt it's totally up to you to pick the one that makes you happy thanks so much for watching and hopefully i didn't make too many mistakes if i did put them in the comments folks are always quick to help and please do subscribe thanks
Info
Channel: Scott Hanselman
Views: 35,025
Rating: undefined out of 5
Keywords:
Id: lp_CJba4RmU
Channel Id: undefined
Length: 33min 23sec (2003 seconds)
Published: Mon Dec 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.