How to change the IP Address of ESXi through command line

In this tutorial, we will explore how we can change the IP Address of ESXi through command line or ssh prompt.

Lets change the IP Address of ESXi through command line or ssh shell

Login to your esxi server using ssh client

[ved@arch ~]$ ssh [email protected]
The authenticity of host '192.168.0.150 (192.168.0.150)' can't be established.
RSA key fingerprint is SHA256:AJW5VPJLbd4IMj0pAzF6KdgiUJIrdbQ2T5W6aF4L8rQ.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.0.150' (RSA) to the list of known hosts.
([email protected]) Password: 
The time and date of this login have been sent to the system logs.

WARNING:
   All commands run on the ESXi shell are logged and may be included in
   support bundles. Do not provide passwords directly on the command line.
   Most tools can prompt for secrets or accept them from standard input.

VMware offers supported, powerful system administration tools.  Please
see www.vmware.com/go/sysadmintools for details.

The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
[root@esx1:~] 

We will now check and list all the vmkernel interfaces available in the esxi server using below command

[root@esx1:~] esxcli network ip interface ipv4 get
Name  IPv4 Address   IPv4 Netmask   IPv4 Broadcast  Address Type  Gateway      DHCP DNS
----  -------------  -------------  --------------  ------------  -----------  --------
vmk0  192.168.0.150  255.255.255.0  192.168.0.255   STATIC        192.168.0.1     false
vmk1  192.168.0.202  255.255.255.0  192.168.0.255   DHCP          192.168.0.1     false

From above output, vmk0 is my management interface. You can identify your management interface accordingly and use the same in the next command to change esxi ip address.

[root@esx1:~] esxcli network ip interface ipv4 set -i vmk1 -I 192.168.0.20 -N 25
5.255.255.0 -g 192.168.0.1 -t static

Your current ssh session may get terminated after executing this command as ESXi management IP has been changed. Login back with the new IP address and verify the same.

[root@esx1:~] esxcli network ip interface ipv4 get
Name  IPv4 Address   IPv4 Netmask   IPv4 Broadcast  Address Type  Gateway      DHCP DNS
----  -------------  -------------  --------------  ------------  -----------  --------
vmk0  192.168.0.20   255.255.255.0  192.168.0.255   STATIC        192.168.0.1     false
vmk1  192.168.0.202  255.255.255.0  192.168.0.255   STATIC        192.168.0.1     false

Conclusion

Thus we have successfully change the IP Address of ESXi through command line or change esxi ip address from ssh shell.

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
vikas
vikas
1 year ago

was helpful.