Analysis on the default route for adding CIDR blocks in Linux

Source: Internet
Author: User
The client needs to route some network segments to specific routes and use route to add rules. [Root @ localhost ~] # Routeadd-net192.168.192.0/24gw192. 168.191.1 description: routeadd-net needs to add the network segment gw gateway address but each restart server...
The client needs to route some network segments to specific routes and use route to add rules. [Root @ localhost ~] # Route add-net 192.168.192.0/24 gw 192.168.191.1 note: the IP address of the gw gateway to be added to route add-net is invalid after each restart of the server.

Solution:

Add the statement to the/etc/rc. local file [root @ localhost ~] # Vi/etc/rc. local #! /Bin/sh www.2cto.com # This script. will be executed * after * all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style. init stuff. touch/var/lock/subsys/local route add-net 192.168.192.0/24 gw 192.168.191.1: wq is the detailed rules for using route add on the Internet: use the Route Command line tool to view and edit the computer's IP Route table. the route Command and syntax are as follows: Route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric] [if Interface]-f clears the route tables of all Gateway entries. -P makes the route permanent when used together with the add command. Command specifies the Command you want to run (Add/Change/Delete/Print ). Destination specifies the network Destination of the route. Mask Netmask specifies the network mask (also known as the subnet mask) related to the network target ). Gateway specifies the forward or next hop IP addresses that the network target defines and the subnet mask can reach. Metric Metric specifies an integer cost value mark (from 1 to 9999) for the route, when the destination address of the forwarded packet is the most matched in the route table) you can use it when selecting multiple routes. Www.2cto.com if Interface specifies the Interface index for the Interface that can access the target. To obtain a list of interfaces and their corresponding interface indexes, use the display function of the route print command. You can use decimal or hexadecimal values for interface indexing. /? Display help at the command prompt. Example: to display all content of the IP route table: route print to display 10. route entry in the starting IP route table: route print 10. * to add a default route with the default gateway address 192.168.12.1: route add 0.0.0.0 mask 0.0.0.0 192.168.12.1 to add a route to the 10.41.0.0 destination with the 255.255.0.0 subnet mask and the next hop address 10.27.0.1: route add 10.41.0.0 mask route 255.0.0 10.27.0.1 to add a permanent route to the target 10.41.0.0 with the 255.255.0.0 subnet mask and 10.27.0.1 next hop address: route-p add 10.41.0.0 mask route 255.0.0 10.27.0.1 to add a route to the 10.41.0.0 target with the 255.255.0.0 subnet mask, 10.27.0.1 next hop address, and its cost value is 7: route add 10.41.0.0 mask route 255.0.0 10.27.0.1 metric 7 to add a route to the 10.41.0.0 target with the 255.255.0.0 subnet mask, 10.27.0.1 next hop address, and indexed using the 0x3 interface: route add 10.41.0.0 mask route 255.0.0 10.27.0.1 if 0x3 to delete a route to the destination 10.41.0.0 with the 255.255.0.0 subnet mask: route delete 10.41.0.0 mask route 255.0.0 www.2cto.com to delete 10. all routes in the starting IP route table: route delete 10. * to change the next hop address with the 10.41.0.0 destination and 255.255.0.0 subnet mask from 10.27.0.1 to 10.27.0.25: route change 10.41.0.0 mask 255.255.0.0 10.27.0.25 author txgc_wm
Related Article

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.