Advance

Routing tutorial with PowerShell

Routing tutorial with PowerShell

One of the features of Windows PowerShell is Route management, which is performed by the Get-NetRoute and New-NetRoute commands. Routing management in the CMD environment is with the Route command. In this article, we will teach you routing tutorial with PowerShell so that you can use PowerShell for routing in Windows.

Routing tutorial with PowerShell

PowerShell’s application for routing has many capabilities, and its many parameters will help you to easily get comprehensive information by personalizing the search.

Learn how to work with the Get-NetRoute command

This application is one of the routing commands in PowerShell that allows you to get complete information about the status of the routers written in your Windows. Here are some examples to teach you how to do this.

Get a list of routes associated with a network interface

Get-NetRoute -Protocol local -InterfaceAlias Ethernet  

Get routes that point to network address 192.168.0.0

Get-NetRoute -DestinationPrefix 192.168*  

Note: The network address must be entered as above. If you use an address such as 192.168.0.0, you will encounter an error.

Recommended Article: Installing on Microsoft IIS

List of routes added with a specific protocol

Get-NetRoute -Protocol Local -DestinationPrefix 192.168.*  

In this command, you can use protocols such as Rip, bgp, Eigrp, etc. instead of Local.

Get a list of active routes

Get-NetRoute -State Alive  

With the above command, you can get complete information from the written routines. You can use the Get-Help Get-NetRoute command for more information on other parameters.

Route writing tutorial with PowerShell

You can use the New-NetRoute command to write a Route manually. This command has the same structure as the Get-NetRoute command. In the following, we will give an example of how to write rout in PowerShell and explain the types of parameters on it.

Note: To write a route, you need to open PowerShell with Administrator access.

New-NetRoute -DestinationPrefix "10.0.0.0/24" -InterfaceAlias "Ethernet" -NextHop 192.168.1.1 -RouteMetric 1 -Protocol Local -Publish Yes  

In the example above, a route for routing the network 10.0.0.0 is written along with some parameters, which we will explain below.

– DestionationPrefix: The desired network address along with its perfix for routing

– InterfaceAlias: The name of the interface you want to write route for

– NextHop: Gateway address to access the imported network

– RouteMetric: The priority of sending packets to the desired Gateway

– Protocol: The type of routing protocol

– Publish: Route running and activating

Now you will be able to write your desired rout.

Note: In the above command, you will need the 3 main parameters DestinationPrefix, InterfaceAlias and NextHop, and if other parameters are not written, Windows will set them by default.

Conclusion

Since PowerShell is the most powerful command line tool, most of the Windows Server management commands are done through this lovely blue environment. In this article, we tried to teach you how to get Get-NetRoute command, Get a list of routes associated with a network interface, List of routes added with a specific protocol, and so on.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.
  • Colton
    Colton
    1 year ago

    When is PowerShell used?

    Reply
    • Dani
      Dani
      1 year ago

      The use of PowerShell is up to the user. This means that no matter how regular a Windows user you are, you rarely use this tool. This means that if you plan to use this scalable engine, you must first broaden your horizons and know that PowerShell is not like the Linux command line and follows a broader process. So, if you are a professional Windows user, the benefits of this tool will be more obvious to you.

      Reply
  • Jose
    Jose
    1 year ago

    How to redirect in Command Prompt and PowerShell?

    Reply
    • Dani
      Dani
      1 year ago

      In CMD, in order to change the path, you have to find the cd item, while in PowerShell, it is enough to get acquainted with Set-Location.

      Reply
  • Dominic
    Dominic
    1 year ago

    If we want to use other parameters in the Windows PowerShell environment, what command is needed?

    Reply
    • Dani
      Dani
      1 year ago

      Get-Help Get-NetRoute can be entered to access more information about the parameters.

      Reply
  • Kevin
    Kevin
    1 year ago

    What kind of command do we need to get those routes that have been added by a specific protocol?

    Reply
    • Dani
      Dani
      1 year ago

      In order to access this type of root, you can also use the following command:
      Get-NetRoute -State Alive

      Reply
  • Zachary
    Zachary
    1 year ago

    What command should I enter in order to get lists of routes that are active or active?

    Reply
    • Dani
      Dani
      1 year ago

      If you need active routes to receive routing information, you can access them by entering the following command in PowerShell:
      Get-NetRoute -State Alive

      Reply

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+18054214518

7 days a week, 24 hours a day