mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix: classic nic dhcp default gateway revisit (#25666)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -242,6 +242,7 @@ func getGuestConfig(
|
||||
osName = "Linux"
|
||||
}
|
||||
|
||||
// append default route
|
||||
if conf.Gateway != nil {
|
||||
if !strings.HasPrefix(strings.ToLower(osName), "win") {
|
||||
route4 = append(route4, netutils2.SRouteInfo{
|
||||
@@ -264,6 +265,18 @@ func getGuestConfig(
|
||||
})*/
|
||||
//}
|
||||
}
|
||||
// append link-local route
|
||||
if conf.ServerIP != nil {
|
||||
route4 = append(route4, netutils2.SRouteInfo{
|
||||
SPrefixInfo: netutils2.SPrefixInfo{
|
||||
Prefix: conf.ServerIP,
|
||||
PrefixLen: uint8(nicdesc.Masklen),
|
||||
},
|
||||
// link-local route gateway IP is the nic IP
|
||||
Gateway: net.ParseIP("0.0.0.0"),
|
||||
})
|
||||
}
|
||||
|
||||
route4, route6 = netutils2.AddNicRoutes(route4, route6, nicdesc, mainIp, mainIp6, len(guestNics))
|
||||
|
||||
conf.Routes = route4
|
||||
|
||||
@@ -540,11 +540,10 @@ func generateDhcpOptions(ctx context.Context, guestnetwork *agentmodels.Guestnet
|
||||
mdIp, "0.0.0.0",
|
||||
"0.0.0.0/0", network.GuestGateway,
|
||||
)
|
||||
} else {
|
||||
routes = append(routes,
|
||||
cidr, "0.0.0.0",
|
||||
)
|
||||
}
|
||||
routes = append(routes,
|
||||
cidr, "0.0.0.0",
|
||||
)
|
||||
if len(routes) > 0 {
|
||||
dhcpopts.Options["classless_static_route"] = fmt.Sprintf("{%s}", strings.Join(routes, ","))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user