Sometimes it is useful to statically assign different gateway addresses for different network segments when configuring multiple Service Console network interfaces on VMware vCenter appliance.
A. To apply a static route on an ESXi host, effective immediately, but not persistent across a reboot:
Connect to host with a ssh client (I prefer putty) and execute the following command:
# route add -net <TargetNetwork> netmask <NetmaskAddress> gw <GatewayAddress> dev <interface>
e.g. route add -net 10.1.2.0 netmask 255.255.255.0 gw 10.1.1.1 dev eth0
to verify that the route was added successfully. In our example, the entry 10.1.2.0 10.1.1.1 255.255.255.0 UG 0 0 0 eth0 should appear.
B. To apply a persistent static route on the appliance:
Connect to host with a ssh client and open the static-routes file with a text editor:
# vi /etc/sysconfig/network/ifroute-eth0
(supposing the interface is eth0)
For every route add a line with the following format:
<TargetNetwork> <GatewayAddress> <Netmask> <Interface>
Then run the following command:
# service network restart
and finally verify the route with: