Skip to content

Commit

Permalink
container: T6701: add support to disable container network DNS support
Browse files Browse the repository at this point in the history
Add ability to set the container network with a disable-dns setting to disable
the DNS plugin that is on be default.

  set container network <network> no-name-server
  • Loading branch information
dvogel-fp authored and c-po committed Sep 11, 2024
1 parent 5729112 commit 1d5625d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions interface-definitions/container.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@
<multi/>
</properties>
</leafNode>
<leafNode name="no-name-server">
<properties>
<help>Disable Domain Name System (DNS) plugin for this network</help>
<valueless/>
</properties>
</leafNode>
#include <include/interface/vrf.xml.i>
</children>
</tagNode>
Expand Down
16 changes: 16 additions & 0 deletions smoketest/scripts/cli/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ def test_dual_stack_network(self):
self.assertEqual(c['NetworkSettings']['Networks'][net_name]['Gateway'] , str(ip_interface(prefix4).ip + 1))
self.assertEqual(c['NetworkSettings']['Networks'][net_name]['IPAddress'] , str(ip_interface(prefix4).ip + ii))

def test_no_name_server(self):
prefix = '192.0.2.0/24'
base_name = 'ipv4'
net_name = 'NET01'

self.cli_set(base_path + ['network', net_name, 'prefix', prefix])
self.cli_set(base_path + ['network', net_name, 'no-name-server'])

name = f'{base_name}-2'
self.cli_set(base_path + ['name', name, 'image', cont_image])
self.cli_set(base_path + ['name', name, 'network', net_name, 'address', str(ip_interface(prefix).ip + 2)])
self.cli_commit()

n = cmd_to_json(f'sudo podman network inspect {net_name}')
self.assertEqual(n['dns_enabled'], False)

def test_uid_gid(self):
cont_name = 'uid-test'
gid = '100'
Expand Down
4 changes: 4 additions & 0 deletions src/conf_mode/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ def generate(container):
'driver': 'host-local'
}
}

if 'no_name_server' in network_config:
tmp['dns_enabled'] = False

for prefix in network_config['prefix']:
net = {'subnet': prefix, 'gateway': inc_ip(prefix, 1)}
tmp['subnets'].append(net)
Expand Down

0 comments on commit 1d5625d

Please sign in to comment.