Knowledge Base

|
Configuring static routes for vmkernel ports on an ESXi host (2001426)
Purpose
Resolution
- 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).
- In ESXi 4.x and 5.0, 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
Note: In ESXi 5.0, static routes are not persistent across reboots. To ensure that any added static routes are persistent, add the command to the /etc/rc.local file. For more information, see Modifying the rc.local or sh.local file in ESX/ESXi to execute commands while booting (2043564).
In ESXi 5.1, 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
- esxcfg-route -a 192.168.100.0/24 192.168.0.1
- 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 will not save or apply static routes with ESXi 5.0 and 4.x hosts. In ESXi 5.1, any manually configured static routes will be 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 will include the static routes.
Additional Information
To successfully add a static route, the host must have direct subnet access to the router being specified via 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.
Also, 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.
Tags
See Also
- Tech Support Mode for Emergency Support
- Adding a static route to an ESX host for an extra Service Console interface
- Modifying the rc.local or local.sh file in ESX/ESXi to execute commands while booting
Update History
Request a Product Feature
- Updated:
- Categories:
- Languages:
- Product Family:
- Product(s):
- Product Version(s):

