Search the VMware Knowledge Base (KB)
View by Article ID

Configuring static routes for vmkernel ports on an ESXi host (2001426)

  • 28 Ratings

Purpose

This article provides steps to configure routes to additional gateways for vmkernel ports on an ESXi host.

Resolution

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: 
  1. Open a console to the ESXi or ESX host. For more information, see Using Tech Support Mode in ESXi 4.1 and ESXi 5.x (1017910) or Tech Support Mode for Emergency Support (1003677).
  2. In ESXi 4.x and 5.0:

    1. To add a static route, run the command:

      esxcfg-route -a target_network_IP netmask default_gateway

      For example, to add a route to the 192.168.100.0 network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of 192.168.0.1, run one of these commands:

      • esxcfg-route -a 192.168.100.0/24 192.168.0.1

        Or

      • esxcfg-route -a 192.168.100.0 255.255.255.0 192.168.0.1

    2. To delete a static route, run the command:

      esxcfg-route -d target_network_IP netmask default_gateway

      For example, to delete a route from the 192.168.100.0 network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of 192.168.0.1, run one of these commands:

  3. In ESXi 5.1, and ESXi 5.5, and ESXi 6.0:

    1. To add a static route, run the command:

      esxcli network ip route ipv4/ipv6 add --gateway IPv4_address_of_router --network IPv4_address

      For example, to add a route to 192.168.100.0 network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of 192.168.0.1, run this command:

      esxcli network ip route ipv4 add --gateway 192.168.0.1 --network 192.168.100.0/24

    2. To list the route, run the command:

      esxcli network ip route ipv4 list
    3. 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 192.168.100.0 network with a /24 bit subnet mask (255.255.255.0) through a router with an IP address of 192.168.0.1, run this command:

      esxcli network ip route ipv4 remove -n 192.168.100.0/24 -g 192.168.0.1
  4. When finished, check the host's current routing table with the esxcfg-route -l command. Any static routes display in the output.

Note: The Host Profile feature in vCenter Server does not save or apply static routes with ESXi 5.0 and 4.x hosts. In ESXi 5.1 and ESXi 5.5, any manually configured static routes are saved or applied using Host Profiles. In order for this functionality to work correctly, the static routes must be added by the process outlined in steps 1-3, then a host profile created from the host. This profile can then be applied to other hosts, which includes the static routes.

Additional Information

To successfully add a static route, the host must have direct subnet access to the router being specified through one of its vmkernel ports. If not, it cannot communicate with the gateway router and reports the error:

Unable to route to gateway address x.x.x.x no route to that subnet exists

For example, to route to the 192.168.100.0/24 network through the gateway router 192.168.0.1, the host must have a vmkernel port configured in the 192.168.0.0/24 network. Without this vmkernel port, it cannot communicate with 192.168.0.1 to forward traffic relating to this static route.

You must ensure that an entry exists for the network in the host's routing table as a Local Subnet Access network. To validate this, use the esxcfg-route -l command.

You cannot add a new gateway for an existing subnet in the vmkernel as you cannot have two default gateway. In the aforementioned example, if an attempt is made to add a new gateway for 192.168.100.0/24 network, an error similar to this occurs:

Duplicate route to network x.x.x.x/xx found.  Please delete the old route first.

Note: When configuring routes in auto-deploy, the preferred way to create custom network entries use the answer file from a reference host. For more information, see VMware AutoDeploy Documentation Center.

Tags

esx-management  service-console-gateway

See Also

Update History

01/02/2013 - Added the command for ESXi 5.0 01/09/2013 - Added ESXi 5.1 to Products and the corresponding command 03/26/2013 - Added Additional Information 05/30/2013 - Adjusted format of esxcfg-route -a command.

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 28 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)




Please enter the Captcha code before clicking Submit.
  • 28 Ratings
Actions
KB: