(ip route) module introduces procedures to access and modify the
network routes on your machine. They are equivalent to the
family of commands, from
Add the route described by the argmuents. dest is the destination network,
in cidr notation (
addr/prefix) or the string
#:device is the name or index of a network link. #:table is the
index of a routing table, one of
RT_TABLE_LOCAL, as defined in
If it is set, #:protocol must be the routing protocol,
as defined in
#:scope must be the scope of the route, one of
#:type must be the type of route, one of
RTN_*, as defined in
If set, #:priority is a number specifying the priority of the rule when the kernel is looking for a matching rule. This is also known as the metric of the route.
If set, #:src is the source address in cidr notation, or as a single address.
If set, #:via is the gateway address. This is not in cidr notation, as the gateway is a single address, not a network.
(route-add "default" #:device "enp1s0" #:via "192.0.2.1") (route-add "192.0.2.0/24" #:device "enp1s0" #:src "192.0.2.15")
If you wish to add an IPv6 route instead, set
as in the following example.
(addr-add "2001:db8::/64" #:device "enp1s0" #:src "2001:db8::1a4c" #:ipv6? #t)
Note that using the wrong ip type with the wrong value for the
flag will result in a
Bad address exception from inet-pton.
Delete the route given in arguments. The arguments follow the same structure
route-add. By specifying more arguments, you can narrow down the
search for the rule to delete further. Each call will only remove one route,
so being more precise ensures you target the rule you wish to delete. It
is not clear which route is deleted if multiple routes match your query.
Print the list of routes on standard output. Note that, contrary to
ip route show, we show both IPv4 and IPv6 routes. To narrow down the
number of routes displayed, you can specify the family as in this example.
(route-show #:family AF_INET6)