-3

I'm running Kali Linux in VMware, and its IP address is 127.0.0.1 and my PC IP address is 192.168.1.5, and I can still ping my Kali Linux with my PC, shouldn't both of their IPs start with 192.168... in order to communicate with each other?

bzmind
  • 161
  • 1
  • 5
  • 1
    Does this answer your question? [What do different types of LAN IP addresses mean?](https://superuser.com/questions/1028699/what-do-different-types-of-lan-ip-addresses-mean) – esqew Nov 23 '21 at 12:56
  • 2
    In case it's not clear (because so far no answer states this *explicitly*): by pinging `127.0.0.1` from anything but your Kali you are *not* pinging your Kali. – Kamil Maciorowski Nov 23 '21 at 13:07
  • @KamilMaciorowski When I type `ifconfig` in Kali, it only shows 127.0.0.1 as the IP, so it's not its actual IP in this LAN? I remember I had used kali in VMware a long time ago, and both my PC and my Kali IP addresses were starting with 192.168..., but now it's like this, how can I get Kali's private IP address then? – bzmind Nov 23 '21 at 13:10
  • @KamilMaciorowski So if I ping 127.0.0.1 on my PC, then what am I pinging exactly? it's the PC itself? so I'm pinging myself? – bzmind Nov 23 '21 at 13:11
  • "I'm pinging myself?" -- Yes. The answers are clear on this. – Kamil Maciorowski Nov 23 '21 at 13:12
  • Did you set your machine up as host only? I am in Kali now and ifcofig shows the correct (192.x.x.x.) NAT Address. – John Nov 23 '21 at 13:13
  • @John I don't know, I tried changing my network connection in vmware to Bridged as well, but the ip didn't change – bzmind Nov 23 '21 at 13:14
  • @John `lo: flags=73 mtu 65536` `inet 127.0.0.1 netmask 255.0.0.0` this is what it outputs, is it the correct ip? there's no other IP addresses in the output – bzmind Nov 23 '21 at 13:17
  • `127.0.0.1` is the correct address for the `lo` (loopback) interface. To communicate with the outside world you need another network interface. If there is no other interface then it means the hypervisor does not emulate an interface for the VM, or the OS in the VM (Kali in your case) cannot "talk" to this "hardware" for some reason. But to tell if there is another interface, you need `ifconfig -a`, not only `ifconfig`. – Kamil Maciorowski Nov 23 '21 at 13:24
  • here's no other IP addresses in the output ... Something is strange in the machine setup. I have a couple of Kali machines and they hall have proper addressing. – John Nov 23 '21 at 13:27
  • @KamilMaciorowski Sorry I'm totally a noob in networking and Linux in general, I typed `ifconfig -a` and this time it also shows eth0, but it doesn't have any IP I guess, here's the output: `eth0: flags=4098 mtu 1500` `ether 00:0c:29:1c:ab:a2 txqueuelen 1000 (Ethernet)` – bzmind Nov 23 '21 at 13:27
  • 3
    Comments are not for this. Let the current question be about `127.0.0.1`, solved. Ask a new question about your current problem if you want. About "I'm totally a noob in networking and Linux in general": please read [this question](https://unix.meta.stackexchange.com/q/5360/108618). It may save you nerves. – Kamil Maciorowski Nov 23 '21 at 13:33

3 Answers3

2

127.0.0.1 is the loopback address on lo or similar and should exist on all systems.

You can infact ping any address in 127.0.0.0/8 with the exception of 127.0.0.0 & 127.255.255.255.

Bib
  • 1,175
  • 1
  • 6
  • 8
  • The person who asked might want to have a look at [localhost](https://en.wikipedia.org/wiki/Localhost) and [private network](https://en.wikipedia.org/wiki/Private_network) at the very least. – Seth Nov 23 '21 at 12:55
2

127.0.0.1 is standard shorthand for "me".

It's known as the loopback address, or localhost. Every computer's 'self' can be reached at 127.0.0.1.

From Wikipedia - localhost

In computer networking, localhost is a hostname that refers to the current device used to access it. It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware.

Tetsujin
  • 47,296
  • 8
  • 108
  • 135
1
  1. 127.0.0.1 is a loopback address, assigned to special loopback interface named lo and associated with the name localhost. This is the way to express literal "Here" for a computer. Continuing the analogy, the localhost name corresponds to "Myself", FQDN corresponds to to a full name, the hostname corresponds to a first name, and the "non-loopback" IP addresses correspond to the current position of the person inside the room, while network addresses are like room numbers.

  2. No, IP addresses don't have to be in the same network to be able to communicate. For instance, your PC is not in the same network as SuperUser server, but those are communicating somehow. In Linux, you can in principle bind a socket to any address assigned to the computer (all of them are called local addresses and you can observe them in the local routing table with ip route show table local) and communicate with any entity which has that address routed towards your computer. In particular, any two addresses present in the local table can communicate with each other, because the local table is the source of information "what's me" for a computer.

Nikita Kipriyanov
  • 2,564
  • 11
  • 28