Static Routing

Table of Contents

Static Route

Syntax

Creating Static Routes on a Switch

Static Route

Static routing is a routing method that uses manually-configured routing tables instead of dynamic routing traffic. It’s a good choice when a route doesn’t change often, when the complexity of a dynamic routing protocol is not desired, or when there’s only one or a few paths to a destination.

Static routes are defined manually, and a switch doesn’t need to learn or calculate routes.

A typical use case is a single-homed network attached to an upstream provider.

Example model & SONiC version:

  • Aurora 830, Aurora 721, Aurora 621
  • Netberg SONiC: sonic-broadcom-202311.n0

Syntax

config route add { add | del } prefix [vrf <vrf_name>] <A.B.C.D/M> nexthop <[vrf <vrf_name>] <A.B.C.D>>|<dev <dev_name>>

Parameter description:

add: Add a route.
del: Add a route.
vrf: VRF name.
A.B.C.D/M: IPv4 address in dotted notation.
dev_name: An interface name.
NotePrefix /nexthop vrf`s and interface name are optional.

ECMP support

Adding a new nexthop to the existing prefix will complement it and not overwrite it.

admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9
admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10

Creating Static Routes on a Switch

Figure 1. A network topology

Pre-requisite

  • Bind IP addresses and GW on hosts.
  • Bind IP addresses on switches.

Configuration

nba621-1

admin@sonic:~$ sudo config route del prefix 192.168.11.0/24 nexthop 10.0.1.1

nba621-2

admin@sonic:~$ sudo config route add prefix 192.168.10.0/24 nexthop 10.0.1.0

Results

admin@nba621-1:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route
K>*0.0.0.0/0 [0/202] via 192.168.0.1, eth0, 01:52:20
C>*10.0.1.0/31 is directly connected, Ethernet68, 00:45:08
C>*10.1.0.1/32 is directly connected, Loopback0, 01:52:20
C>*192.168.0.0/24 is directly connected, eth0, 01:52:20
C>*192.168.10.0/24 is directly connected, Ethernet0, 00:06:16
S>*192.168.11.0/24 [1/0] via 10.0.1.1, Ethernet68, 00:44:23
admin@nba621-2:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route
K>*0.0.0.0/0 [0/202] via 192.168.0.1, eth0, 01:52:17
C>*10.0.1.0/31 is directly connected, Ethernet68, 00:44:39
C>*10.1.0.1/32 is directly connected, Loopback0, 01:52:17
C>*192.168.0.0/24 is directly connected, eth0, 01:52:17
S>*192.168.10.0/24 [1/0] via 10.0.1.0, Ethernet68, 00:44:12
C>*192.168.11.0/24 is directly connected, Ethernet0, 00:03:59

Ping between hosts:

user@left:~$ ping 192.168.11.1
PING 192.168.11.1 (192.168.11.1) 56(84) bytes of data.
64 bytes from 192.168.11.1: icmp_seq=1 ttl=62 time=0.122 ms
64 bytes from 192.168.11.1: icmp_seq=2 ttl=62 time=0.164 ms
64 bytes from 192.168.11.1: icmp_seq=3 ttl=62 time=0.280 ms
64 bytes from 192.168.11.1: icmp_seq=4 ttl=62 time=0.113 ms
NEWS

Latest news