Why server has two ip's

I am practicing in Ansible lab , why i am getting two ip’s when i use command hostname -i in every server (Ansible controller, server1, server2 )

  1. Ansible controller
[root@ansible-controller ~]# hostname -i
172.20.1.2 172.17.0.4
[root@ansible-controller ~]# date
Sun Mar 26 19:10:56 UTC 2023
  1. server1 (web1)
[root@web1 ~]# hostname -i
172.20.1.100 172.17.0.6
[root@web1 ~]# date
Sun Mar 26 19:11:34 UTC 2023
  1. server2 (web2)
[root@web2 ~]# hostname -i
172.20.1.101 172.17.0.5
[root@web2 ~]# date
Sun Mar 26 19:12:02 UTC 2023

Anyone please can explain this.

Hi @ahens000 ,

It’s because you have two interfaces attached to the machine and each refers to the same machine.

When you did cat /etc/hosts you can see there that each of these IPs is assigned to the same hostname
And you can verify the interface with the command : ip a

NB: The same machine can have multiple interface

Regard

1 Like