Public IP vs. Private IP and Port Forwarding (Explained by Example)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
have you ever written an application or website hosted on your personal laptop and works fine but the moment you move outside your local network you get this error right and you think oh I'm using the private IP so let me switch to the public IP and then you still get the same error right so we're getting this in this video we will explain the difference between the public IP and the private IP n how can you expose your laptop to the outside world your application to the outside world to the Internet and we're gonna explain all about routers and modems and all these things and why this is happening coming up what's up y'all this is Vanessa from eye geometry where it is a software engineer by example if you're new to this channel welcome we discussed all kind of software engineering concepts here tutorials programming pretty much anything else related to software engineering that part you look particularly interest me and what that's it let's just jump into the video so classically in the early nineties if you remember guys if you hook up your computer to this device that is called the modem that will pretty much you have one device and you more I want you hook it up to this this DSL or the modem you will get one IP address and that IP address is the public IP address and you pretty much can be identified to do the entire internet with this IP address right and that works fine if you a host an application an ordinary application on this IP address there everyone can basically use that IP address in that port and then can consume your application anywhere in the internet okay because it's a public IP address it's known everywhere however these days you pretty much must have multiple devices right and your local network so you cannot assign public IP address for your phone and Mac and and your TV and your Playstation you cannot do that right so pretty much every home now have what they call a router and the router serves multiple purposes here at first it is the one that connects you to the internet most probably it has a modem right and that is the machine the router is technically the machine that gets the public IP address right that's the only machine that gets the public public IP address but the rest of your network will become an internal local area network LAN right and because of that we need somewhere to it's like we need some sort of an addressing system to address these guys right and that's why the router also gets another internal IP address which is usually like 1 9 2 & 6 8 1 1 or sometimes 1000 1 or sometimes 1 7 2 like all these internal stuff right and these are not addressable in the Internet these are purely internal stuff ok so your machine will get 99216 l19 and then you can run your application perfectly works if you're in turn of your internal so if you you if you're in this phone like you your your phone and you're connected to the Wi-Fi to the same network you can access the application because you're in the same network however ok if someone outside tries to access that you'll immediately they'll immediately get it because what the heck is 1 9 2 1 6 8 1 9 this is not a publicly addressed IP so you'll clearly get on our header ok so clearly we will say ok uh I am going to give people my public IP address which is let me type it up so you just type in Google Bob what is my IP and you get this number and then you pay give it to them and still they get an error the older they used your IP address so what's going on there and the reason is this slow router is the owner of this IP ok if people connect to this IP address on this port the router has no idea what this application is 8080 it has no idea what this application because and it's not running right because 8080 or this nodejs application or whatever application you're on is not running at all it's actually running here so how this the router knows that hey I should forward this to this you should tell the router this this concept you should teach it the one of the way to to route your application is to do port routing okay and that's like easiest way but there are a lot of ways to make your application that is hosted here on port 191 6 8 1 9 visible to the Internet there are many ways ok and that the easiest way is port forwarding ok so what is port forwarding port forwarding is the idea you create a table in your router and a lot of routers support that you go to your firewall options on your router and maybe we can show this if we have the time I can show this a hopefully like in a segment quickly how to do that but essentially what you do is like hey router if you ever receive a request on your public IP which is this one on port 8080 please forward it to moi which is 192 168 1 9 ok that's what's essentially port forward that means again and you can literally write that in your router you said hey 8080 means 196 day one night so router says if it receives an 88 you request it will automatically bounce it up to your application and that's why you will get the users will see your application oh this this this means that your IP address should be hard-coded static you cannot assign this dynamic because every time you change you have to change that thing ok also it's little risky to expose your internal network like traffic like that ok because you don't want to expose your internal network traffic outside like sometimes some people can gain access to your application and do bad stuff to your machine right so if you want to do this do it on a machine that you don't get about ok all right and all right so let's try to jump and do maybe some port forwarding so alright guys so I have a little application here on my no js' here and let's look basically some emojis right very basic application yeah this is my private local IP address off my macbook ok and this is the application running on 8080 obviously if I go to my public IP address I am going to get an error right and the reason is because we discussed that right and even if I talk my phone outside the Wi-Fi network and I use 4G I'm gonna get the same error because now I'm using the public Internet okay so how can I solve this if you go to your router right this is my basic router configuration here and there firewall you can click firewall port forwarding and this is as you can see this is my public Wi-Fi one IP the wide area network and then I'm gonna create a simple node application here no js' this is I'm gonna create a new application I'm gonna say hey anything that range from eight zero eight zero I don't wanna everything just eight zero eight zero I want you to forward to this device which is than my Mac IP that Saint Mac which is my machine okay and if you click here you'll you'll see a list of all your entire list obviously your your router will change based on your router configuration but you can pretty much find this into any router okay once you guys said add okay this will configuration will get added and any TCP traffic which eventually this is HTTP right HTTP just bounces back to TCP all right this will get forwarded to this machine so let's try if now i refresh this i will essentially have access to that and I'm gonna show you also how I can do it through my phone hey guys as you can see I have I am on my phone I turned off the Wi-Fi so I'm not on my local area network anymore I'm only on 4G so I'm gonna go ahead and go to the browser and literally use the IP address the public IP address of the router and 8080 which we have forwarded and if I click OK the test and and then we will see the application as you can see guys alright so we can actually connect this and if I give you this address you will have basically even access my application but I'm gonna turn it turn this off after I published the videos there you won't be able able to public's as this application alright guys I hope you enjoyed this video if you enjoyed it give give it a like and subscribe to check out the other content of this channel we discussed software engineering by example we have a lot of topics like this one way I talk about proxies we talk about tutorials Python JavaScript pretty much anything software engineering then it particularly interests me all right I'm gonna see you in the next one you guys stay awesome
Info
Channel: Hussein Nasser
Views: 225,245
Rating: undefined out of 5
Keywords: hussein nasser, private ip router, public ip address, port forwarding by example, port forwarding router admin config, expose private ip to internet, private vs public ip, public ip address and private ip address, public private ip address explained, port forwarding explained, port forwarding not working, port forwarding tutorial
Id: 92b-jjBURkw
Channel Id: undefined
Length: 9min 39sec (579 seconds)
Published: Thu Mar 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.