![根據 DHCP 網關變更路由](https://rvso.com/image/1641894/%E6%A0%B9%E6%93%9A%20DHCP%20%E7%B6%B2%E9%97%9C%E8%AE%8A%E6%9B%B4%E8%B7%AF%E7%94%B1.png)
我已在路由器上設定 BGP(使用 Entware)以透過 VPN 發送一些路由。成功了。但現在我需要從中排除一種設備(它必須不通過 VPN 隧道)。
我的小鳥配置
log syslog all;
log stderr all;
router id x.x.x.x;
function martians()
{
return net ~ [ 100.64.0.0/10+,
169.254.0.0/16+,
172.16.0.0/12+,
192.168.0.0/16+,
10.0.0.0/8+,
127.0.0.0/8+,
224.0.0.0/4+,
240.0.0.0/4+,
0.0.0.0/32-,
0.0.0.0/0{0,7}
];
}
protocol device {
scan time 15;
}
protocol kernel kernel_routes {
scan time 60;
import none;
export all;
kernel table 1000; # kernel routing table number
}
protocol static static_routes {
import all;
#route 192.168.2.62/32 via "eth3";
}
protocol bgp antifilter {
import filter {
if martians() then reject;
gw = 1.0.0.1; # override route nexthop
accept;
};
export none;
local as 64999; # local default as-number
neighbor y.y.y.y as 65432;
multihop;
hold time 240;
}
VPN 連線出現時建立表 1000
ip rule add iif br0 table 1000
對於 SBR,我嘗試執行以下命令:
ip rule add from 192.168.2.62 table 120
ip route add default dev eth3 table 120
但結果是「網路不可用」。
現在我嘗試了這個
ip rule add from 192.168.2.62 table 120
ip route add default via x.x.x.x dev eth3 table 120
它已經奏效了。但我不知道運營商的網關不在運行時。它來自 DHCP。如何根據 DHCP 的新資訊更改表 120 中的預設路由?或如何在 Bird 配置中排除它
答案1
您可以只請求main
需要 DHCP 預設路由的主機的表:
ip rule add pref 100 from 192.168.2.62 table main
ip rule add pref 200 iif br0 table 1000