# Solved: Find connecting IP address in Linux



## AGCurry (Jun 15, 2005)

I know that Linux knows and keeps track of the IP address from which I've logged in, because it tells me when I log in what address I came in from LAST.

But - is there a command which simply provides my current IP address?

Thanks in advance.


----------



## Squashman (Apr 4, 2003)

ifconfig


----------



## AGCurry (Jun 15, 2005)

Thanks, Squashman, but ifconfig only gives me the address of the ethernet adaptor and the loopback address - and the man page for ifconfig does not seem to provide for any option to get the address of THE DEVICE FROM WHICH I AM CONNECTING.


----------



## Squashman (Apr 4, 2003)

I am not sure which device you want. If you are behind a router, look at your router config to get your Internet IP address. Or just go to http://www.whatismyip.com


----------



## AGCurry (Jun 15, 2005)

Okay. The Linux box's network card is 172.xx.xx.xx. ifconfig gives me that address just fine.

But I'm connecting from a PC, address 10.0.xx.xx. THAT's the address I want to be able to access in a shell script. When I log on to the Linux box, there's a last-login message like "last login Tue Dec 8 blah blah from 10.0.xx.xx", so I know the information exists SOMEWHERE on the Linux server. There oughta be a command which yields it - or a file to look in, at least - but I don't know what it is.


----------



## Squashman (Apr 4, 2003)

last or lastlog


----------



## Squashman (Apr 4, 2003)

Or just type who


----------



## AGCurry (Jun 15, 2005)

Squashman said:


> Or just type who


Thanks! I will extract the ip address by looking for $(tty) in the list who brings back.


----------

