-2

EDIT: I had to change the whole question up to reword it properly as the Access Point stuff had no relevancy to the main question.

As the title suggests, I wanted to give my Pi a static IP Address when connected to an ethernet port, one where you could just connect to it remotely as soon as it gained access to the internet. I thought I could do this just by following the tutorials online on setting a static address on my ethernet interface, but it turned out that the static IP had to be in range with the given IP, meaning in my case that I would have to set my Pi's static address to the address given by my PC's ethernet, being 192.168.137.1. I started becoming more confused, as I realised that this IP would have to then change whenever I went to a different location and connected through their ethernet there.

Is there a solution to all this?

4
  • What have you tried. There are literally thousands of tutorials.
    – Milliways
    Jul 26 '21 at 22:45
  • I thought part of setting up a pi as an access point usually involves giving the pi a static IP address - I know it doesn't HAVE to have a static IP address to be an access point, but all access point tutorials for the pi seem to always involve this one step
    – Bravo
    Jul 26 '21 at 23:32
  • You're right it does set a static address for the wireless interface, but for the ethernet port its dynamic and that's the one causing me problems. I did set a static address for its ethernet port, but doing that resulted in there being no internet connection to the pi itself, with its IP being out of range. It is true that I can set it within range, e.g. on my PC with the famous 192.168.137.1 then connect it to the pi(set the pi's address within that range), but will this same thing work when also connecting directly to my router? What about connecting to an ethernet port outside?
    – Thanos
    Jul 27 '21 at 11:47
  • This is a "network question" - it is not specific to Raspberry Pi. Please delete this question, or accept one of the answers.
    – Seamus
    Aug 20 '21 at 18:48
0

For you to be able to connect to your pi directly over the internet it would need a static internet facing ip address, not may home users have internet connections with more than one static IP address. Normally, they have a single dynamic IP address which the router shares between computers on the local lan via NAT.

To connect to a computer on your local lan (192.168.137.1 is an address on your local lan as are 192.168.137.2 .. 254) you would have to set up port forwarding on the router to redirect traffic from the single internet facing IP address to the computer on your LAN.

When you took your pi to another location, the internet connection would have a different dynamic internet facing IP address and your Pi will have a different IP address behind the router on this new lan, you would have to set up port forwarding on this router too. The internet facing ip address which you would use to access your pi would have to change for every location you visited.

However, you could do what you are asking if you set up a vpn from the PI to a computer on your own lan and then connect into that vpn to access your pi. Whenever the pi is plugged into a network with internet access it would have to open the VPN connection to your home network. For your home vpn server you would have to use dynamic dns on your router so that you could look up its IP address or obtain a static address from the Internet Service Provider. You would need to set up port forwarding on the router to pass vpn traffic to your vpn server on your local network

Search for OpenVPN, it would allow you to create a vpn which would make this possible

I hope this helps

0

No I don't think it works like that.

And there is a lexical ambiguity in the way you worded it as of now

If in the case Where you are keeping you pi and other computer on the same network and moving both of them to another network together,

on your computer you could use arp to find the pi by mac address whenever they are on the same network.

You could use a script to automate the search

If in the case you want your pi and computer to remotely connect over WAN and they are both on different networks occasionally changing,

You will likely need a 3rd computer or server to stay on one network and have the pi and computer communicate with the server so the pi tells the server where the pi were to be is so the server can relay that information to you main computer alerting its location.

This method will need the pis LAN to be forwarded to WAN on whatever network the pi were to join (Whatever network the pi would be on would need special rules).

If in the case that you want your computer to be in one place and just the pi moves,

The pi could connect to your computer and tell the computer directly its ip address and have the computer connect using the given IP.

This method will need the pis LAN to be forwarded to WAN on whatever network the pi were to join (Whatever network the pi would be on would need special rules).

A Pis (Or any computers) L(ocal)A(rea)N(etwork) IP and W(ide)A(rea)N(etwork) IP are different.

If none of these work, (They will take a bit to get working), please can I have more details to help you further?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.