LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem to get IP (https://www.linuxquestions.org/questions/linux-software-2/problem-to-get-ip-4175542427/)

Huamin 05-12-2015 10:41 PM

Problem to get IP
 
Hi,
How to resolve this problem?

[root@CentOS65x64 ~]# ifconfig eth0 | grep inet | awk '{ print $2 }'
eth0: error fetching interface information: Device not found

mralk3 05-12-2015 11:18 PM

The error is self explanatory. eth0 does not exist. Run ifconfig without any argument or pipes. You will then see what network interfaces exist.

Edit-

Try running the following instead:

[~]$ sudo ifconfig | grep inet | awk '{ print $2 }' | sed '/127.0.0.1/d' | sed 's/addr://g'

192.168.1.136

veerain 05-12-2015 11:57 PM

You may use dhcp client to automatically set up net if a router is connected to your box.

Huamin 05-13-2015 09:32 AM

Thanks all.

Mralk,
Are you putting one IP to the OS?

mralk3 05-13-2015 11:47 AM

Quote:

Originally Posted by Huamin (Post 5361881)
Thanks all.

Mralk,
Are you putting one IP to the OS?

Yes, I have only one ip address on my system. It is a laptop on wifi.


All times are GMT -5. The time now is 09:05 AM.