In our lab, we have a Linux server that we can log onto locally or ssh into with a specific IP. When I am logged into the machine, I can see its internal IP with ifconfig
or ip a
and I can see its external IP through something like curl icanhazip.com
. However, the external IP reported by that last command, is different from the one I type in when using ssh to connect to the machine, I believe the reported IP is the IP of our router.
When I am logged into the machine locally, is it possible for me to find out which IP addresses can be used to ssh into the system (not the IP addresses of the users that are logged in, but rather what IP addresses I can use with the ssh ###.###.###.###
command). I would like to find this out without logging into the router admin panel to see what IP addresses and ports are being forwarded. Would the ssh IP addresses be stored in a file (I could not find anything in /etc/sshd_config
), or is there a command that I can run to display it, like with the internal IP?
Best Answer
Many utilities will show the user's IP address, including
who
andw
andlast -ai
.Of course, if there is any form of redirection taking place, you may be looking at the machine that did the redirection.