If you move your ESXi host to a new physical location, you might have to change the default IP gateway.
You can use the vicfg-route command to manage the default gateway for the VMkernel IP stack. vicfg-route supports a subset of the Linux route command’s options.
Important: No ESXCLI command exists to manage the default gateway.
If you run vicfg-route with no options, the command displays the default gateway. Use --family to print the default IPv4 or the default IPv6 gateway. By default, the command displays the default IPv4 gateway. Specify one of the options listed in Connection Options for vCLI Host Management Commands in place of <conn_options>
.
Procedure
- Add a route entry to the VMkernel and make it the default.
- For IPv4 networks, no additional options are required.
vicfg-route <conn_options> --add <network_ip> <netmask_IP> <gateway_ip>
For example, to add a route to 192.XXX.100.0 through 192.XXX.0.1 by using the following syntax. vicfg-route <conn_options> -a 192.XXX.100.0/24 192.XXX.0.1
You can also use the following syntax. vicfg-route <conn_options> -a 192.XXX.100.0 255.255.255.0 192.XXX.0.1
- For IPv6 networks, use
--family v6
. vicfg-route <conn_options> -f V6 --add <network_ip_and_mask> <gateway_ip>
The following command uses example values. vicfg-route <conn_options> -f V6 --add 2001:10:20:253::/64 2001:10:20:253::1
- List route entries to check that your route was added by running the command without options.
vicfg-route <conn_options>
The output lists all networks and corresponding netmasks and gateways.
- Set the default gateway.
- For IPv4, use the following syntax.
vicfg-route <conn_options> 192.XXX.0.1
You can also use the following syntax. vicfg-route <conn_options> -a default 192.XXX.0.1
- For IPv6, use the following syntax.
vicfg-route <conn_options> -f V6 -a default 2001:10:20:253::1
- Run
vicfg-route --delete
to delete the route. Specify first the gateway, and then the network.
vicfg-route <conn_options> -d 192.XXX.100.0/24 192.XXX.0.1