The route command for Linux

Source: Internet
Author: User

1. View the routing table
Route-n

2. Add Default gateway
Route add default GW 113.200.114.225
Or
Route add-net 0.0.0.0 netmask 0.0.0.0 GW 113.200.114.225

3. Delete the default gateway
Route del default GW 113.200.114.225

Generally, multiple network segments communicate with each other, and a priority route needs to be established rather than through the default gateway.
3. Routes added to the 192.168.40.0/24 subnet
Route add-net 192.168.40.0 netmask 255.255.255.0 GW 192.168.0.254
Or
Route add-net 192.168.40.0/24 GW 192.168.0.254

Specify a device instead of an address
Route add-net 192.168.40.0 netmask 255.255.255.0 Dev eth0
Or
Route add-net 192.168.40.0/24 Dev eth0

4. Remove the route to the 192.168.40.0/24 subnet
Route del-net 192.168.40.0 netmask 255.255.255.0 Dev eth0
Or
Route del-net 192.168.40.0/24 Dev eth0

5. Host routing: How to configure a route to a host
Route add-host 192.168.2.13 Dev eth2

Add to Script
Vi/etc/sysconfig/static_routes

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.