简体   繁体   English

如何获得正确的IP地址

[英]How to get the right IP Address

I need to write a shell script for the purpose of unblocking the current ip from a server.我需要编写一个 shell 脚本,以便从服务器上解除对当前 ip 的阻止。 The script must run on mac os.该脚本必须在 mac os 上运行。

The script is finished i just need to get the right ip adress, the one i connect to the internet with.脚本已完成,我只需要获得正确的 IP 地址,即我连接到互联网的 IP 地址。 If a hit 'ipconfig getifaddr en0' in the console i get the following adress: 127.168.X.XXX.如果在控制台中点击“ipconfig getifaddr en0”,我会得到以下地址:127.168.X.XXX。 But when I use a service like 'whatismyip.com' im getting 87.188.XXX.XXX.但是当我使用像“whatismyip.com”这样的服务时,我得到的是 87.188.XXX.XXX。 This is the one I need to get in the console.这是我需要进入控制台的那个。

Any ideas on which command i could use to get the right ip?关于我可以使用哪个命令来获得正确的 ip 的任何想法?

Thanks on advance.提前致谢。

You are tying to find out your external ip address.您正在尝试找出您的外部 IP 地址。 If you have curl installed on your system, the quickest way is to use:如果您的系统上安装了curl ,最快的方法是使用:

curl ifconfig.co

That will return the ip you are looking for.这将返回您正在寻找的IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM