VMware Arena

Virtual Network basics and Add Static route for ESX server

Understanding Virtual Network:-

With virtual network, you can network virtual machines in the same way that you do physical machines and can build complex networks within a single ESX Server host or across multiple ESX Server hosts, for production deployments or development and testing purposes. In other terms, Virtual network is a representation of your own network in the cloud.

Virtual switches (Standard switch & Distributed Switch) allow virtual machines on the same ESX Server host to communicate with each other using the same protocols that would be used over physical switches, without the need for additional networking hardware. ESX Server virtual switches also support VLANs that are compatible with standard VLAN implementations from other vendors. Virtual network allows the VM to communicate in between in a secure and robust way. It is very important to understand How Virtual machine traffic routes to understand the entire stack of Virtual network.

Virtual network

How to add static route to ESX Server

This step of adding static route does not applicable for the Virtual network i.e Virtual machine network. This static route addition is for the management network i.e Service Console network. Connect to the ESX server via SSH and add a route using the below command:
# route add -net netmask gw

Example 1:- I want to add a route for the destination network 192.168.0.0/23 through the gateway address 172.121.64.1

# route add -net 192.168.0.0 netmask 255.255.254.0 gw 172.121.64.1

Example 2: I want to add a route for the destination network 192.168.0.0/23 through the gateway address 172.121.64.1 and i want this route to be going via my vswif1 interface.

#  route add -net 192.168.0.0 netmask 255.255.254.0 gw 172.121.64.1 dev vswif1

Example 3: I want to add a route only for one destination ip address (NTP server) 192.168.0.54 through the gateway address 172.121.64.1 via vswif1 interface

#  route add -net 192.168.0.54 netmask 255.255.255.255 gw 172.121.64.1 dev vswif1

To verify the added route:

# route or route | grep 192.168.0.54

Now i added the route and all is well and everything is working as expected. Let’s take a scenario, My ESX server rebooted today morning and after that my ESX is not syncing with NTP server. it is because the added routes disappeared after my reboot not only reboot even if you restart the network service, added routes will disappear. You need to ensure that your routes are persistent over the reboot.

To apply a static routes during ESX server boot:-

1. Edit the file called static-routes in /etc/sysconfig using your favorite editor VI or Nano. If the file does not exist, creathe file with name “static-routes”

    nano /etc/sysconfig/static-routes

2. add the routes which u want to add using the below commands

# any net netmask gw

Example 1:- I want to add a route only for one destination ip address (NTP server) 192.168.0.54 through the gateway address 172.121.64.1 via vswif0 interface

# any net  192.168.0.54 netmask 255.255.255.255 gw 172.121.64.1 dev vswif0

3. To verify the added route

# route or route | grep 192.168.0.54  

After the above line is added  in the file /etc/sysconfig/static-routes. Routes are appearing even after the my ESX server reboot.

I hope this is informative for you. You can make use of my vSphere Distributed Switch Deep dive series to understand the in-depth architecture of virtual network. Be social and share it in social media like Google +, Facebook and Twitter, if you feel worth sharing it.

Exit mobile version