To set static routes, use the /etc/sysconfig/network-scripts/route- files which are read during the network service initialization. For example to add static route for eth0, create a file /etc/sysconfig/network-scripts/route-eth0 and add the routes as explained below
- For ip commands, the ifup-route script. supplies ip route add and the contents of the file are all parameters necessary to set up the route. For example, to set up a default route, the file would contain the following:
default via X.X.X.X dev eth0
10.10.10.0/24 via X.X.X.X dev eth0
The alternative format is as follows:
In the above example, X.X.X.X is the gateway IP address. Subsequent entries must be numbered sequentially (for example ADDRESS1=, NETMASK1=, GATEWAY1=). Note, that multiple entries must be sequentially numbered and must not skip a value (0 must be followed by 1, not a number greater than 1).
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/10670663/viewspace-765574/，如需转载，请注明出处，否则将追究法律责任。