Retrieve IP address in HP-UX?

2.1k Views Asked by At

I am using below to retrieve ip address for my Linux (Centos) host and print to a file:-

ip route get 8.8.8.8 | awk 'NR==1 {print $NF}'

Can anyone confirm how can I do the same in HP-UX?

uname -a on by box shows this:- HP-UX tsth6038 B.11.23 U ia64 1187320084 unlimited-user license

2

There are 2 best solutions below

0
On

Try this:

netstat -in | awk '{ print $3 }' | grep -v Network

Have in mind you can have several ip addresses

If you want to get rid of local loop:

netstat -in | grep -v lo0 | awk '{ print $3 }' | grep -v Network
0
On

This will give correct IP Address of server netstat -in | grep -v lo0 | awk '{ print $4 }' | grep -v Address