route Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

The route command in Linux is an essential tool for systems administrators. It allows them to display and manipulate IP routing tables. It is used to configure static routes, which are often needed when setting up network configurations. This command is vital for managing the flow of traffic within a network.

Syntax of route Command in Linux

The basic syntax of the route command in Linux is as follows:

Where:

  • add|del|change|get: These options specify the action to be performed. They can either add, delete, change routes, or get routing information.
  • -net|-host: These options specify whether the target is a host or a network.
  • target: This represents the destination.
  • netmask: This is used to specify the netmask.
  • gw: This stands for 'gateway'. It specifies the gateway.
  • [dev] If: This specifies the interface.
Sharpen Your Fundamentals with Free Learning

Options in route command in Linux

  1. -n: Show numerical addresses instead of trying to determine symbolic host names.

    For example -

    Output:

    This command displays the routing table with numerical addresses.

  2. add: Used to add a route.

    For example -

    This command adds a route to the 192.168.2.0 network with the specified netmask and gateway.

  3. del: Used to delete a route.

    For example -

    This command deletes the route to the 192.168.2.0 network with the specified netmask and gateway.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Display the IP routing table:

    Output:

    Explanation: This command displays the current IP routing table.

  • Add a default gateway:

    Explanation: This command sets 192.168.1.1 as the default gateway.

Tips

  • The route command is being phased out in favor of the 'ip route' command. However, it is still widely used and found in many systems.

  • Always double-check your routing table after making changes to verify that routes have been added or removed correctly.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of route Command in Linux

  • Change an existing route:

    Explanation: This command changes the gateway for the 192.168.2.0 network to 192.168.1.2.

  • Get the route to a specific host or network:

    Output:

    Explanation: This command retrieves the routing details for the specified IP address.

  • Delete all routes:

    Explanation: This command deletes all the routes in the routing table. This command should be used with caution as it can disrupt network connectivity.

Conclusion

  • The route command in Linux is a powerful tool for managing IP routing tables.

  • It provides several options to add, delete, change and get routing information.

  • While the 'ip route' command is gradually replacing it, the route command is still widely used and crucial for Linux system administrators.