Configure static routes under Linux
Experimental topological diagram
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/DF/wKiom1Ps1HKh-6JrAAD5V1TpcqE466.jpg "title=" Experimental topology. png "alt=" wkiom1ps1hkh-6jraad5v1tpcqe466.jpg "/>
1, first set the IP address for eth0 and eth1 under B computer
Open configuration file
#vim/etc/sysconfig/network-scripts/ifcfg-eth0
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/45/E1/wKioL1Ps07KC8Hy0AAEU3rOD9-4600.jpg "title=" 1.png " alt= "Wkiol1ps07kc8hy0aaeu3rod9-4600.jpg"/>
Device= The name of the NIC
Bootproto= whether to use DHCP, choose not to use in the experiment
Hwaddr= whether to add a network card number (MAC)
Ipaddr= is the IP address .
netmask= Mask
network= domain, which is the network segment you are in
onboot= here to select Enable, i.e. YES
gateway= Gateway
broadcast= broadcast address, in the experiment without the tube
After the configuration is complete, restart the network service
#service Network Restart
the network card configuration method of several other computers and B Computer, just configure the eth0 after the configuration eth1 on the selection .
2. Configure static routing table
File path:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/45/E1/wKioL1Ps1Cfjw0oiAAE8oGXk_50411.jpg "title=" 5.png " alt= "Wkiol1ps1cfjw0oiaae8ogxk_50411.jpg"/>
B Computer routing table configuration ;
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DF/wKiom1Ps01jgL2lqAAGJDuF7CMw155.jpg "title=" 2.1. PNG "alt=" wkiom1ps01jgl2lqaagjduf7cmw155.jpg "/>
C Computer routing table configuration
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/E1/wKioL1Ps1IuAO7GNAAC74ufpe9s635.jpg "title=" 3.1. PNG "alt=" wkiol1ps1iuao7gnaac74ufpe9s635.jpg "/>
3 . Check if the routing forwarding feature is enabled
[Email protected] ~]# Cat/proc/sys/net/ipv4/ip_forward
1(if 1 is shown here ,indicates enabled, if 0 is displayed, it is not enabled)
If not enabled, use this command to enable:
#ech0 1 >/proc/sys/net/ipv4/ip_forward
C Computer also to enable routing forwarding
4. Change The routing configuration file. (Because the routing settings configured by the previous command are lost after the network service is restarted, change the configuration file)
#vim/etc/sysctl.conf
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/45/E1/wKioL1Ps1OSTStjtAAHBmpqaP4I932.jpg "title=" 4.png " alt= "Wkiol1ps1oststjtaahbmpqap4i932.jpg"/>
Use after configuration is complete
#sysctl –p
Make the configuration file effective immediately
Then restart the Network service
C Computer also to change the routing configuration file
After the above configuration is completed, the static route under Linux even if the configuration is complete, I'll look at the results.
this is in Ping The results of the D computer using the ping command on computer B
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/45/E1/wKioL1Ps1Qahc_ekAAGuEFlVdmw867.jpg "title=" 6.png " alt= "Wkiol1ps1qahc_ekaagueflvdmw867.jpg"/>
This is used D Computer PING a computer results
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/45/E1/wKioL1Ps1SPRqiuyAAJ5ZCCRgjM173.jpg "title=" 7.png " alt= "Wkiol1ps1sprqiuyaaj5zccrgjm173.jpg"/>
At this point, static routing is complete, rookie experiment notes, the shortcomings of the great God, please teach,
This article is from the "Communication" blog, please be sure to keep this source http://sxct168.blog.51cto.com/824373/1540235