\begin{exe} {Adding a Static Route using \textbf{nmcli}}

   We are going to add a static  IPv4 route address to your
   system and make it persistent.  We will do this
   without editing files under \filelink{/dev} directly,
   using \textbf{nmcli}.

   \begin{enumerate}

      \item
      Begin by examining your current routing tables, using
      both \textbf{route} and \textbf{ip}:

      \begin{cmd}
$ route
      \end{cmd}
      \begin{response}
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.2.2      0.0.0.0         UG    100    0        0 ens33
link-local      *               255.255.0.0     U     1000   0        0 ens33
172.16.2.0      *               255.255.255.0   U     100    0        0 ens33
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
      \end{response}
      \begin{cmd}
$ ip route
      \end{cmd}
      \begin{response}
default via 172.16.2.2 dev ens33  proto static  metric 100
169.254.0.0/16 dev ens33  scope link  metric 1000
172.16.2.0/24 dev ens33  proto kernel  scope link  src 172.16.2.135  metric 100
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 linkdown
      \end{response}
      \item
      Add a new route using \textbf{nmcli}:
      \begin{cmd}
$ sudo nmcli conn mod "Auto Ethernet" +ipv4.routes "192.168.100.0/24 172.16.2.1"
      \end{cmd}
      \item
      Note it has not yet taken effect:
      \begin{cmd}
$ route
      \end{cmd}
      \begin{response}
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.2.2      0.0.0.0         UG    100    0        0 ens33
link-local      *               255.255.0.0     U     1000   0        0 ens33
172.16.2.0      *               255.255.255.0   U     100    0        0 ens33
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
      \end{response}
      \item
      Reload the interface to have it take effect and show it has:
      \begin{cmd}
$ sudo nmcli conn up "Auto Ethernet"
      \end{cmd}
      \begin{response}
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/25)
      \end{response}
      \begin{cmd}
$ route
      \end{cmd}
      \begin{response}
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.2.2      0.0.0.0         UG    100    0        0 ens33
link-local      *               255.255.0.0     U     1000   0        0 ens33
172.16.2.0      *               255.255.255.0   U     100    0        0 ens33
192.168.100.0   172.16.2.1      255.255.255.0   UG    100    0        0 ens33
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
      \end{response}
      \item
      Reboot and verify the route has taken effect (i.e., it is
      \textbf{persistent}:  If so remove it:
      \begin{cmd}
$ route
      \end{cmd}
      \begin{response}
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.2.2      0.0.0.0         UG    100    0        0 ens33
link-local      *               255.255.0.0     U     1000   0        0 ens33
172.16.2.0      *               255.255.255.0   U     100    0        0 ens33
192.168.100.0   172.16.2.1      255.255.255.0   UG    100    0        0 ens33
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
      \end{response}
      \begin{cmd}
$ sudo nmcli conn mod "Auto Ethernet" -ipv4.routes "192.168.100.0/24 172.16.2.1"

$ sudo nmcli conn up "Auto Ethernet"
      \end{cmd}
      \begin{response}
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.16.2.2      0.0.0.0         UG    100    0        0 ens33
link-local      *               255.255.0.0     U     1000   0        0 ens33
172.16.2.0      *               255.255.255.0   U     100    0        0 ens33
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
      \end{response}

      \item
      Note you can set a route with either \textbf{route} or
      \textbf{ip} from the command line but it won't survive
      a reboot as in:
      \begin{cmd}
$ sudo ip route add 192.168.100.0/24 via 172.16.2.1
$ sudo route
....
      \end{cmd}
      You can verify that a route established this way is not persistent.

   \end{enumerate}
\end{exe}

