Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ioc_start.py: allow setting IP address on lo0 #48

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iocage_lib/ioc_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ def start_network_interface_vnet(

dhcp = self.get('dhcp')

ifaces = []
ifaces = ['lo0']

for addrs, gw, ipv6 in net_configs:
if (
Expand All @@ -1193,7 +1193,7 @@ def start_network_interface_vnet(
# They didn't supply an interface, assuming default
iface, ip = "vnet0", addr

if iface not in nics:
if iface not in nics and iface != 'lo0':
continue

if iface not in ifaces:
Expand Down
30 changes: 29 additions & 1 deletion tests/functional_tests/0004_start_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_02_start_rc_jail(invoke_cli, resource_selector):
for jail in resource_selector.rcjails:
assert jail.running is True, f'{jail.name} not running'

# TODO: Let's also start jails in a single command to test that out
# Network-related tests belong here because the code is only executed at jail
# start time.

@require_root
@require_zpool
Expand Down Expand Up @@ -109,3 +110,30 @@ def test_03_create_and_start_nobridge_vnet_jail(release, jail, invoke_cli):

finally:
os.remove(path)


# TODO: Let's also start jails in a single command to test that out

@require_root
@require_zpool
def test_04_vnet_jail_with_loopback_alias(release, jail, invoke_cli):
jail = jail('loopback_alias_jail')

invoke_cli([
'create', '-r', release, '-n', jail.name,
'boot=on', 'vnet=on', 'defaultrouter=none',
f'ip4_addr=lo0|192.168.2.10'
])

assert jail.exists is True
assert jail.running is True

stdout, stderr = jail.run_command(['ifconfig', 'lo0'])
assert bool(stderr) is False, f'Ifconfig returned an error: {stderr}'
assert '192.168.2.10' in stdout, (
'Could not set address on loopback interface.'
)

invoke_cli([
'destroy', jail.name, '-f'
])