I have a manjaro linux server with at least two network interface controllers (NICs) and would like to route all traffic going to certain IP address ranges or subnets over one, and everything else over one of the others.
So far I've configured the networks via nmcli
, but I only have a tenuous grasp of the subject.
Ideally the solution would work via the command line, be persistent and not depend strongly on the distribution used.
Edit: As per Route IP Traffic using nmcli / Centos 7 something along the lines of
nmcli connection modify "Wired connection 1" +ipv4.routes "10.0.0.0/16"
should work, however the packages don't seem to be routed across the correct network.
General Pre-Information about this Answer
I assume my Answers in Generally on my Knowledge based on Debian Systems, however in this part I skip the Network-Manager Part due I am not using it anyway and in my personal mind makes it only complicated.
You Asked, and in the Comments it seems to be nearly clear, that you want to route the 10.0.0.0/16 to another network card.
You Provided "Wired connection 1" +ipv4.routes "10.0.0.0/16"
-- which device name should the right one, can be found out via
ip address
orifconfig
-- Usually you unsure to it, unplug the cards cable and look todmesg
or /var/log/syslogSo in My Example, assume the Following:
The Short way for testing or pre-set, not Persistent:
ip route add 10.0.0.0/16 dev eth0
The Tricky Part for now is, getting it Persistent.
On RHEL/CentOS/Fedora/Scientific based Systems,
Adding here
Where the First is the Network you want to match, second the IP of the Router. In My example, 10.0.0.1
Using the Debian Way. (Debian Bases Systems, Like Ubuntu)
on some Systems, /etc/network/interfaces may seem to be empty. In that case, you have to look into vi /etc/network/interfaces.d, but we assume the basic /etc/network/interfaces file to be used.
Look for your Interface eth0
Modify, that it looks like
The Generic, Static Way (Might be outdated on Systemd enabled systems)
Edit /etc/rc.d/rc.local or /etc/rc.local
add
ip route add 10.0.0.0/16 dev eth0
This answer is meaned to solve it in generally.