Linux Network Interface

Sometimes I need to know IP of specified network interface, for example eth0.

There are several ways to do it:

  • ifconfig command, but you need to yum install net-tools.x86_64 if it does not present:
1
ifconfig eth0 | grep "inet" | awk '{print $2}'
  1. ip command, this command is pre-installed in most Linux distros.
1
ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1
0%