LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 12-08-2017, 03:36 AM   #1
WhatTheL
LQ Newbie
 
Registered: Nov 2016
Posts: 5

Rep: Reputation: Disabled
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.
 
Old 12-08-2017, 04:22 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,483

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
Code:
ip addr
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Network interface binding wrong ip address techfour Linux - Networking 4 11-06-2013 01:09 PM
[SOLVED] I'm trying to remember the ip command to assign an interface to an IP address... BMan8577 Linux - Newbie 3 12-18-2011 09:45 PM
How to change eth1 address from /etc/network/interface? venom4u31 Linux - Newbie 7 11-28-2011 09:02 AM
OpenBSD: ping command - bad interface address igadoter *BSD 2 05-02-2011 03:30 PM
Network Interface IRQ address fullgore Slackware 3 04-04-2008 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration