Score:0

Configure Default route metric on multiple network cards

us flag

My network setup looks like this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 74:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.201/24 metric 100 brd 10.10.1.255 scope global dynamic enp2s0
       valid_lft 9012sec preferred_lft 9012sec
    inet6 fe80::0000:0000:0000:0000//64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 74:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.202/24 metric 100 brd 10.10.1.255 scope global dynamic enp3s0
       valid_lft 9012sec preferred_lft 9012sec
    inet6 fe80::0000:0000:0000:0000/64 scope link 
       valid_lft forever preferred_lft forever

My Netplan looks like this:

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp2s0:
      dhcp4: true
    enp3s0:
      dhcp4: true
  version: 2

My route looks like this:

default via 10.10.1.1 dev enp2s0 proto dhcp src 10.10.1.201 metric 100 
default via 10.10.1.1 dev enp3s0 proto dhcp src 10.10.1.202 metric 100 
10.10.1.0/24 dev enp2s0 proto kernel scope link src 10.10.1.201 metric 100 
10.10.1.0/24 dev enp3s0 proto kernel scope link src 10.10.1.202 metric 100 
10.10.1.1 dev enp2s0 proto dhcp scope link src 10.10.1.201 metric 100 
10.10.1.1 dev enp3s0 proto dhcp scope link src 10.10.1.202 metric 100 

I would like to have enp2s0 to be my default network card to access internet and my home network.

Where do I change this so even after a reboot or update it stays and doesn't return to default.

Thanks

Score:1
us flag

Found the solution:

Simply needed to add to my netplan and apply:

dhcp4-overrides:
    route-metric: 10

This is my updated netplan version:

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp2s0:
      dhcp4: true
      dhcp4-overrides:
        route-metric: 10
    enp3s0:
      dhcp4: true
      dhcp4-overrides:
        route-metric: 100
  version: 2

**** The lower value would be prioritized**

In now shows up with 'ip a' command:

2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 74:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.201/24 **metric 10** brd 10.10.1.255 scope global dynamic enp2s0
       valid_lft 10562sec preferred_lft 10562sec
    inet6 fe80::7a8c:b5ff:fe84:58d6/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 74:86:e2:2b:28:50 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.202/24 **metric 100** brd 10.10.1.255 scope global dynamic enp3s0
       valid_lft 10558sec preferred_lft 10558sec
    inet6 fe80::0000:0000:0000:0000/64 scope link 
       valid_lft forever preferred_lft forever
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.