Static routes
U
SER
G
UIDE
146
In this case it is not possible to specify the administrative distance. When further routes to the same
destination are present, it is chosen the one with smaller metric. The command:
ip route get <dst>
displays which route will be selected in order to reach the destination
<dst>
.
In the same way, for IPv6 destinations the command:
ip
–
6 route get <ipv6-dst>
displays which route will be selected in order to reach the destination
<ipv6-dst>
.
Routes directly added through the
IP
command have priority over the other routes.
Using the
ip
command to add more routes is especially useful for debugging purposes, like to add
temporary routes without affecting the configuration of the router.
R
OUTES ACQUIRED VIA
DHCP
PROTOCOL
When you use the DHCP protocol in client mode on a specific network interface, you can also
acquire static routes sent to the DHCP server in addition to the IP address. Tipically, the server
always send the default route.
In the default configuration, the routes that are acquired via DHCP are set with an administrative
distance of
180
.
The command
set dhcpcd route <opzioni>
allows to re-configure the routing table, changing the default behaviour. For example:
set dhcpcd route host 194.1.1.1
installs only the route towards the host 194.1.1.1, independently of all the other routes sent by the
server. The nexthop is the IP address of the router supplied by the server.
Similarly, you can specify the sub-networks also:
set dhcpcd route net 172.123.0.0 netmask 255.255.0.0
You can also set the administrative distance value, the table in which the route must be inserted
and a possibile associated tag:
set dhcpcd route host a.b.c.d distance N
set dhcpcd route host a.b.c.d table N
set dhcpcd route host a.b.c.d tag N
The same options can be applied in case the route goes to a sub-network.
T
RAFFIC BLOCKING VIA STATIC ROUTES
The command
set route
can block traffic towards specific destination, configuring
null0
device
as outgoing interface of packets. For example:
set route net 85.34.166.16 netmask 255.255.255.248 dev null0
blocks the traffic towards
85.34.166.16/29
subnet.