Add a route table to CentOS

Source: Internet
Author: User
CentOS static route modification command Method 1: Add route routeadd-net192.168.0.0/24gw192. 168.0.1routeadd-host192.168.1.1dev192.168.0.1 delete route routedel-net192.168.0.0/24gw192. 168.0.1add add route del delete route-net CentOS static route modification command
Method 1:
Add route
Route add-net 192.168.0.0/24 gw 192.168.0.1
Route add-host 192.168.1.1 dev 192.168.0.1
Delete a route
Route del-net 192.168.0.0/24 gw 192.168.0.1

Add route
Del delete route
-Net
-Host: set the route to a host.
Gw egress gateway IP address
Dev egress gateway physical device name

Add default route

Route add default gw 192.168.0.1
By default, one route is enough.

Route-n View route table

Method 2:
Add route
Ip route add 192.168.0.0/24 via 192.168.0.1
Ip route add 192.168.1.1 dev 192.168.0.1
Delete a route
Ip route del 192.168.0.0/24 via 192.168.0.1

Add route
Del delete route
Via gateway egress IP address
Dev gateway egress physical device name

Add default route
Ip route add default via 192.168.0.1 dev eth0
Via 192.168.0.1 is my default router

View route information
Ip route

Save route settings so that they are valid after network restart
Create a file named route-eth0 in the/etc/sysconfig/network-script/directory.
Vi/etc/sysconfig/network-script/route-eth0
Add the following content to this file:

192.168.1.0/24 via 192.168.0.1

Restart network verification

 
/Etc/rc. d/init. d/network contains the following lines:

# Add non interface-specific static-routes.
If [-f/etc/sysconfig/static-routes]; then
Grep "^ any"/etc/sysconfig/static-routes | while read ignore args; do
/Sbin/route add-$ args
Done
Fi

That is, add the static route to the/etc/sysconfig/static-routes file.
 
For example, join:
Route add-net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1

The static-routes format is
Any net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1
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.