LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   Command to print network interface and its IP address (https://www.linuxquestions.org/questions/red-hat-31/command-to-print-network-interface-and-its-ip-address-4175619182/)

WhatTheL 12-08-2017 03:36 AM

Command to print network interface and its IP address
 
Hi All,

I would like to run a script to get all network interfaces and their IP addresses of a standalone PC, such that the command line can print it out.

This device is installed with RedHat Enterprise Linux 7.0.
I have tried the following command but it only showed me one interface and the loopback address.

The command was:
----quote------

hostname --ip-address

----unquote----


There are 2 network interfaces in this PC. but I could only view the interface for the loopback,not the other interface.
How can I get an output in the following manner?

<interface1> <non loopback ip address1>
<interface2> <ip address 2>

Thanks in advance.

TenTenths 12-08-2017 04:22 AM

Code:

ip addr


All times are GMT -5. The time now is 01:39 AM.