This paper analyzes the starting process of static route of Rhel/centos system, so that students can understand the starting process of Linux system.
can help students to better understand the Linux system, also can help the usual troubleshooting.
-System startup script
/etc/init.d/network, this script is a critical line initiated by the bash script, static route:
Action $ "Bringing Up interface $i:"./ifup $i Boot
Ifup refers to the/etc/sysconfig/network-scripts/ifup, $i refers to interface, such as ETH0,BOND0.
Boot can actually be no more.
-Open the Ifup script, where the two most critical lines are:
otherscript= "/etc/sysconfig/network-scripts/ifup-${devicetype}" exec ${otherscript} ${config}
DeviceType is defined in/etc/sysconfig/network-scripts/network-functions, where the DeviceType variable is assumed to be eth,config, then the executed statement is:
Exec/etc/sysconfig/network-scripts/ifup-eth $
-Re-profiling the/etc/sysconfig/network-scripts/ifup-eth script, the key is the last line:
Exec/etc/sysconfig/network-scripts/ifup-post ${config} ${2}
-then analyze/etc/sysconfig/network-scripts/ifup-post, which has a line:
/etc/sysconfig/network-scripts/ifup-routes ${realdevice} ${devname}
-Finally Analysis/etc/sysconfig/network-scripts/ifup-routes, this script is used to start the static route script, there are two functions: Handle_file () and Handle_ip_file (), are used to add routes, but they do not have the same file format, that is, static route files can be in two different formats.
-Below is an example of how to automatically load a static route at system boot, such as to add a static route to the Bond1 interface, you need to create the file:/etc/sysconfig/network-scripts/route-bond1, Then add the following line to the file (for example):
10.140.0.0/15 via 10.9.214.1
Another form of the students to study their own, here will not repeat.
This article from "Linux operation and Maintenance" blog, declined reprint!
Analysis of the starting process of static route in Rhel/centos