UNIX/Linux get IP Address

1 min read Sep 15, 2013

UNIX/Linux get IP Address

use this:

curl icanhazip.com

or this:

function myip(){
	myip="$(ifconfig | grep 'inet.*netmask.*broadcast')"
	lanip="$(echo $myip | awk '{print $2}')"
	publicip="$(echo $myip | awk '{print $6}')"
	echo '你的局域网IP是: '$lanip
	echo '你的外网IP是: '$publicip
	echo '复制到剪贴板' $lanip | pbcopy
}
Picsew | Ezra
« Newer: Linux 配置 IP  Older: UNIX/Linux Command: chmod »