Skip to content

Static Routes

haripk edited this page Sep 9, 2014 · 9 revisions

Static Routes (on Virtual Machine Interface)

Routes can be statically configured in a virtual-network to direct traffic to go via a service virtual machine. The configured static routes are distributed to other nodes via BGP, thus directing traffic through required virtual machine. These routes are configured on a virtual machine’s interface.

For example in a virtual-network with subnet 10.0.0.0/24, all the traffic originating from a VM in virtual-network, destined to subnet 11.1.1.0/24 can be configured to go via a service appliance, using static route configured on a service VM interface.

  VM2 (10.1.1.252)   <------->   VM1 (10.1.1.251)   <------->  Service VM (10.1.1.253)  

In the above diagram service VM interface has a static route configured to receive all traffic destined to subnet 11.1.1.0/24.

Route table of virtual-network. Route/prefix NextHop 10.1.1.251/32 Compute Node1, Label A 10.1.1.252/32 Compute Node2, Label B 10.1.1.253/32 Compute Node3, Label C 11.1.1.0/24 Compute Node3, Label C

Configuration

Contrail UI

Enable static route option in service template 1> Choose service template image and type 2> Enable static route option for interfaces of interest

Adding static routes on service instance interface 1> Choose virtual network for interfaces 2> Configure static routes for interface, in the drop down menu of static routes 3> If auto scaling option is chosen, then traffic destined to static route subnet would be load balanced across service instances

Script

The below command adds a static route to forward traffic destined to 11.1.1.0/24 to be routed to the service VM interface 10.1.1.253 of the VM with UUID '4cf8bc4d-21e6-4555-9fe3-eaec454e9c3e' into a route-table with name my_route_table2.

On the cfgm node,

cd /opt/contrail/utils source /opt/contrail/api-venv/bin/activate python provision_static_route.py --prefix 11.1.1.0/24 --virtual_machine_id '4cf8bc4d-21e6-4555-9fe3-eaec454e9c3e' --virtual_machine_interface_ip 10.1.1.253 --route_table_name my_route_table2 --api_server_ip 10.204.217.7 --api_server_port 8082 --oper add --user admin --password contrail123 --tenant_name admin

You can add more than one route in the same route-table.

To delete a static route,

source /opt/contrail/api-venv/bin/activate python provision_static_route.py --prefix 11.1.1.0/24 --virtual_machine_id '4cf8bc4d-21e6-4555-9fe3-eaec454e9c3e' --virtual_machine_interface_ip 10.1.1.253 --route_table_name my_route_table2 --api_server_ip 10.204.217.7 --api_server_port 8082 --oper del --user admin --password contrail123 --tenant_name admin

Note : The VM UUID can be got either from the Contrail UI (Monitor >Networking > Instances) or from the Openstack Horizon UI (Click on the Instance name in the Instances list

Host Routes

Support is also added for host routes to be configured in the VM, via the classless static routes option in the DHCP server response sent to the VM. The routes to be sent in the DHCP response to the VM can be configured for each virtual network.

Host Routes can be added while creating the network in the “Create Network” page (configure -> Network -> Networks). Click on the “Host Routes” option and add the host routes that have to be sent to the virtual machines.

Clone this wiki locally