Unlike ESX, ESXi does not have a service console. The management network is on a vmkernel port and therefore, uses the default vmkernel gateway. Only one vmkernel default gateway can be configured on an ESXi/ESX host. However, you can add static routes to additional gateways/routers from the command line.
To configure a static route to a second gateway/router for the management network, follow the below steps:
- Open a console to the ESXi or ESX host. For more information, see Using ESXi Shell in ESXi
- In ESXi 7.0, and ESXi 8.0:
- To add a static route, run the command:
esxcli network ip route ipv4/ipv6 add --gateway IPv4_address_of_source_router --network IPv4_address_destination_network
For example, to add a route to ##.##.##.## network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of xx.xx.xx.xx, run this command:
esxcli network ip route ipv4 add --gateway xx.xx.xx.xx --network ##.##.##.##/24
- To list the route, run the command:
esxcli network ip route ipv4 list
- To remove a static route, run the command:
esxcli network ip route ipv4 remove -n network_ip/mask -g gateway_ip
For example, to remove a route from ##.##.##.## network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of xx.xx.xx.xx, run this command:
esxcli network ip route ipv4 remove -n ##.##.##.##/24 -g xx.xx.xx.xx
- When finished, check the host's current routing table with the esxcfg-route -l command. Any static routes display in the output.
Note : # and xx Represents the ip4 address.