How can I get the address of my local machine?

116,523

Solution 1

I just got the shortest way around this

$ who

root     pts/22       2016-12-28 13:22 (179.xx.xxx.xx)

If connected via ssh. This will display the user logged in plus the IP address

Solution 2

Just adding to the answer, an easy way to tell your address (ip/domain), is to ssh into a computer you can ssh into, exit and then ssh back into it again. Most times, you'll see a welcome message like:

"Last login at xx:xxpm from you.domain.com/ip.ad.dre.ss"

Solution 3

Try ifconfig. It should tell you your local IP address (on your network) for the various interfaces like WiFi and Ethernet.

Solution 4

An easiest way to get IP address via SSH:

Command: ifconfig

Example:

stalinrajindian@ubuntuserver:~$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.30.3.27  netmask 255.255.255.0  broadcast 172.30.3.255
        inet6 fe80::a00:27ff:fe8b:9986  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:8b:99:86  txqueuelen 1000  (Ethernet)
        RX packets 4876  bytes 1951791 (1.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 775  bytes 73783 (73.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 78  bytes 5618 (5.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 78  bytes 5618 (5.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Share:
116,523

Related videos on Youtube

Marty
Author by

Marty

I'm an iOS developer on the eBay app.

Updated on September 18, 2022

Comments

  • Marty
    Marty over 1 year

    I'm on a macbook running Lion. In Terminal I'm connected to my schools server with ssh. I navigated to a folder on the server and have a file I want to copy to my local machine, but I don't know what the IP address of my local machine is. How can I get it? I'm in the folder on the server, and I want to copy read.txt onto my local machine's hard drive. I've tried scp ./read.txt [my computer name].local/newRead.txt but it doesn't work.

  • Admin
    Admin over 9 years
    What if the command returns "ifconfig: interface eth0 does not exist"?
  • Admin
    Admin over 7 years
    @kolistriva Try "en0".
  • dave_thompson_085
    dave_thompson_085 over 7 years
    Or echo $SSH_CLIENT silghtly longer to type but almost no clutter to read.
  • joelostblom
    joelostblom over 7 years
    No need to log in and out, just type last -ai.