Skip to content

Commit

Permalink
Add mgmt subnet range to no_proxy var
Browse files Browse the repository at this point in the history
  • Loading branch information
toweber committed Dec 19, 2024
1 parent 2f9bab2 commit 5d7a870
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ func (c *CLab) createNodeCfg(nodeName string, nodeDef *types.NodeDefinition, idx
noProxyLower, existsLower := nodeCfg.Env["no_proxy"]
noProxyUpper, existsUpper := nodeCfg.Env["NO_PROXY"]
noProxy := ""
if existsLower {
if existsLower {
noProxy = noProxyLower
for _, defaultValue := range noProxyDefaults {
for _, defaultValue := range noProxyDefaults {
if !strings.Contains(noProxy, defaultValue) {
noProxy=noProxy + "," + defaultValue
}
}
} else if existsUpper {
} else if existsUpper {
noProxy = noProxyUpper
for _, defaultValue := range noProxyDefaults {
if !strings.Contains(noProxy, defaultValue) {
Expand All @@ -247,17 +247,21 @@ func (c *CLab) createNodeCfg(nodeName string, nodeDef *types.NodeDefinition, idx

// add all clab nodes to the no_proxy variable, if they have a static IP assigned, add this as well
var noProxyList []string
for key := range c.Config.Topology.Nodes {
noProxyList = append(noProxyList, key)
ipv4address := c.Config.Topology.Nodes[key].GetMgmtIPv4()
for key := range c.Config.Topology.Nodes {
noProxyList = append(noProxyList, key)
ipv4address := c.Config.Topology.Nodes[key].GetMgmtIPv4()
if ipv4address != "" {
noProxyList = append(noProxyList, ipv4address)
}
ipv6address := c.Config.Topology.Nodes[key].GetMgmtIPv6()
if ipv6address != "" {
noProxyList = append(noProxyList, ipv6address)
}
}
}

// add mgmt subnet range for the sake of completeness - some OS support it, others don't
noProxyList = append(noProxyList, c.Config.Mgmt.IPv4Subnet)
noProxyList = append(noProxyList, c.Config.Mgmt.IPv6Subnet)

// sort for better readability
sort.Strings(noProxyList)
Expand Down

0 comments on commit 5d7a870

Please sign in to comment.