BUGFIX starting jail with dhcp

This commit is contained in:
yo 2024-04-20 20:32:51 +02:00
parent dbe9622a01
commit 452b0e4b4e
2 changed files with 25 additions and 10 deletions

View File

@ -1448,7 +1448,7 @@ func StartJail(args []string) {
fmt.Printf(" > Setup VNet network: OK\n")
// Set default route, unless main network is dhcp
if ! cj.isFirstNetDhcp() {
if ! cj.isFirstNetDhcp() && !strings.EqualFold(cj.Config.Ip4_addr, "none") {
fmt.Printf(" > Setup default ipv4 gateway:\n")
cmd := fmt.Sprintf("/usr/sbin/setfib %s /usr/sbin/jexec %d route add default %s", cj.Config.Exec_fib, cj.JID, cj.Config.Defaultrouter)
out, err := executeCommand(cmd)

View File

@ -83,6 +83,7 @@ func umountAndUnjailZFS(jail *Jail) error {
}
func destroyVNetInterfaces(jail *Jail) error {
if !strings.EqualFold(jail.Config.Ip4_addr, "none") {
for _, i := range strings.Split(jail.Config.Ip4_addr, ",") {
iname := fmt.Sprintf("%s.%d", strings.Split(i, "|")[0], jail.JID)
fmt.Printf("%s: ", iname)
@ -94,6 +95,20 @@ func destroyVNetInterfaces(jail *Jail) error {
fmt.Printf("OK\n")
}
}
}
if !strings.EqualFold(jail.Config.Ip6_addr, "none") {
for _, i := range strings.Split(jail.Config.Ip6_addr, ",") {
iname := fmt.Sprintf("%s.%d", strings.Split(i, "|")[0], jail.JID)
fmt.Printf("%s: ", iname)
_, err := executeCommand(fmt.Sprintf("ifconfig %s destroy", iname))
//_, err := executeScript(fmt.Sprintf("ifconfig %s destroy >/dev/null 2>&1", iname))
if err != nil {
return err
} else {
fmt.Printf("OK\n")
}
}
}
return nil
}