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 ""

should work, however the packages don't seem to be routed across the correct network.

  • Can you describe your network layout in further detail? Does each interface have an attached router that you want to forward packages to?
    – vidarlo
    Jun 29, 2021 at 15:40
  • why not using basic ip route?
    – djdomi
    Jun 29, 2021 at 20:03
  • thanks @djdomi. Seems ip route is what i need. Now i just need to find out what the correct routes look like.
    – danba
    Jul 1, 2021 at 6:22
  • @danba since oyu did not tell what is exactly the issue, i cant help currently (X and Y Problem)
    – djdomi
    Jul 1, 2021 at 11:34

1 Answer 1


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 to another network card.

You Provided "Wired connection 1" +ipv4.routes ""

-- which device name should the right one, can be found out via ip address or ifconfig -- Usually you unsure to it, unplug the cards cable and look to dmesg or /var/log/syslog

So in My Example, assume the Following:

  • "Wired connection 1" = eth0
  • "" or (or should be routed to eth0

The Short way for testing or pre-set, not Persistent:

ip route add dev eth0

The Tricky Part for now is, getting it Persistent.

On RHEL/CentOS/Fedora/Scientific based Systems,

  • edit /etc/sysconfig/network-scripts/route-eth0

Adding here via

Where the First is the Network you want to match, second the IP of the Router. In My example,

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.

  • edit /etc/network/interfaces

Look for your Interface eth0

iface eth0 inet static

Modify, that it looks like

iface eth0 inet static
###EITHER with Gateway
#post-up route add -net netmask gw dev eth0
#post-down route del -net netmask gw dev eth0

###or without Gateway
#post-up route add -net netmask dev eth0
#post-down route del -net netmask dev eth0

The Generic, Static Way (Might be outdated on Systemd enabled systems)

Edit /etc/rc.d/rc.local or /etc/rc.local


  • ip route add dev eth0

This answer is meaned to solve it in generally.

  • @danba it would be great if you could accept the answer if it helped you, or tell me in case if not so i can ajust my answer
    – djdomi
    Jul 5, 2021 at 4:23
  • 1
    thanks for the detailed answer. I ended up having to specify the via for the route in order to get any packets to go over it. ip route add via dev eth0. Also i realized that i had multiple default routes (one for each device), and I only wanted one device to be used as a fallback in case there's no more specific route, so i removed the excess defaults by ip route flush default via dev eth0.
    – danba
    Jul 5, 2021 at 5:58
  • Okay, one point for you i forget the flush default :)
    – djdomi
    Jul 5, 2021 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .