Linux hosts add routing route

Source: Internet
Author: User

Recent small mess I use the Ansible batch deployment device access to the log audit system, after the discovery of script execution, the log server side still did not receive the Linux host upload syslog, after troubleshooting the cause of the failure is that the host route is not put through

To add a route to a host, the instructions are simple:

1. Add/Remove Default gateways:

Added: Route add default GW  GATEWAY_IP
Delete: Route del default GW gateway_i

2. Add/Remove normal routes:

-host 192.168.1.1 GW gateway_ip Delete: Route del  -gateway_ip-192.168.1.1Gateway_ IP Delete: Route del  192.168.1.1255.255.255.255gateway_ip

  Note: Add routes directly using the route command, and once the system restarts, the configured routes will disappear ;

Cause: The routing table of the Linux host only survives in memory;

Workaround: Add the routing information to the following file (either) and the system will load automatically when it restarts:

  1,/etc/rc.local  2,/etc/ profile 3,/etc/sysconfig/static-router

Enclose the format written on these three files:

1,/etc/rc.local

    Route Add-host x.x.x.x GW x.x.x.x    -net x.x.x.x netmask x.x.x.x GW x.x.x.x

2,/etc/profile

    Route Add-host x.x.x.x GW x.x.x.x    -net x.x.x.x netmask x.x.x.x GW x.x.x.x

3,/etc/sysconfig/static-router (if you do not have this file, you can manually create a)

    192.168. 1.0/ GW gateway_ip
Any host 192.168.1.0 GW Gateway_ip

Additional notes:

For example, using 1 and 2, the route will be loaded automatically after rebooting the system, but if the network service is restarted, the routing table is still missing because the system is not re-loaded in/etc/profile and/etc/rc.local, but using 3 does not occur, and viewing the data on the web says: The network script invokes the information inside the/etc/sysconfig/static-router, so using Method 3, you can still load the routing table even if you restart the network service.

Linux hosts add routing route

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.