Locations of visitors to this page

Thursday, August 27, 2009

how to find ip address of network interface

how to find ip address assigned to network interface
如何取得网卡分配的IP地址

运行脚本:
/sbin/ifconfig -a|awk '
{
  if ( $0 ~ /^[^ ]/ ) {
    ifname=$1
    do {
      getline
      if ( $0 ~ /inet addr/ ) {
        ifaddr=substr($2, index($2, ":")+1)
      }
    } while ( $0 ~ /^[ ]/ )
    print ifname, ifaddr
    ifname=""
    ifaddr=""
  }
}
'
bond0 192.168.11.18
eth0
eth1
lo 127.0.0.1
sit0
tun0 172.16.220.94
列出系统中所有网卡对应的IPv4地址


-fin-

No comments:

Website Analytics

Followers