Nicolas_235
Posts: 4
Joined: Thu Jul 02, 2015 10:12 pm

Internet IP Address

Thu Jul 02, 2015 10:47 pm

Hello,
I made a small project on my Pi. I configured server, autostart, ports on router etc. but I don't know how to get an IP address without visiting the IP checking webpage like whatismyip.com (using LXDE and sitting right in front of my monitor in the house) ...
I have to have access to my Pi from everywhere by the internet (or in other words: I have to know what is the Pi's IP address). After some time the IP address will be changed right ?
Am I supposed to do anything to make my Pi's IP address static (for web) or something ?

I'm sorry for any language mistakes if they appeared.
I'm still learning this language.

User avatar
DougieLawson
Posts: 39124
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Internet IP Address

Fri Jul 03, 2015 7:42 am

Which IP address do you want? Your LAN address or your public IPv4 address?

LAN address is easy
hostname -I # capital EYE
ifconfig -a
ip show addr

Because you can't get your public address without going out to somewhere on the internet and asking it to return the remote address that just connected.

sudo apt-get install dnsutils
dig +short myip.opendns.com @resolver1.opendns.com

curl -s http://httpbin.org/ip

With my home router (Technicolor TG582n) I can scrape the public ip address from the router's home page
curl -s -g "http://192.168.1.254/landing.lp?rs=getINFOIP" | tail -1
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Nicolas_235
Posts: 4
Joined: Thu Jul 02, 2015 10:12 pm

Re: Internet IP Address

Fri Jul 03, 2015 11:35 am

DougieLawson wrote:Which IP address do you want? Your LAN address or your public IPv4 address?

LAN address is easy
hostname -I # capital EYE
ifconfig -a
ip show addr

Because you can't get your public address without going out to somewhere on the internet and asking it to return the remote address that just connected.

sudo apt-get install dnsutils
dig +short myip.opendns.com @resolver1.opendns.com

curl -s http://httpbin.org/ip

With my home router (Technicolor TG582n) I can scrape the public ip address from the router's home page
curl -s -g "http://192.168.1.254/landing.lp?rs=getINFOIP" | tail -1
Thanks for reply. I think I can't read my Pi's IPv4 without being connected to the same network :/
It'd be stupid sending the IP address to the page whose IP address is unknown.
I think I'll just change my internet provider to another with "static public IP" (i don't know how to name it correctly).

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Internet IP Address

Fri Jul 03, 2015 5:19 pm

The situation of an ISP not giving a fixed public IP address is exactly what "dynamic DNS" providers cater for. Some are free to use and even for those that charge it may be cheaper than the additional charge from an ISP for a fixed address.

Many routers incorporate the necessary client to communicate with a small selection of dynamic DNS services. Or you can run one on a machine on your LAN.

Return to “Beginners”