Okay, so let's summarize what we have just discussed. All network nodes are configured
with the default gateway. Without default gateway, your node doesn't know how to get
out. The default gateway specifies which node to use to address external nodes. And you
can use IP route show to show the default gateway. Static routes can be needed in some
cases to define a route to a network that is not behind the default gateway. This is
something that you will find in complex networks where multiple networks are connected by multiple
routers. You could do that in a runtime using a command like IP route at 192.2.0.0.74 via
10.0.0.10. So that will add the custom route to the 192.2.0.0.0 network via 10.0.0.10 where
10.0.0.10 must always be a network address that is accessible on the local network.
You can also configure persistent static routes. On Red Hat, you easily do that using NMTUI.
And on Ubuntu NetPlan, static routes are added as a property of the network card in the NetPlan
YAML file. So you would use routes and then you would use two with the IP address of the network
and via with the IP address of the local node that needs to be addressed for reaching this
specific network. Let me show you. So IP route show is what I want to do first. Here we can see
all the routes. And there is a default via. That's the default route that I need to get out
on the internet. And we also see the local network and the local network on the device
ENS160. That's the direct attached network. That doesn't really count. I can use IP route
add 192.168.30.0.24 to add an imaginary network. And let's do that without the typo. And then I
need via 192.168.29.3 for instance. And IP route show is going to show that the route has now been
added. Obviously, this serves to nothing if the network does not exist. So I can't test,
but I can show you how to do it in NMTY where I'm using editor connection edit. And there we have
routing where I need to select edit and I need to select add. So what am I going to add? Well,
192.168.29. No, not 29. 31.0.24. And the next hop, that's the computer on the local network that
will take me there. That could be four. And that is good enough. So I'm clicking OK. And I'm going
to activate just the usual way that we have seen before with NMTY. Hop, activate. And then we use
back. We get out of here. And I'm using IP route show. And what do we see? We see the new route
being added. And how about the old one? Well, remember, anything you do with the IP command
is non-persistent. And that means that when your network interface is restarted, reinitialized,
or whatever, you lose the configuration on it. And that's what just happened.