Filtrar IP de Host Linux

Filtrar todos IPs do Host comando ip

ip addr | awk '/inet /{print $2}'

Filtrar segundo IP do comando ip

ip addr | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | sed -n 2p

Pegar IP de gateway com comando ip

ip route | awk '/default/{print $3}'

Filtrar terceiro IP do comando ifconfig

ifconfig | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | sed -n 3p

Pegar IP de gateway com comando route

route -n | awk '/^0.0.0.0/ {print $2}'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s