bastille icon indicating copy to clipboard operation
bastille copied to clipboard

Wrong gateway chosen on create vnet jail

Open ddowse opened this issue 3 years ago • 2 comments

[MANDATORY] Describe the bug [MANDATORY]

On dual network stack host creating a vnet jail results to having the ipv6 gateway assigned. Creating a second or more jails afterwards results in created without a "defaultrouter" in rc.conf Stopping all jails.

[MANDATORY] Bastille and FreeBSD version (paste bastille -v && freebsd-version -kru output) 0.8.20210115 12.2-RELEASE-p1 12.2-RELEASE-p1 12.2-RELEASE-p1

[MANDATORY] How did you install bastille? (port/pkg/git) pkg

[optional] Steps to reproduce?

bastille create vnet alcatraz0 12.2-RELEASE 10.0.1.10/24 em0 [...creation...with ipv6 as defaultrouter in rc.conf] bastille create vnet alcatraz1 12.2-RELEASE 10.0.1.11/24 em0 [...no defaultrouter in rc.conf] bastille stop alcatraz0 bastille stop alcatraz1 bastille create vnet alcatraz2 12.2-RELEASE 10.0.1.12/24 em0 [...creation...with ipv6 as defaultrouter in rc.conf] bastille create vnet alcatraz3 12.2-RELEASE 10.0.1.13/24 em0 [...no defaultrouter in rc.conf] [and so on..]

[optional] Expected behavior

Choose the correct default gateway.

[optional] Screenshots

2021-03-03-022842_815x953_scrot

2021-03-03-023030_480x169_scrot

[optional] Note

The Problem seems to be around Line 386
...(netstat -rn | awk '/default/ {print $2}) ...

I can provide a fix if you think this is the problem, too.

ddowse avatar Mar 03 '21 02:03 ddowse

The auto-detection is not always perfect. Gateway can be defined in the bastille.conf using the bastille_network_gateway=aa.bb.cc.dd will be used to override auto-detection.

cedwards avatar May 05 '21 01:05 cedwards

In addition, there is also the problem, that there is no logic to set the IPv6 default gateway with sysrc: https://github.com/BastilleBSD/bastille/blob/master/usr/local/share/bastille/templates/default/vnet/Bastillefile

FloGatt avatar Jul 21 '21 14:07 FloGatt