From abc4650ae8cc6cad453f23aaeca3a35970138899 Mon Sep 17 00:00:00 2001 From: Shapes0 <63262012+Shapes0@users.noreply.github.com> Date: Sat, 1 Jun 2024 19:53:30 -0500 Subject: [PATCH] Add GUI options for resolv.conf DNS client config --- src/etc/inc/system.inc | 4 ++++ .../pfSense/include/www/system_advanced_network.inc | 10 ++++++++++ src/usr/local/www/system_advanced_network.php | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index df215002200..83593258aae 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -240,6 +240,10 @@ function system_resolvconf_generate($dynupdate = false) { $resolvconf .= "options edns0\n"; } + if (!empty(config_get_path('system/resolvconf_custom_options'))) { + $resolvconf .= base64_decode(config_get_path('system/resolvconf_custom_options', "")); + } + $dnslock = lock('resolvconf', LOCK_EX); $fd = fopen("{$g['etc_path']}/resolv.conf", "w"); diff --git a/src/usr/local/pfSense/include/www/system_advanced_network.inc b/src/usr/local/pfSense/include/www/system_advanced_network.inc index c9583b9b566..a4c439e7efb 100644 --- a/src/usr/local/pfSense/include/www/system_advanced_network.inc +++ b/src/usr/local/pfSense/include/www/system_advanced_network.inc @@ -40,6 +40,7 @@ function getAdvancedNetwork($json = false) { $pconfig['sharednet'] = config_path_enabled('system', 'sharednet') ? config_get_path('system/sharednet') : null; $pconfig['disablechecksumoffloading'] = config_path_enabled('system', 'disablechecksumoffloading'); $pconfig['ip_change_kill_states'] = config_path_enabled('system', 'ip_change_kill_states') ? config_get_path('system/ip_change_kill_states') : null; + $pconfig['resolvconf_custom_options'] = base64_decode(config_get_path('system/resolvconf_custom_options', "")); $pconfig['hnaltqenable'] = config_path_enabled('system', 'hn_altq_enable'); $pconfig['disablechecksumoffloading'] = config_path_enabled('system', 'disablechecksumoffloading'); $pconfig['disablesegmentationoffloading'] = config_path_enabled('system', 'disablesegmentationoffloading'); @@ -222,6 +223,13 @@ function saveAdvancedNetworking($post, $json = false) { config_del_path('system/ip_change_kill_states'); } + if (!empty(trim($post['resolvconf_custom_options']))) { + $resolvconf_custom_options_source = str_replace("\r\n", "\n", trim($post['resolvconf_custom_options'])); + config_set_path('system/resolvconf_custom_options', base64_encode($resolvconf_custom_options_source)); + } else { + config_del_path('system/resolvconf_custom_options'); + } + setup_microcode(); // Write out configuration (config.xml) @@ -240,6 +248,8 @@ function saveAdvancedNetworking($post, $json = false) { $retval = 0; $retval |= filter_configure(); + system_resolvconf_generate(); + if ($syslogrestart) { system_syslogd_start(); } diff --git a/src/usr/local/www/system_advanced_network.php b/src/usr/local/www/system_advanced_network.php index a878c2a1471..2176db705ff 100644 --- a/src/usr/local/www/system_advanced_network.php +++ b/src/usr/local/www/system_advanced_network.php @@ -319,6 +319,16 @@ ))->setHelp('This option resets all states when a WAN IP Address changes instead of only '. 'states associated with the previous IP Address.'); +$form->add($section); + +$section = new Form_Section('DNS Client Configuration'); + +$section->addInput(new Form_Textarea( + 'resolvconf_custom_options', + 'resolv.conf custom options', + $pconfig['resolvconf_custom_options'] +))->setHelp('Enter any additional options to add to the /etc/resolv.conf configuration here.'); + $form->add($section); print $form; ?>