Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Get the IP address associated with a network interface

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
tirengarfio
Posts: 6
Joined: 2008-11-02 16:00

Get the IP address associated with a network interface

#1 Post by tirengarfio »

Hi,

how can i get the IP address associated with a network interface using the terminal?

Javi

User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: Get the IP address associated with a network interface

#2 Post by debil »

With ifconfig. For example eth0:

Code: Select all

$ /sbin/ifconfig eth0
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.

deranjer
Posts: 5
Joined: 2009-09-23 16:44

Re: Get the IP address associated with a network interface

#3 Post by deranjer »

Code: Select all

/sbin/ifconfig -a
or

Code: Select all

sudo ifconfig -a
If you don't know the name of the interface these commands should list all of the networking interfaces on your machine (and list all of the information).

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Get the IP address associated with a network interface

#4 Post by dbbolton »

debil wrote:With ifconfig. For example eth0:

Code: Select all

$ /sbin/ifconfig eth0
Or, if you don't feel like reading all that junk:

Code: Select all

/sbin/ifconfig wlan0 | grep addr: | awk '{print $2}'
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: Get the IP address associated with a network interface

#5 Post by debil »

deranjer wrote:

Code: Select all

sudo ifconfig -a
Since sudo is not misused by default in Debian, better to do

Code: Select all

$ su -c "ifconfig -a"
and avoid further confusion.
dbbolton wrote:Or, if you don't feel like reading all that junk:

Code: Select all

/sbin/ifconfig wlan0 | grep addr: | awk '{print $2}'
Or if you want to get rid of all that "addr:" junk:

Code: Select all

$ /sbin/ifconfig eth0 | grep addr: | cut -d: -f2 | cut -d" " -f1
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Get the IP address associated with a network interface

#6 Post by nadir »

dbbolton:

Code: Select all

/sbin/ifconfig wlan0 | grep addr: | awk '{print $2}'
debil:

Code: Select all

    $ /sbin/ifconfig eth0 | grep addr: | cut -d: -f2 | cut -d" " -f1
i like both. finally a reason to make use of an alias (and... done). thanks
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

Post Reply