İçeriğe geç

Configuring routes in Linux/Windows and changing priority of route by changing metric(Windows

Lets see the lab scenario(INE labFind the Secret Server):


Here there are total 5 networks:

a) Internet





Dynamic routing for network c) and d) is configured in router. So we can access Webserver running at and

Test Web Server
Company Web Server

1. Windows:

(A) Adding Routes

a) Lets first see our current routing table

route print
Routing table

b) As you can see we are already having routes to and, that’s why we are able to access webservers.

c) Now secret network( is also connected to the router but it cannot be accessed as we do not have route for this.

d) In this case we can add a route manually in our windows routing table.

route ADD <destination_network> MASK <subnet_mask>  <gateway_ip> metric_costroute ADD MASK

e) Now if we again see our routing table. We can see that our newly added route is there:

Newly added route

f) Now we should be able to access secret web server and indeed we can:

Secret Web server

(B) Changing priority of routes by changing metric

Lower the metric value means higher the priority. We will be seeing a scenario in which we are having 2 interfaces connected to internet 1) Ethernet and 2)Wi-Fi. By default Windows gives more priority to ethernet, therefore its metric has lower value as compared to that of Wi-Fi, but what if we want to use Wi-Fi for all the internet traffic fortunately I was having the same requirement and overcome this by changing the metric of default route of Wi-Fi route. is gateway address for Ethernet interface and is the IP address assigned to the interface by DHCP server of router. Similarly for WLAN interface is gateway address and is the IP address assigned to the Wi-Fi interface. Here is the ipconfig output just for confirmation:

a) Now for changing priority we first need to know the Interface. We can use any of these commands for this:

get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatusnetsh interface ipv4 show interfacesGet-NetAdapter

b) Changing the metric(Run as administrator):

Set-NetIPInterface -InterfaceIndex 12 -InterfaceMetric 15

(C) Disabling priority of ethernet interface(Prevents Wi-Fi disconnection after connecting Ethernet)

Just disable Priority & VLAN option in Interface advanced options

1. Go to network and sharing center in control panel.
2. Select change adapter settings
3. Right click on your Ethernet device and select properties on popup menu.
4. In properties menu, click configure button.
5. When configure menu, select advanced tab.
6. In advanced menu, under property list, look for “Priority & Vlan” and select it.
7. Look in value list to the right and select disable toggle.
8. Click Ok, on your way back out of menus and wait 15 seconds until system updates new value.

2. Linux:

Steps are exactly same. Only commands are different.


routing table


ip route add via
Adding new route

c) New route added:

Delete Route:

route del -net gw netmask dev eth0

Thank you for reading!

Author: Prabhsimran (https://www.linkedin.com/in/pswalia2u/)


İlk Yorumu Siz Yapın

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir