Ubuntu 管理心得

搜尋此網誌

2022年10月6日 星期四

Set network interface priority

cf: https://forums.raspberrypi.com/viewtopic.php?t=278033  

For linux: 

First run the command:

route -n 

It will show the metrics of the interface. 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    202    0        0 eth1
0.0.0.0         192.168.1.12    0.0.0.0         UG    303    0        0 wlan0
 
The lower the route priority first. So eth0 is higher than wlan0.
Edit /etc/dpchcd.conf: 
interface wlan0 
metric 100 
And run route -n, it will then show:
 
Kernel IP routing table 
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.12 0.0.0.0 UG 100 0 0 wlan0 
0.0.0.0 192.168.2.1 0.0.0.0 UG 204 0 0 eth1  
 
Thus, wlan0 will is higher than eth1. 
Becuase wlan0 is the external interface, while eth1 is for internal interface, the wlan0 priority need to be higher than eth1. Otherwise, the outside internet can not be reached. 
 
For windows:
The following image shows the NIC is set to metric 5.

 

 
 

沒有留言:

張貼留言

網誌存檔