test me

Site Search:

How to find your router's public ip with command line

Back>

Since any of your http requests are wrapped inside IP packets, and there is an source ip address in IP packet, potentially any server can let you know your router's public ip address. Some website just do that, for example https://ipinfo.io/: you can use command line curl to get the the http response, then grep the ip field you like, no matter it is ipv4 or ipv6 address. The url ipinfo.io/ip, just reply with your ipv4 address, even grep is saved.



curl https://ipinfo.io/ip

So if you don't want to buy a static ip, the ISP's dynamic ip is ok for connection from internet, you just need a crontab to send the ip to your mailbox or some internet storage such as a webservice (google UDDI or filetype:wsdl) -- somewhere your cellphone's browser can check when you are travel outside the town.

curl https://ipinfo.io/ip | mail -s ipchange <yourmailaddress>

or

curl https://ipinfo.io/ip | curl -X POST -d @- http://<yourposturl>


In case you can not find a free webservice, you can build one for free with google cloud platform.
All you need is a credit card. You can then register a free google cloud platform account, then follow their wizard to create a bookstore site (and many others) with whole bunch of copy paste in their online google cloud shell. Google put $300 in the free account, so that you can try their product and fall in love with it, nice. The free trial is one year, during that trail period, you can try paid services such as AI products with that $300, if the free tier didn't match your needs. After one year, the free tier resources are still free. Other competitors are amazon cloud and microsoft azure.

web service interactive build with GCP
web service interactive build with GCP


No comments:

Post a Comment