Static routes
U
SER
G
UIDE
145
S
TATIC ROUTES
C
ONFIGURATION
Static routing tables can be configured with the command:
set route net <dest> netmask <netmask> gw <ipaddr> [options]
set route net <dest> netmask <netmask> dev <interface> [options]
set route host <dest> gw <gw_ip_addr> [options]
set route host <dest> dev <interface> [options]
In order to remove a route the command is:
set no-route net <dest> netmask <netmask> gw <gw_ip_addr>
set no-route net <dest> netmask <netmask> dev <interface>
set no-route host <dest> gw <gw_ip_addr>
set no-route host <dest> dev <interface>
It is possible to give to the route several attributes through additional parameters,
Through additional parameters can be associated with different attributes for the route, such as the
administrative distance to determine the precedence of the route, a possible tag that can be used
by routing protocols for the redistribution of routes, the routing table for the operations of Policy
Based Routing (see next paragraph). The available options are:
tag N
tag N distance N
table N tag N distance N
For example:
set route net 192.168.13.0 netmask 255.255.255.0 gw 10.1.1.1 tag 10
set route net 192.168.13.0 netmask 255.255.255.0 gw 10.1.1.1 tag 20 distance 130
set route net 10.1.0.0 netmask 255.255.0.0 gw 1.1.1.1 table 1 tag 10 distance 220
To add a route to IPv6:
set route ipv6 X:X::X:X/N
It is possible to set the routes using
ip
11
command:
ip route add <dst> dev <ifname> proto kernel [metric N]
ip route add <dst> via <nexthop> proto kernel [metric N]
ip route add <dst> via <nexthop> dev <ifname> proto kernel [metric N]
If the destination is IPv6 it is necessary to specify:
ip
–
6 route add <dst> dev <ifname> proto kernel [metric N]
ip
–
6 route add <dst> via <nexthop> proto kernel [metric N]
11
-
The routes set by
ip
command are updated but are not saved in the configuration. In order to save and also activate them at the next router reboot, you have to use: set autocmd ip route add ....