ESXi ホスト上の VMkernel ポートの固定ルートを構成する
search cancel

ESXi ホスト上の VMkernel ポートの固定ルートを構成する

book

Article ID: 320652

calendar_today

Updated On: 02-24-2025

Products

VMware vSphere ESXi

Issue/Introduction

  • This article provides information about the command to configure routes to additional gateways for VMkernel ports on an ESXi host.

Symptoms:

Environment

  • VMware vSphere ESXi 6.7
  • VMware vSphere ESXi 6.5
  • VMware vSphere ESXi 6.0
  • VMware vSphere ESXi 7.0

Resolution

  • Unlike ESX, ESXi does not have a service console. The management network runs on a VMkernel port and therefore uses the default VMkernel gateway.
  • An ESXi/ESX host can have only one VMkernel default gateway configured. 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 these steps - 
    • Open a console to the ESXi or ESX host. For more information, see Using ESXi Shell in ESXi
    • In ESXi 4.x and 5.0, run this command -
      • esxcfg-route -a target_network_IP netmask default_gateway
    • For example, to add a route to the 192.168.#.# target network IP with a /24-bit subnet mask (255.255.255.0) through a router with an IP address of 192.168.#.#, run one of the following commands -
      • esxcfg-route -a 192.168.#.#/24 192.168.#.#
        • OR
      • esxcfg-route -a 192.168.#.# 255.255.255.0 192.168.#.#
  • Note - In ESXi 5.0, static routes are different across reboots. To ensure that the static route you add persists, add the command to the /etc/rc.local file. 
  • For more information, see Modifying the rc.local or local.sh file in VMware vSphere ESXi to execute commands while booting
  • In ESXi 5.1 and 5.5, run this command -
    • esxcli network ip route ipv4/ipv6 add --gateway IPv4_address_of_router --network IPv4_address
  • For example, to add a route to the 192.168.#.# network with a /24-bit subnet mask (255.255.255.0) through a router with IP address 192.168.#.#, run this command - 
    • esxcli network ip route ipv4 add --gateway 192.168.#.# --network 192.168.#.#/24
  • Once finished, check the ESXi host current routing table by running the command esxcfg-route -l. All static routes will be displayed in the output.

Note -

  • The Host Profiles feature in the vCenter Server does not save or apply static routes on ESXi 5.0 and 4.x hosts.
  • In ESXi 5.1 and ESXi 5.5, Host Profiles are used to save or apply all manually configured static routes.
  • For this feature to work properly, you must add static routes by following the process described in steps 1-3.
  • This creates a host profile from the host. This profile can then be applied to other hosts and they will contain the static routes.

Additional Information

  • To successfully add a static route, the host must have direct subnet access to the specified router through one of its VMkernel ports.
  • If it does not have this access, it will not be able to communicate with the gateway router and will report the following error -
    • Unable to route to gateway address 192.168.#.# No route exists to that subnet.
  • For example, if you want to route to the 192.168.#.#/24 network through a gateway router 192.168.#.#, then the host must have a VMkernel port configured in the 192.168.#.#/24 network, or it will not be able to communicate with 192.168.#.# to forward traffic related to this static route.
  • The host's routing table must have an entry for this network as a Local Subnet Access network. You can verify this by running the esxcfg-route -l command.
  • You cannot have two default gateways, so you cannot add a new gateway for an existing subnet in the VMkernel.
  • In the previous example, if you try to add a new gateway for the 192.168.#.#/24 network, you get an error similar to the following - 
    • Found duplicate route to network 192.168.#.#/#24. Please remove the old route first.

Note: