How to add static routes in Linux

Source: Internet
Author: User

1. Add a default route

Route add default gw 10.0.0.1 (effective only in memory by default)

You can append the file to/etc/rc. local at startup.

Echo "route add default gw 10.0.0.1">/etc/rc. local

2. Add a static route

Route add-net 192.168.2.0/24 gw 192.168.2.254

To take effect permanently, do the following:

Echo "any net 192.168.2.0/24 gw 192.168.2.254">/etc/sysconfig/static-routes

Static route entry added to a host

Route add-host 192.168.2.2 gw 192.168.2.254

To take effect permanently, do the following:

Echo "any host 192.168.2.2 gw 192.168.2.254">/etc/sysconfig/static-routes

Note: This file is not available in Linux by default. You must manually create one.

Read more: how to add permanent static routes in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.