3 # Save DNS client configuration
5 require './net-lib.pl';
6 $access{'dns'} == 2 || &error($text{'dns_ecannot'});
7 &error_setup($text{'dns_err'});
9 $old_hostname = &get_system_hostname();
11 $in{'hostname'} =~ /^[A-z0-9\.\-]+$/ ||
12 &error(&text('dns_ehost', $in{'hostname'}));
14 for($i=0; defined($ns = $in{"nameserver_$i"}); $i++) {
15 $ns = $in{"nameserver_$i"};
16 $ns =~ s/^\s+//; $ns =~ s/\s+$//;
18 &check_ipaddress_any($ns) ||
19 &error(&text('dns_ens', $ns));
20 push(@{$dns->{'nameserver'}}, $ns);
26 while ($in{$namekey}) {
27 $dns->{'name'}[$i] = $in{$namekey};
28 my $nskey = "nameserver$i";
30 while (++$j < $max_dns_servers) {
31 $ns = $in{"${nskey}_$j"};
32 $ns =~ s/^\s+//; $ns =~ s/\s+$//;
34 &check_ipaddress_any($ns) ||
35 &error(&text('dns_ens', $ns));
36 push(@{$dns->{$nskey}}, $ns);
43 if (!$in{'domain_def'}) {
44 @dlist = split(/\s+/, $in{'domain'});
46 $d =~ /^[A-z0-9\.\-]+$/ ||
47 &error(&text('dns_edomain', $d));
48 push(@{$dns->{'domain'}}, $d);
50 @dlist>0 || &error($text{'dns_esearch'});
53 &save_dns_config($dns);
54 &save_hostname($in{'hostname'});
56 if ($in{'hosts'} && $in{'hostname'} ne $old_hostname) {
57 # Update hostname in /etc/hosts too
58 @hosts = &list_hosts();
61 foreach $n (@{$h->{'hosts'}}) {
62 if (lc($n) eq lc($old_hostname)) {
67 &modify_host($h) if ($found);
70 # Update in ipnodes too
71 @ipnodes = &list_ipnodes();
72 foreach $h (@ipnodes) {
74 foreach $n (@{$h->{'ipnodes'}}) {
75 if (lc($n) eq lc($old_hostname)) {
80 &modify_ipnode($h) if ($found);
84 &webmin_log("dns", undef, undef, \%in);