Linux Static route modification

Source: Internet
Author: User

1. Method One:

    • Add Add route
    • del Delete route
    • -net setting a route to a network segment
    • -host setting a route to a host
    • GW Export Gateway IP address
    • Dev Egress Gateway Physical device name
    • 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 route
      • Route del-net 192.168.0.0/24 GW 192.168.0.1
    • Add default route
      • Route add default GW 192.168.0.1
    • Route-n Viewing the routing table

Method Two:

    • Add Add route
    • del Delete route
    • Via Gateway egress IP Address
    • Dev Gateway Export Physical device name
    • 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 route
      • IP route del 192.168.0.0/24 via 192.168.0.1
    • Add default route
      • IP route add default via 192.168.0.1 dev eth0
    • Via 192.168.0.1 is my default router
    • Viewing routing information
      • IP route
    • Save the routing settings so that they are valid after a network restart
      • Create a file named Route-eth0 under the/etc/sysconfig/network-script/directory
      • Vi/etc/sysconfig/network-script/route-eth0
      • Add content in this file in the following format
      • 192.168.1.0/24 via 192.168.0.1
      • Restart network authentication

There are a few lines in/etc/rc.d/init.d/network:

# 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

In other words, adding static routes to the/etc/sysconfig/static-routes file is OK.

If you join:
Route add-net 11.1.1.0 netmask 255.255.255.0 GW 11.1.1.1

The format of the static-routes is
Any net 11.1.1.0 netmask 255.255.255.0 GW 11.1.1.1

Linux Static route modification

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.