Take a look at /etc/rc.d/rc.local. The file states
Please note that you must run chmod +x /etc/rc.d/rc.local to ensure that this script will be executed during boot.
So:
chmod +x /etc/rc.d/rc.local
Then place your commands above the last line
touch /var/lock/subsys/local
There is better way using relevant configuration files. Rules and routes can be specified using corresponding file names. All the relevant configuration files are given below. (The device names may differ.)
/etc/iproute2/rt_tables /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/route-eth0 /etc/sysconfig/network-scripts/route-eth1 /etc/sysconfig/network-scripts/rule-eth0 /etc/sysconfig/network-scripts/rule-eth1
To create a named routing table, use /etc/iproute2/rt_tables. I added 128 mynet.
# # reserved values # 255 local 254 main 253 default 0 unspec # # local # 128 mynet
The EL 7.x /etc/sysconfig/network file. The default route is GATEWAY.
NETWORKING=yes HOSTNAME=hostname.sld.tld GATEWAY=10.10.10.1
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth0 file, without HWADDR and "UUID". This configures a static IP address for eth0 without using NetworkManager.
DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTOCOL=none IPADDR=10.10.10.140 NETMASK=255.255.255.0 NETWORK=10.10.10.0 BROADCAST=10.10.10.255
THE EL 7.x /etc/sysconfig/network-scripts/ifcfg-eth1 file, without HWADDR and UUID. This configures a static IP address for eth1 without using NetworkManager.
DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTOCOL=none IPADDR=192.168.100.140 NETMASK=255.255.255.0 NETWORK=192.168.100.0 BROADCAST=192.168.100.255
The EL 7.x /etc/sysconfig/network-scripts/route-eth1 file. The default route was already specified in /etc/sysconfig/network.
192.168.100.0/24 dev eth1 table mynet default via 192.168.100.1 dev eth1 table mynet
The EL 7.x /etc/sysconfig/network-scripts/rule-eth1 file:
from 192.168.100.0/24 lookup mynet
Update for RHEL8
This method described above works with RHEL 6 & RHEL 7 as well as the derivatives, but for RHEL 8 and derivatives, one must first install network-scripts to use the method described above.
dnf install network-scripts
The installation produces a warning that network-scripts will be removed in one of the next major releases of RHEL and that NetworkManager provides ifup/ifdown scripts as well.