Linux: Add routing from different class network A (192.168.1.x) to network B (192.168.10.x) with ip route command

Friday, 12th July 2013

adding routing from one network to other linux with ip route

I had a Linux router which does NAT for a local network located behind a CISCO router receiving internet via its WAN interface routing traffic  to Linux with IP The Linux router has few network interfaces and routes traffic for networks; and Another Linux with IP had to talk to (because it was necessary to be able access  ISCO's router web interface accessible via a local network interface with IP ( Access to wasn't possible from because routing on NAT-ting Linux ( to network was missing. To make Linux communicate with,  had to add following routing rules with ip command on both the Linux with IP and Linux host behind NAT (

1. On Server ( run in root shell and add to /etc/rc.local

# /sbin/ip r add via
And then copy paste same line before exit 0 in /etc/rc.local

Its good idea always to check routing, after adding anything new, here is mine:

# ip r show dev eth0  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev eth1  proto kernel  scope link  src
default via dev eth1 

2. And also on Second Linux host ( 

# /sbin/ip r add via
To make routing permanent again paste in /etc/rc.local before exit 0

After above rules, I can normally ping and access hosts on class C network  from

Share this on:

Download PDFDownload PDF

Tags: , , , , , , , , , , , , ,

Leave a Reply

CommentLuv badge