Wednesday, May 8, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 365  / 2 Years ago, sun, january 23, 2022, 4:33:34

Why each time I change of location the ip address is modified. In fact, today, I was in three different places during day, and each time I've execute the hostname -I command the ip address was different.


More From » command-line

 Answers
3

hostname -I lists all assigned IP addresses on your host presently. I have VMPlayer installed on my system, so I get three IP addresses listed.



terrance@terrance-ubuntu:~$ hostname -I
10.0.0.100 172.16.163.1 192.168.43.1


The first group of numbers 10.0.0.100 is my local IP address of my system given to me by my DHCP server / router. The next two sets of numbers are assigned by the VMPlayer and are not controllable by the network manager of this host.



With DHCP servers, as long as your computer's local IP settings are set for dynamic no matter where you go and connect your IP address will change. Most of this will be based on the DHCP Leases of each server. If you connect to the same server within the Lease time of the IP address, you should obtain the exact same IP address again since the server assigns the IP addresses to the MAC address that is connected. Once a Lease expires the DHCP server should reclaim that IP address and assign it to another system when it connects.



To get a little more in depth look at my present network, I use netstat.



terrance@terrance-ubuntu:~$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.16.163.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.43.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8


With netstat, the -r means to show me the routes, and the -n means to show me numeric instead of the hostnames. In my example above, you can see that my network gateway is 10.0.0.1 which should be my router.


[#12826] Monday, January 24, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
smelrop

Total Points: 263
Total Questions: 122
Total Answers: 108

Location: Saudi Arabia
Member since Thu, Jan 28, 2021
3 Years ago
;