Как удалить статический маршрут windows

Маршруты — это сетевые установки, которые используются операционной системой для организации трифака и доступа к локальной сети и в Интернет. С помощью этой странички вы научитесь просматривать, удалять и добавлять маршруты на компьютере с ОС Windows от XP до 10. Все эти действия выполняются в командной строке или ее улучшенном и расширенном аналоге PowerShell.

Хочется также сказать о том, что если вы не уверены в своих знаниях, лучше не изменять данные настройки. Т.к. при неправильном использовании маршрутизации вы можете оставить ваш компьюетр без доступа к сети Интернет.

Просмотр маршрутов

Наберите команду

route print

persistent-routes-0011

Удаление всех статических маршрутов:

route -f

persistent-routes-0012

Добавление статического маршрута:

route -p add 0.0.0.0 mask 0.0.0.0 192.168.95.1

persistent-routes-0013

Удаляем все маршруты: route -f
persistent-routes-0015

После того, как все маршруты стёрты, естественно пропадёт Интернет. Для того, чтобы он появился вновь, необходимо задать маршрут по умолчанию. Добавляем постоянный маршрут к шлюзу:

route -p add 0.0.0.0 0.0.0.0 192.168.10.254 OK

В Windows XP/2003 Server после этого появится Интернет. Но если у вас Windows 7/8.1/или 2008/2012 Server, необходимо также выполнить команды:

ipconfig /release
ipconfig /renew

Как удалённо очистить таблицу маршрутов

Если вы хотите проделать все эти операции удалённо, вам понадобится программа NetAdapter Repair (подробнее). Дело в том, что после применения команды route -f соединение с сервером будет утрачено. А утилита NetAdapter Repair автоматически перезагрузит компьютер после очистки таблицы маршрутов. Для удалённой очистки необходимо проделать следующие действия:

1 Запустить утилиту NetAdapter Repair от имени Администратора.

2 Установить флажок возле пункта Clear ARP/Route Table.

3 Нажать кнопку Run All Selected:

NetAdapter Repair. Удалённая очистка таблицы маршрутов

После выполнения операции пойдёт обратный отсчёт времени и компьютер (сервер) перезагрузится автоматически:

persistent-routes-0022

Если что-то непонятно, спрашивайте в комментариях.

In this article, we will look at what a ‘static route’ is and why it should be added at all. We will use the so-called ‘Root’ — meaning we will prescribe routes using the ‘route add’ command in the Windows command line. Let’s recap the theory and in what cases using the ‘route add’ in this way may be useful for you.

‘Static routing’ is a type of routing in which routes are explicitly specified when configuring a router. All routing occurs without the participation of any routing protocols.

A ‘static route’ is an administrator-defined route causing packets that move between the source and destination to go along the specified path. It is an explicitly indicated path that a packet must travel from point A to point B.

Why do we need to be able to add static routes? It is very common for security to use Virtual Private Networks (VPN). VPNs are used both by organizations — for the organization of their secure networks — and by providers — to provide access to the global Internet to simple users. This sometimes causes minor inconveniences, however, to organizations and among ordinary users.

For example, if you have two computers at home, the first of which has access to the Internet via VPN, it is also connected to the second computer’s local network. Every time it connects to the Internet, the connection between the two computers is lost because the first computer (the one connected to the VPN) is already on another network and therefore unavailable to the second computer. This can be corrected just by configuring a static route.

Routes are network settings that are used by the operating system for organizing network traffic, as well as accessing the local network and the Internet. With help of the information on this page, you will learn how to view, delete, and add routes on a computer running a version of Windows — from XP to 10.

1. View Active Routes in Command Prompt Tool

To simply see the routing table on your computer, type the following at the command prompt Start Run cmd:

route print

2. How to Remove All Static Routes

This is done in the following way: run the command line and type the following command:

route -f

3. Add Static Route in Command Line Shell

To add a static IP route, in the command line running as administrator, enter the command:

route -p add 0.0.0.0 mask 0.0.0.0 192.168.95.1

Where:

  • route the program itself that works with the routing table;
  • -p is a key that says that the route will be permanent, because (Important note!) without this key, all routes that you add will be deleted after rebooting, so if you want to use the route always, write this key if only once, then you can not write;
  • add the command itself that adds an entry to the routing table;
  • 0.0.0.0 the network with which you want to have a connection;
  • mask 0.0.0.0 subnet mask;
  • 192.168.95.1 the gateway address, usually the modem address.

4. How to Remove Specific Static Route

To remove static route open command line and type this command:

route delete 0.0.0.0 mask 0.0.0.0 192.168.95.1

How to Manage Static Route with Action1

The first thing you need to do is login to the Action1 dashboard.

Next, on the left side menu, select the Managed Endpoints item and mark the endpoint for which you want to block the port.

Then click on the More Actions button and select the Run Command option.

In the window that opens, enter the command route -p add 0.0.0.0 mask 0.0.0.0 192.168.95.1 to add a static route you need.

In case you need to delete a route use this command route delete 0.0.0.0 mask 0.0.0.0 192.168.95.1

After clicking the Next Step button, you need to select the endpoints for which you are going to add or remove static route. To do this, click Add Endpoints and select the desired endpoint.

Click Next Step and in the next step you can schedule the execution time of your command. Then click Finish.

Consider Using Action1 Cloud RMM Solution

Action1 allows IT professionals to efficiently manage configurations for computers within and outside the local network. In addition, the platform offers total control of patch management, software distribution, remote desktop, as well as many other features to run your IT security and administration as seamlessly as possible.

Маршруты в Windows

route print — вывести список всех маршрутов, ключ -4 выведет все маршруты только по протоколу ipv4

Добавить маршрут в Windows

Синтаксис добавления маршрута в CMD

route add -p <SUBNET_ID> mask <SUBNET_MASK> <GATEWAY> <METRIC> IF <INTERFACE_ID>

где:
Ключ -p (persistent) добавит статический маршрут, т.е. он сохранится после перезагрузки. Во избежание стрельбы себе в ногу лучше сначала добавить без -p, протестить и потом уже добавить с -p.
SUBNET ID — подсеть которую мы добавляем
SUBNET MASK — маска для нового маршрута
METRIC — вес маршрута от 1 до 9999, чем меньше значение, тем выше приоритет маршрута
GATEWAY — гейтвей для новой подсети, по сути первый hop в который сервер отправит трафик
INTERFACE ID — необязательно, нро лучше указываем интерфейс, иначе может забиндиться на другой NIC и отправить трафик в неверном направлении, прописываем route print и смотрим внутренний номер интерфейса

Добавить маршрут в CMD

route add -p 192.168.0.0 MASK 255.255.255.0 192.168.1.1 metric 7 IF 11

Прочитать можно так: чтобы трафик попал в подсеть 192.168.0.0/24, нужно обратиться к узлу 192.168.1.1 через сетевой интерфейс с айди 11

Добавить маршрут в PowerShell

Тут вместо route print используется Get-NetRoute
Get-NetAdapter используется чтобы узнать Interface Index

New-NetRoute -DestinationPrefix "192.168.0.0/24" -RouteMetric 7 -InterfaceIndex 11 -NextHop 192.168.1.1

Удалить маршрут в Windows

Удалить маршрут в CMD

route delete 192.168.0.0 MASK 255.255.255.0 192.168.1.1 IF 11

Удалить маршрут в PowerShell

Remove-NetRoute -DestinationPrefix "192.168.0.0/24" -RouteMetric 7 -InterfaceIndex 11 -NextHop 192.168.1.1

Маршруты в Linux Линукс

route -n — вывести список всех маршрутов

Добавить маршрут в Linux Линукс

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0

или

route add -net 192.168.0.0/24 gw 192.168.1.1 dev eth0

Добавить статический маршрут в Linux

В /etc/network/interfaces, после описания интерфейса, следует добавить:

post-up route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.1.1

Удалить маршрут в Linux Линукс

route delete -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.1.1

Sometimes you need to create static route entries to make communication with different networks that are connected via a different gateway. A gateway is simply a network router that routes the network traffic between different networks. When you have more than one gateway (router) on your network, then you may need to implement static route technique on Windows 10/Windows 11 or Windows servers/any Operating system.

A static route will tell the Operating System to send network packets to the appropriate router instead of sending them to the default router. This simple guide shows how to add, delete and modify a static route to the routing table on Windows 11/10 and Microsoft Server Operating Systems.

There are a few useful commands you must know. Route delete, add and print. These commands will be handy to any user who has administrative access and know which router/gateway should be used for which network.

Why Add Static Route?

It mostly depends on the network setup. Usually, you can add these static routes on your default router (if it can support) or core switch. When you have this kind of proper network setup, you do not need to add a static route to each computer separately on the network. But in a few exceptional cases, you may need to implement static routes on individual computers. Here are a few examples.

  1. You have more than one internet router on the network and you need to send traffic to certain websites (based on their IP addresses) via a different router than the default gateway. Let’s say, for example, all traffic to Netflix can be sent via the 2nd internet router where other website traffic can go through the 1st internet router.
  2. There are several VLANs or subnets available on the network. Before building the proper routing table on the router or core switch, adding a static route on your Windows computer will help you to test the connectivity see the traffic flow.
  3. For network security or isolation purpose, certain routes can’t be added to the default gateway device. In this case, as a network administrator, you can add the static route on a local computer to make network communication.

Route Add on Windows 11/10 and Windows Servers

Though there are major changes and interface upgrades in the latest Windows 11, the below steps remain the same.

Make sure you run the below commands on command prompt (or PowerShell) which is opened as Administrator.

run as cmd

Here is the command to add a static route to the routing table.

route ADD destination_network MASK subnet_mask  gateway_ip metric_cost
route add 10.10.10.0 mask 255.255.255.0 10.10.29.1

It indicates that any packets to 10.10.10.0 (in class C – 255.255.255.0) network should be forwarded to the 10.10.29.1 router (gateway).

Obviously, the PC/server in which we run this command is in the 10.10.29.0/24 network because it should communicate to the gateway from the same network.

The issue with the above command is when you shut down or restart the computer, these route entries will be removed. To make it permanent and add to the Windows OS routing table, we should use the –p key with the add command. So, adding a persistent (or permanent) static route on Windows 10 command will be like this;

route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.1

Route Print

Route print command is another useful command to view the entries on the routing table and which routes are active at the moment.  If you need to modify an entry that is already in the routing table, better to confirm the entries before changing. To do it, use the route print command.

Route print

route print command Windows

Also, we can view the persistent routes in a Windows OS by checking the following registry path. Look for the entries in this area before or after modifying any routing table entries.

HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet-> Services->Tcpip->Parameters->PersistentRoutes

Route Delete on Windows 11/10 & Windows 2022/2019/2016 Servers

The below command is to delete an existing persistent route from a computer. Even though we added a route entry with the network, network mask and gateway, but to delete, we need to mention the network only. So, it goes like this;

route delete 10.10.10.0

That will delete the 10.10.10.0 route entry from the computer. You do not need to restart the computer to take effect. Adding and deleteting route entries take effect instantly.

Let’s say that after the recent network change, now the network 10.10.10.0 should be routed through the 10.10.29.200 gateway. Obviously, you have to modify the existing route for this network and change the gateway to 10.10.29.200.

So, how to modify the existing route entry? You can’t modify an existing entry.

The simple method is to delete it and add the new entry. So, in this case, you would perform the below commands.

Route delete 10.10.10.0

Route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.200

We hope this simple guide is helpful in understanding the route add, delete and print commands in Windows 10/Windows 11 client PC and other server Operating Systems. Make sure you open the command prompt or PowerShell as Administrator to perform these commands. If you want to use cosmetic variables to identify the fast hops to reach a network, you can use the metric key as described at the Microsoft site here.

The command to delete a route from the Windows routing table is route delete.

 route delete <SUBNET_ID>

To delete a route in Windows, use the route delete command followed by the subnet ID (IP address of the destination network/host).

For example, to delete routes to the 192.168.1.0 network, issue the route delete command as follows:

route delete 192.168.1.0

To be more specific, for example, to delete the route to the destination network 10.10.0.0 with the subnet mask of 255.255.255.0, enter the route delete command as follows:

route delete 10.0.0.0 mask 255.255.255.0

You can issue the route print command to check the Windows routing table.

Deleting Routes From the Routing Table in Windows With ROUTE DELETE Command

  • Как удалить телеграмм с компьютера windows
  • Как удалить старый принтер из системы windows 10
  • Как удалить темп файлы windows 10
  • Как удалить старый загрузчик windows 10
  • Как удалить телеметрию в windows 10 навсегда