Linux获取外网ip


Linux获取外网ip
 
方法一:curl -s "http://checkip.dyndns.org/"|cut -f 6 -d" "|cut -f 1 -d"<"    www.2cto.com       
方法二:w3m -dump http://submit.apnic.net/templates/yourip.html | grep -P -o '(\d+\.){3}\d+' 
方法三:curl ifconfig.me          
 
方法四:curl icanhazip.com 
方法五:curl -s www.123cha.com | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n 1
 
把它们添加到 .bashrc (Bash 专用) 或者 .profile (非 Bash 专用)里面去
 
alias myip='curl ifconfig.me'
 
source .bashrc 或者 . .profile 即可生效
 
输入 myip 就能拿到 WAN IP。
 

相关内容

    暂无相关文章