Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Routing Tables

This section describes the way to setup routing table as well as it explains the logic used to prioritize interfaces.

The routing table is stored in the kernel which merely acts upon it. The route itself is set by the user-space tools. There is no preference as any tool created for this reason will do. It can be either a DHCP client, ip command or route command.

It is important to understand that NetworkManager changes the routing table whenever it creates a new connection.

Routing table acts as a junction and is there to show where the different network subnets will be routed to. An example of a routing table is shown below.

$ ip route \
    default via dev wlp3s0 proto static metric 600 \ dev wlp3s0 proto kernel scope link src metric 600 \ dev lxcbr0 proto kernel scope link src \ dev docker0 scope link metric 1000 linkdown \ dev docker0 proto kernel scope link src linkdown \ dev virbr0 proto kernel scope link src linkdown

The first column is the subnet with the “default” being a wildcard for everything else. The “via” fragment points to the <Gateway> however when it is missing it indicates that that network is connected directly and instead it describes a source address.

The metric field/column translates to the number of hops required to reach the destination and is used to determine which route shall be preferred when there are more than one route available for a specific destination. Since this value is related to the concept of distance, the lower it’s value is the better.

The metric value can be set manually however when NetworkManager creates a connection the following defaults are applied:

  • Ethernet is preferred over WiFi
  • WiFi is preferred over WWAN

Editing the routing tables

The routing table can be added or modified using the standard ip command which is available on Ubuntu Core. You can find more information on its man page.

Separately it is possible to modify routing information per single connection using the nmcli tool. The parameters such as: gateway, routes and metrics can be modified.

The following options are responsible:



These options can be modified in a following way:

$ nmcli connection modify <name> +ipv4.routes <destination> ipv4.gateway <gateway>
$ nmcli connection modify <name> ipv4.route-metric <metric>

Where <name> is the connection name. You can obtain it by listing available connections on the system:

$ nmcli c show
  • <destination> is the destination network provided as a static IP address, subnet or “default”.
  • <gateway> is the new gateway information. is the new metric information.

Note that this kind of changes can be made separately for each connection thus it is possible to provide a fine grained control over how the packets directed to different networks are routed.

It is also important to understand that bringing up and down connections with different values set for these options is in fact changing the routing table.

This page was last modified 6 months ago. Help improve this document in the forum.