How to Access your Raspberry Pi Website over the Internet (with port forwarding)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is tony teaches tech i'm tony and in this video i'm going to show you how to access your raspberry pi over the internet and the way we're going to do this is with something called port forwarding now if you're not familiar port forwarding is essentially within the context of your home router taking traffic coming into your router at home and forwarding it over a specific port to a specific device on your network in our case that specific device is the raspberry pi now on this raspberry pi i have an nginx web server running and it's hosting a wordpress website so i have separate video about how to set that all up so check that out if that's of interest to you but otherwise we'll continue on with the tutorial and setting up the port forwarding so on my screen here is the website that i am running off of my raspberry pi if you know anything about ip addresses you'll know right away that this is a local ip address and that's very important distinction to make in this video tutorial the difference between a local ip address and a a public external ip address so this is only accessible on my local area network here at home if you're connected to my wi-fi if you're plugged into my router then you can access this this website but anybody outside the rest of the world cannot access this website because we have not set up port forwarding yet so um let me just show you real quick here uh i'm gonna log into this the raspberry pi via ssh so ssh root at uh it's not root it's pi at the ip address so 192.168.0.136 password hit enter and uh what i'm going to do is i'm just going to look at the access log for the nginx server so we're going to look at that every second it's going to refresh and update and what you'll see here is that the last time the the raspberry pi website has been accessed was uh march 26 at 23 37 29 okay so if i refresh the page hit enter you'll see the log update and now the last time the raspberry pi has been accessed is 23 41 20. okay and we could do it again it entered 23 41 30. so that sounds about right um this will come in handy when we're accessing our raspberry pi externally over the internet but it's good to just show you that right off the bat now uh we'll get out of here and what we want to do is if if you don't already know it determine the ip address of your router for me i know the ip address of my router is going to be a little bit of a new tab here and actually we'll make this full screen again my ip address for my router is 192.168.0.1 and you'll see a login screen like this now if you don't know the ip address for your router you can use the netstat command i'll have a video about that that you can check out on on mac or linux or if you're on windows you can use the ipconfig command ipc on fig command and that'll tell you whatever the default gateway is for your for your local area network okay so now uh let's log in okay to the the your router and again if you don't know the credentials uh you'll just have to google that or i have another video about how to figure out your router's credentials and all that stuff so um check that out at this point in the tutorial it's going to be a little bit different for everybody else because every router has a different structure as far as how everything's laid out how you do port forwarding and all that stuff but as long as you understand the fundamental concepts of what you're doing you should be able to figure it out for yourself so what that means basically is the steps that i go through right now on my router are going to be pretty much slightly different for you okay but in the end all we're trying to do is port forward okay so i'm here on my router and what i want to do is i typically look under the advanced section because port forwarding is something that's pretty advanced and for me i have to i don't actually do the port forwarding on my router i'm taken to my isp to do the port forwarding which is kind of weird but it works because i've been through here and i've done it so i'm going to log into my account with my internet service provider and i'm going to navigate to the section where i need to do the port forwarding so i think if i remember correctly i have to go to this my network go to c network go to advanced settings go to port forwarding and then add port forward okay so um the device for this port forward uh is going to be raspberry pi for me um and i have a comment i'll have a comment to make after doing this uh because i know it's going to look different for you so i'm going to forward traffic to my raspberry pi uh it's going to be a manual setup the port number that i want to afford is 80 because that's the port that http uses and the protocol only needs to be tcp in this case okay so i'm going to click on next it's adding that port forward and the port forward has been added so we can confirm that here so the ip address of my raspberry pi this is the local ip address 192.168.0.136 and the port the the port that's being forwarded is port 80 over the tcp protocol so again anybody that accesses my public ip address will look that up in a minute anybody that accesses my public ip address over port 80 will be redirected to my local ip address on my network which as we've shown you is the uh nginx website that is uh the wordpress website running on top of nginx okay the one comment that i wanted to make is a more standard um port forwarding page looks like this so this is a an image that i brought up from one of the older routers that i've used the linksys router typically in this case it would be under applications and gaming a single port forward and then you would ext you'd fill in the external port 80 the internal port 80 the protocol you would change that to just tcp in this case and then two ip address it would be 192.168. in my case it would be a 0 and then 136. click the enable checkbox and hit save settings so that's just another example about what port forwarding might look like on your router now i mentioned an external ip address what is an external ip address well we can there's a couple different ways you can figure out what your external ip address is but google is a good place to look so you can literally type into google what's my ip and that will come back unfortunately for me my ipv6 my ip version 6 we want the ipv version 4 ip address and it'll pull that up for us in a second so my public ip address is 6899-206-145 so let me copy that we're going to need that and come back to our raspberry pi website which is again hosted at this ip address locally and in order for this to work properly we have to tell wordpress the new external ip address to operate under because well let me just show you let's go into the wordpress admin dashboard for this the username is tony the password i'll type that in and when we uh what we want to do in here is update the um under settings general we need to update the wordpress address url from the local ip to the external ip okay so we'll change that in both cases for the wordpress address and the site address and then hit save changes and uh it's not necessary but we'll log back in okay so now if we look at that we are operating under our external ip address okay so at this point we have configured port forwarding um i think the last thing that we have to do is test it out so i have my cell phone here and we're gonna disconnect from wi-fi just so we can use a network that is not the local network here so right now we're connected to the 4g lte and what i'm going to do is open up a web browser here and open up a new tab and type in the ip address of my my external ip address so that is 68.99.206.145. and as you can tell i was already in here before doing this as a test i'll hit enter to load that page and it's loading and the site cannot be reached so what did i forget let me pause here for a second to think about this okay guys i'm back and after doing a little bit of research unfortunately it turns out that my internet service provider is blocking port 80. so here is the the article cox.com cox is my internet service provider as you can see here port 80 inbound connections meaning the connections coming into my router over the tcp protocol are unfortunately blocked uh for they they say for the worms reasons and i guess so i explicitly cannot host a web server on out of my home network here um which is really weird because when i tested this out a week ago everything worked fine now at this point i hate to do it but i i can't complete the tutorial and show you uh all the way through to the end because uh port 80 is blocked and that is like a dead end for me and that might be the same thing for you too if your internet service provider blocks port 80 then that's not going to work and i guess the other option would be to do a different port have a host a host your website under a different port other than port 80 but from what i can tell the only there i've tried a whole bunch of ports and even port 443 although it's not on this list here um is also blocked uh which if you're not familiar 443 is the https port for secure http connection so um yeah like i said uh as long as your internet service provider is not blocking port 80 then everything should work just fine for you it's like i said just unfortunate that uh my internet service provider is blocking that port and for that reason i can't bring this tutorial full circle but everything up until this point still applies as far as how to access your raspberry pi over the internet so please uh yeah please please don't think that this tutorial is a complete favorite just because i can't show you that on screen here but like i said the same concept should apply for your internet service provider assuming that they don't block any ports like that so hopefully that was valuable for you if it was give it a thumbs up subscribe to this channel for more videos like this from me in the future and if you do i'll see you in the next one [Music] you
Info
Channel: Tony Teaches Tech
Views: 62,689
Rating: undefined out of 5
Keywords: access raspberry pi over internet, how to connect a raspberry pi to the internet, raspberry pi internet server, raspberry pi port forwarding, port forwarding for raspberry pi, port forwarding raspberry pi 3, port forwarding raspberry pi ssh, raspberry pi port forwarding not working, how to port forward raspberry pi, port forwarding raspberry pi web server, port forwarding ssh raspberry pi, raspberry pi 3 port forwarding
Id: AFeye1zLpFo
Channel Id: undefined
Length: 12min 24sec (744 seconds)
Published: Wed May 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.