Linux Routing configuration file

Source: Internet
Author: User
Divided into system routing, network card routing (redhat8 above), static routing
System routing can be set in/etc/sysconfig/network
Network card routing can be set in/ETC/SYSCONFIG/NEWORK-SCRIPT/IFCFG-ETHX
Static routing in/etc/sysconfig/networking/device/can be set in Ethx.route, static route as the name implies, is fixed, set up the general will not easily change the route


Reproduced:
http://tieba.baidu.com/f?kz=636594999


Static routing configuration files in Linux


Static routing: Many people like to add a/etc/rc.d/rc.local to a large number of routes that are not part of this segment.


Route add-net 192.168.1.0 netmask 255.255.255.0 GW 10.224.0.251


Route add-host 192.168.100.1 GW 10.224.0.251


Such a statement, in fact, the system also provides the location where it is correctly placed, but this file does not exist by default, you need to see/etc/init.d/network this script to know, it will not only bring the network card, but also to check whether there are/etc/sysconfig/ static-routes files, if any, add the static routes recorded in these files, the format is simple, such as the above two statements replaced by the static-routes requirements of the format is:


Any-net 192.168.1.0 netmask 255.255.255.0 GW 10.224.0.254


Any-host 192.168.100.1 GW 10.244.0.254




I use the Redhat 8.0, single card.
My/etc/sysconfig/network is:
Networking=yes
Hostname=qflinux
gateway=192.168.0.1


My/etc/sysconfig/static-routes is:
eth0 net 192.168.1.0 netmask 255.255.255.0 GW 192.168.0.254
eth0 net 192.168.2.0 netmask 255.255.255.0 GW 192.168.0.254
eth0 net 192.168.3.0 netmask 255.255.255.0 GW 192.168.0.254


And also


Code:
[Root@qflinux sysconfig]# Ifconfig
Eth0 Link encap:ethernet hwaddr 00:05:5d:26:ae:69
inet addr:192.168.0.254 bcast:192.168.0.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:8084 errors:0 dropped:0 overruns:0 frame:0
TX packets:269 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:653535 (638.2 KB) TX bytes:31880 (31.1 KB)
Interrupt:5 Base address:0x9000


Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Up loopback RUNNING mtu:16436 metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 b) TX bytes:700 (700.0 b)
But:


Code:
[Root@qflinux root]# Route
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
192.168.0.0 192.168.0.254 255.255.255.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 Lo
Default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

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.