Thursday, January 6, 2011

How to get my local IP address?

Using ipconfig, grep, and awk commands.

hsual@psgltpe014 $ ipconfig | awk '{ print NF, $0 }'
1 
4 Windows 2000 IP Configuration
1 
3 Ethernet adapter CPQTUN:
1 
6       Connection-specific DNS Suffix  . : 
15      IP Address. . . . . . . . . . . . : 0.0.0.0
15      Subnet Mask . . . . . . . . . . . : 0.0.0.0
13      Default Gateway . . . . . . . . . : 
1 
5 Ethernet adapter Local Area Connection:
1 
6       Connection-specific DNS Suffix  . : aaa.bbb.ccc.corp
15      IP Address. . . . . . . . . . . . : 10.22.10.2
15      Subnet Mask . . . . . . . . . . . : 255.255.255.0
13      Default Gateway . . . . . . . . . : 10.22.10.1


hsual@psgltpe014 $ ipconfig | grep IP.Address | grep -v 0.0.0.0 | awk '{ print $15 }'
10.22.10.2
hsual@psgltpe014 $ 

No comments: