• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Linux Tutorials Networking

Linux Networking: route, Mastering Routing in Ubuntu

neo by neo
May 27, 2025
in Networking
0
Linux Networking: route, Mastering Routing in Ubuntu

Linux Networking: route, Mastering Routing in Ubuntu

0
SHARES
3
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Networking: Mastering Routing in Ubuntu

Linux Networking: route, mastering routing in Ubuntu lies at the heart of any networked system, determining how data packets travel between devices and networks. For Linux administrators, mastering routing commands is essential to control network traffic and troubleshoot connectivity issues effectively.

In Ubuntu, the route command offers a simple yet powerful way to view and manipulate the system’s routing table. Whether you’re adding static routes, analyzing traffic paths, or configuring network gateways, understanding this command is crucial for optimizing network performance and maintaining seamless connectivity.

In this guide, we’ll explore the basics of routing in Ubuntu, dive into practical examples using the route command, and share tips to help you master Linux networking with confidence. Let’s get started!

Using the route Command in Ubuntu

In Ubuntu, the route command helps display and modify the IP routing table, which defines the paths network traffic takes to reach its destination. Network administrators frequently rely on this command to configure, troubleshoot, and optimize routes.

By default, the route command belongs to the net-tools package. However, on newer Ubuntu distributions, this package might not be pre-installed because net-tools has been deprecated in favor of the iproute2 suite.

Command route not found
Command not found

Installation

To install net-tools (which contains route) package type in the terminal:

sudo apt install net-tools

Check Routing Table

To display the current routing table use the following:

ADVERTISEMENT
route

or

route -n

Output:

root@ubuntu-d-2022q1:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    100    0        0 enp0s3
10.0.2.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 enp0s3
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-15faf413e796

Route Output Explanation

This routing table entry defines the default route for all traffic. If a packet’s destination doesn’t match a more specific route, it will be forwarded to the gateway at 10.0.2.2 via the enp0s3 network interface. This setup is typical for systems connected to a network via NAT or bridge, such as in virtualized environments.

ADVERTISEMENT
  • Destination: This column indicates the network or host the route applies to.
  • Gateway: The IP address of the next hop or gateway through which packets should be routed.
  • Genmask: The subnet mask for the destination network.
  • Flags: These indicate various characteristics of the route
    • U: The route is up and operational.
    • G: The route is to a gateway (as opposed to a directly connected device).
  • Metric: The cost of the route. Lower metric values have higher priority.
  • Ref: This is the reference count (how many routes are referencing this entry).
  • Use: Indicates the number of times this route has been used to send packets.
  • Iface (Interface): The network interface associated with this route.

Add/Delete Route

For instance, you can use route add to define a new route or route del to remove an existing route. These options are particularly helpful when you need to reroute traffic due to changes in the network topology or troubleshoot connectivity issues.

To add a route to a specfic network or host use the following:

sudo route add -net <network> netmask <netmask> gw <gateway> dev <interface>

For specific host:

ADVERTISEMENT
sudo route add -host <host> gw <gateway> dev <interface>

# Example
sudo route add -net 192.168.10.0 netmask 255.255.255.0 gw 10.0.2.2 dev eth0

To delete a route:

sudo route del -host <host> gw <gateway> dev <interface>

defencedev.com

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

AdGuard: Block Different Services on the Local Network

Next Post

Linux Files Operation: grep, Efficient Text Search

neo

neo

Next Post
Linux Files Operation: grep, Efficient Text Search

Linux Files Operation: grep, Efficient Text Search

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Browse by Category

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.