Analysis of the starting process of Static Routing in CentOS

Source: Internet
Author: User

Analysis of the starting process of Static Routing in CentOS

This article analyzes the Starting Process of Static Routing in RHEL/CentOS, so that students can understand the Starting Process of Linux.

It can help students better understand the Linux system and troubleshoot common errors.

-System Startup Script

/Etc/init. d/network. This script is a bash script, and the key line for static route startup:

action$ "Bringingupinterface$i:" . /ifup $iboot

Ifup refers to/etc/sysconfig/network-scripts/ifup, and $ I refers to interfaces, such as eth0 and bond0.

Boot is actually not needed.

-Open the ifup script. The key two lines are:

OTHERSCRIPT= "/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" exec ${OTHERSCRIPT}${CONFIG}$2

DEVICETYPE is defined in/etc/sysconfig/network-scripts/network-functions. If the DEVICETYPE variable is eth and CONFIG is $1, The executed statement is:

exec /etc/sysconfig/network-scripts/ifup-eth $1$2

-Analyze the/etc/sysconfig/network-scripts/ifup-eth script again. The key is the last line:

exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG}${2}

-Analyze/etc/sysconfig/network-scripts/ifup-post, which contains a line:

/etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE}${DEVNAME}

-Finally, analyze/etc/sysconfig/network-scripts/ifup-routes. This script is used to start Static Routing. There are two functions: handle_file () and handle_ip_file (), both are used to add routes, but the two correspond to the file format that is not used, that is, Static Routing files can have two different formats.

-The following example shows how to automatically Load Static routes at system startup. For example, to add a static route to the bond1 interface, you must first create the file:/etc/sysconfig/network-scripts/route-bond1, then add the following lines to the file (for example ):

10.140.0.0 /15 via10.9.214.1

In another format, the students will study it by themselves and will not repeat it here.

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.