Tenho duas interfaces de rede, eno1 e eth0. Gostaria que ambas usassem DHCP para obter um endereço IP. Gostaria que eno1 fosse usado como rota padrão para tudo. A única vez que quero usar eth0 é ao especificar interface em um comando curl.
Criei dois arquivos de configuração:
root:/etc/systemd/network$ ls -la
total 16
drwxr-xr-x 2 root root 4096 Oct 20 10:50 .
drwxr-xr-x 6 root root 4096 Oct 20 10:51 ..
-rw-r--r-- 1 root root 59 Oct 20 09:54 10-eno1.network
-rw-r--r-- 1 root root 59 Oct 20 10:41 20-eth0.network
root:/etc/systemd/network$ cat 10-eno1.network
[Match]
Name=eno1
[Network]
DHCP=yes
[Route]
Metric=100
root:/etc/systemd/network$ cat 20-eth0.network
[Match]
Name=eth0
[Network]
DHCP=yes
[Route]
Metric=4000
Tentei reiniciar e mexer nas métricas, mas elas não surtiram efeito.
root:/etc/systemd/network$ systemctl status systemd-networkd
● systemd-networkd.service - Network Configuration
Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; preset: enabled)
Active: active (running) since Sun 2024-10-20 10:51:59 UTC; 12min ago
TriggeredBy: ● systemd-networkd.socket
Docs: man:systemd-networkd.service(8)
man:org.freedesktop.network1(5)
Main PID: 24821 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 76956)
FD Store: 0 (limit: 512)
Memory: 1.7M (peak: 2.1M)
CPU: 32ms
CGroup: /system.slice/systemd-networkd.service
└─24821 /usr/lib/systemd/systemd-networkd
Oct 20 10:51:59 systemd-networkd[24821]: eth0: Link UP
Oct 20 10:51:59 systemd-networkd[24821]: eth0: Gained carrier
Oct 20 10:51:59 systemd-networkd[24821]: eno1: Gained IPv6LL
Oct 20 10:51:59 systemd-networkd[24821]: eth0: Gained IPv6LL
Oct 20 10:51:59 systemd-networkd[24821]: Enumeration completed
Oct 20 10:51:59 systemd[1]: Started systemd-networkd.service - Network Configuration.
Oct 20 10:51:59 systemd-networkd[24821]: eno1: Configuring with /etc/systemd/network/10-eno1.network.
Oct 20 10:51:59 systemd-networkd[24821]: eth0: Configuring with /etc/systemd/network/20-eth0.network.
Oct 20 10:51:59 systemd-networkd[24821]: eno1: DHCPv4 address 192.168.0.2/24, gateway 192.168.0.1 acquired from 192.168.0.1
Oct 20 10:51:59 systemd-networkd[24821]: eth0: DHCPv4 address 192.168.0.99/24, gateway 192.168.0.1 acquired from 192.168.0.1
root:/etc/systemd/network$ ip route show
default via 192.168.0.1 dev eno1 proto dhcp src 192.168.0.2 metric 1024
default via 192.168.0.1 dev eth0 proto dhcp src 192.168.0.99 metric 1024
128.138.140.44 via 192.168.0.1 dev eno1 proto dhcp src 192.168.0.2 metric 1024
128.138.140.44 via 192.168.0.1 dev eth0 proto dhcp src 192.168.0.99 metric 1024
192.168.0.0/24 dev eno1 proto kernel scope link src 192.168.0.2 metric 1024
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.99 metric 1024
192.168.0.1 dev eno1 proto dhcp scope link src 192.168.0.2 metric 1024
192.168.0.1 dev eth0 proto dhcp scope link src 192.168.0.99 metric 1024