summaryrefslogtreecommitdiff
path: root/src/conf_mode/host_name.py
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2019-02-22 11:05:10 -0800
committerhagbard <vyosdev@derith.de>2019-02-22 11:06:05 -0800
commit116b8d2d821daa4e804249bd109819003dd9ef3d (patch)
tree49e4a6b1230cf11dfc0a5eae5b73f79b73b73f80 /src/conf_mode/host_name.py
parent57e4b8475188641e5f1698a5fd9db15ba8b7f15f (diff)
downloadvyos-1x-116b8d2d821daa4e804249bd109819003dd9ef3d.tar.gz
vyos-1x-116b8d2d821daa4e804249bd109819003dd9ef3d.zip
Fixes: T1262 - dhcp requested WAN ip address doesn't get search parameter in /etc/resolv.conf
Diffstat (limited to 'src/conf_mode/host_name.py')
-rwxr-xr-xsrc/conf_mode/host_name.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py
index 6886324f2..486d1ec8f 100755
--- a/src/conf_mode/host_name.py
+++ b/src/conf_mode/host_name.py
@@ -86,6 +86,18 @@ def get_resolvers(file):
except IOError:
return []
+def get_dhcp_search_doms(file):
+ search_doms = []
+ try:
+ with open(file, 'r') as resolvconf:
+ for line in resolvconf.readlines():
+ line = line.split('#',1)[0];
+ line = line.rstrip();
+ if 'search' in line:
+ return re.sub('^search','',line).lstrip().split()
+ except IOError:
+ return []
+
default_config_data = {
'hostname': 'vyos',
'domain_name': '',
@@ -174,6 +186,8 @@ def generate(config):
if not config['no_dhcp_ns']:
config['nameserver'] += dhcp_ns
+ for file in glob.glob('/etc/resolv.conf.dhclient-new*'):
+ config['domain_search'] = get_dhcp_search_doms(file)
# We have third party scripts altering /etc/hosts, too.
# One example are the DHCP hostname update scripts thus we need to cache in
@@ -204,6 +218,7 @@ def generate(config):
tmpl = jinja2.Template(config_tmpl_resolv)
config_text = tmpl.render(config)
+ print (config_text)
with open(config_file_resolv, 'w') as f:
f.write(config_text)