Someone helped me with a pfSense php script that allowed the changing of 2 DHCP assigned DNS servers for my LAN interface. It doesn't work with OPNsense. One thing I saw was file mentioned at top didn't exist, but even switching it to /conf/config.xml didn't work. There must be some other edits needed to get this to work. Anyone know how? Thanks.
require_once '/etc/inc/config.inc';
global $config;
$interface = "lan";
$dnsfoo = "192.168.1.1";
$dnsbar = "1.1.1.1";
if (!is_array($config["dhcpd"])) {
$config["dhcpd"] = [];
}
if (!is_array($config["dhcpd"][$interface])) {
$config["dhcpd"][$interface] = [];
}
// empty the current values
$config["dhcpd"][$interface]["dnsserver"] = [];
// add new values to the list
$config["dhcpd"][$interface]["dnsserver"][] = $dnsfoo;
$config["dhcpd"][$interface]["dnsserver"][] = $dnsbar;
write_config("Change DHCP globally assigned DNS");
// reload services, etc here as necessary
$toreturn = [
"data" => true,
];