Adding a persistent static route

Whether your Windows server or Linux server has multiple NICs to connect it to multiple VLANs and/or networks, sometimes you’ll need to configure a static route so that your server knows which interface to use in order to get to the syslog server, ntp server etc if it is to use a route other than the default gateway.

Solaris

vi /etc/gateways    (if this file doesn’t exist read on…)

Underneath>>    net 192.168.0.1 gateway 192.168.0.254 metric 1 passive

Add the following>>       net 10.0.0.0 gateway 10.8.2.65 metric 1 active

Note:  The default gateway is set in the /etc/defaultrouter file

If the /etc/gateways file doesn’t exist, then static routes may have been added “the old way”

cd /etc/rc2.d

ls | grep static

You may see a startup file called Snnnstatic_routes.  Inside this script will be non-persistent static routes added using lines that read something like /usr/sbin/route add 10.0.0.0/24 10.8.2.65 1   Append your routes to the ‘start’ section, not forgetting to add a corresponding route delete command in the ‘stop’ section.

Red Hat Linux

echo ‘10.0.0.0/24 via 10.8.2.65’ >> /etc/sysconfig/network-scripts/route-eth0

service network restart

route -n to view the current routing table

Windows

route -p ADD 10.0.0.0 MASK 255.255.255.0 10.8.2.65

netstat -rn to view the routing table

Excellent examples here: http://www.thegeekstuff.com/2012/04/route-examples/

Did you like this?
Tip cyberfella with Cryptocurrency

Donate Bitcoin to cyberfella

Scan to Donate Bitcoin to cyberfella
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to cyberfella

Scan to Donate Bitcoin Cash to cyberfella
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to cyberfella

Scan to Donate Ethereum to cyberfella
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to cyberfella

Scan to Donate Litecoin to cyberfella
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to cyberfella

Scan to Donate Monero to cyberfella
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to cyberfella

Scan to Donate ZCash to cyberfella
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.