route - View and Edit the Routing Table

Maintained on
Table of Contents

The route command displays and edits the routing table, the table of paths your computer uses for network traffic.

When your PC sends traffic, it consults the routing table to decide which gateway (exit) to use for a given destination. With route, you can inspect that table, or send traffic for a specific network through a different router.

Basic Syntax of the route Command

route [-f] [-p] [-4|-6] <command> [<destination>] [mask <netmask>] [<gateway>] [metric <metric>] [if <interface>]

Specify one of the following four commands as <command>.

CommandDescription
printDisplay the routing table
addAdd a route
deleteDelete a route
changeModify an existing route

Option Quick Reference

OptionDescription
-fClear all routes that have a gateway from the routing table
-pUsed with add to make the route persist across reboots
-4Target IPv4 only
-6Target IPv6 only
add / delete / change require administrator privileges

print works in a regular Command Prompt, but adding, deleting, or changing routes requires administrator privileges. Without them, the operation is denied. See the related article for how to start as an administrator.

Display the Routing Table (print)

route print
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>route print
===========================================================================
Interface List
(list of interface numbers and names)
===========================================================================
IPv4 Route Table
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.10 25
(one line per route follows)
C:\users\user>
Output varies by environment

Labels and contents vary depending on your Windows display language and network configuration. The output above is an example to show the format.

The IPv4 route table consists of the following five columns.

ColumnDescription
Network DestinationAddress of the destination network
NetmaskSubnet mask that defines the range of the destination network
GatewayAddress of the next device to forward traffic to (On-link if on the same network)
InterfaceIP address of the network adapter used to send the traffic
MetricPriority of the route. Lower values take precedence

The row with destination 0.0.0.0 and netmask 0.0.0.0 is the default route (default gateway). Any traffic that matches no other route is sent here.

Filter the Output

Specify a destination after print to show only matching routes. You can also use *.

route print 192.168.*

To show only IPv4 or only IPv6, add -4 or -6.

route -4 print
route -6 print

Add a Route (add)

For example, to send only traffic for 10.0.0.0/255.0.0.0 through the router 192.168.1.254:

route add 10.0.0.0 mask 255.0.0.0 192.168.1.254

To specify a metric, add metric.

route add 10.0.0.0 mask 255.0.0.0 192.168.1.254 metric 5

If you have multiple network adapters, specify the interface number with if (you can find it in the interface list shown by route print).

route add 10.0.0.0 mask 255.0.0.0 192.168.1.254 if 12
When adding an IPv6 route

Specify an IPv6 destination with a prefix length, such as 2001:db8::/32.

Keep the Route After a Reboot (-p)

By default, a route added with add disappears after a reboot. To keep it, add -p.

route -p add 10.0.0.0 mask 255.0.0.0 192.168.1.254

Persistent routes are listed in the “Persistent Routes” section at the end of the route print output.

Delete a Route (delete)

route delete 10.0.0.0

If you specify only the destination, the routes matching that destination are deleted. When several routes might match, also specify mask and the gateway to narrow down the target.

route delete 10.0.0.0 mask 255.0.0.0 192.168.1.254

Modify a Route (change)

Change the gateway or metric of an existing route.

route change 10.0.0.0 mask 255.0.0.0 192.168.1.253
What change cannot modify

change cannot modify the destination or netmask itself. To change them, remove the route with delete and add it again with add.

Clear the Routing Table (-f)

route -f

You can also combine -f with another command. In that case, the table is cleared before the command runs.

Do not run -f casually

Running -f removes every route that has a gateway, including the default route (default gateway), and you may lose access to the internet or your corporate network. If you are working remotely, you may be disconnected and unable to recover. To tidy up routes, it is safer to remove only the routes you need to with delete.

Practical Examples

Check the Current Default Gateway

Filter the output by specifying 0.0.0.0 as the destination to find the default route.

route print -4 0.0.0.0

ipconfig also shows the default gateway, but route print gives more detail when multiple routes exist.

Check Routes While on a VPN

Connecting to a VPN may add routes to the routing table. Save the route print output before and after connecting, then compare them with fc to see what changed.

route print > before.txt
rem Connect to the VPN, then
route print > after.txt
fc before.txt after.txt

Use a Different Router for One Network Only

This example sends only traffic for the internal network 10.1.0.0/16 through the dedicated router 192.168.1.254.

add-route.cmd
@echo off

route -p add 10.1.0.0 mask 255.255.0.0 192.168.1.254

if errorlevel 1 (
  echo Failed to add the route. Run this as an administrator.
  exit /b 1
)

echo Route added.

Summary

GoalCommand
Display the routing tableroute print
Display IPv4 onlyroute -4 print
Add a routeroute add 10.0.0.0 mask 255.0.0.0 192.168.1.254
Add a route that survives rebootsroute -p add 10.0.0.0 mask 255.0.0.0 192.168.1.254
Delete a routeroute delete 10.0.0.0
Change a route’s gatewayroute change 10.0.0.0 mask 255.0.0.0 192.168.1.253

Practice questions

Practice Problem

Which option do you specify to add a route that persists after a reboot?

Choose one answer.

  1. -f
  2. -p
  3. -4

Practice Problem

In the routing table, what does a route with destination 0.0.0.0 and netmask 0.0.0.0 represent?

Choose one answer.

  1. The loopback address
  2. The default route (default gateway)
  3. The broadcast address
#Command Prompt #Batch Files #Command Line #Commands #Network #Routing