Manage ESXi Routing Via Command Line Interface

There are certain key combinations and commands I find more difficult to remember than others. I wrote about Send F Key to VMware Fusion via MacBook Keyboard and the next in line is routing for ESXi. This is not something i do very often but It happens from time to time. I will not go into the details (requirements) behind the configuration needed in this case but let’s just say it was not something I see a lot.

So In this case I had two vmkernel adapters, vmk0 (used for normal management and vMotion) and vmk1 (used for backup purposes) and their information including name, MAC address, MTU, switch & port group placement among other things) can be listed using the following command:

esxcli network ip interface list

The vmkernel adapter IP configuration can be listed using:

esxcli network ip interface ipv4 get

This is the output from the above command:

Let’s move on to topic of this blog post, the ESXi routing configuration via cli. And yes, there is an option to mange this via the a UI e.g vSphere Web Client as well.

List current routing configuration using the following command:

esxcli network ip route ipv4 list

In my case I received the following:

All traffic not target for the network will go via vmk0 meaning the interface to the default gateway. Based on network requirements the customer wanted network to be accesses via the

The command syntax for adding and removing an additional route is:

esxcli network ip route ipv4 add/remove

So to achieve the requirements I ran the following command:

esxcli network ip route ipv4 add -n -g

Verified the configuration using the list option and it looks ok:

The following command will remove my newly added configuration:

esxcli network ip route ipv4 remove -n -g

These commands were tested on ESXi 6.0.0 build-3568940

3 pings

Comments have been disabled.