E
E
edo1h2022-04-11 15:39:09
linux
edo1h, 2022-04-11 15:39:09

Are there ready-made solutions for multihoming in linux?

First, about the problem we are solving:
There are several links, each with its own address (or several addresses).
For example, we have eth0 with addresses 1.1.1.1 and 1.1.1.2, and eth1 with address

2.2.2.2 request came.

That is, let ip ro show
default via 2.2.2.1 dev eth1 onlink
AND on the external host we run ping 1.1.1.2
Responses to ICMP requests should go from the eth0 interface from the address 1.1.1.2

The task is familiar, it is solved using iptables / nftables and iproute2.
But the solution each time resembles a "sunset by hand."

Question: is there something ready to solve this problem? In order for the nftables rules for marking packets/records in conntrack, ip rule and their associated routing tables to be kept up to date automatically (the addition/removal of network interfaces and addresses on them was tracked).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
ValdikSS, 2022-04-13
@ValdikSS

NetworkManager is supported but requires manual configuration.
Something like:

# nmcli c modify 'eth0' ipv4.route-table 1234
# nmcli c modify 'eth0' ipv4.routing-rules "from 1.2.3.4 table 1234 priority 1000"

You will need at least some route in the main routing table, although
# ip route add default dev lo
netplan also supports policy routing, but did not test it.
In general, what you need can be implemented in a bash script in the form of a dispatcher for NetworkManager.

A
Alexander Karabanov, 2022-04-11
@karabanov

Multihome IPv4 in Linux
Just do not forget to enter connected routes, otherwise local traffic will go through the router, although it should go directly from machine to machine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question