diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-06-26 16:34:42 +0000 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-06-26 16:34:42 +0000 |
commit | d58ea68e07ac987e642947ceabe3dd87ecdb22ad (patch) | |
tree | 17f6587ac5a7d045dd7473adee2a53b8edb565e3 /scripts | |
parent | 3f41fcca673762ff27328192036719eace6b6495 (diff) | |
download | vyatta-cfg-d58ea68e07ac987e642947ceabe3dd87ecdb22ad.tar.gz vyatta-cfg-d58ea68e07ac987e642947ceabe3dd87ecdb22ad.zip |
=> Modified VyattaConfig.pm function 'returnOrigValues()' to return empty array when no value is configured
=> Modified VyattaConfigLoad.pm to give a higher ranking to 'system host-name' than 'interface' so that during boot-up
if host is using dhcp client to get an ip for an interface, it can send the host-name if configured
=> Modified vyatta-interfaces.pl:
1. to request only for dhcp options 'subnet-nask', 'broadcast address', 'routers', 'domain-name-servers'
when an interface is configured to get an ip using dhcp.
2. ask for a domain-name only if domain-name is not configured in our CLI
3. do not request dhcp options: 'time-offset', 'interface-mtu' and 'host-name' that were being requested before
4. Update /etc/resolv.conf to remove domain-name and name-server options received from dhcp server for the
particular interface that releases dhcp lease either from op-mode or cfg-mode
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/VyattaConfig.pm | 5 | ||||
-rwxr-xr-x | scripts/VyattaConfigLoad.pm | 1 | ||||
-rw-r--r-- | scripts/vyatta-interfaces.pl | 27 |
3 files changed, 27 insertions, 6 deletions
diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm index 941bb63..9ddc8ef 100755 --- a/scripts/VyattaConfig.pm +++ b/scripts/VyattaConfig.pm @@ -262,7 +262,10 @@ sub returnValues { # node is relative sub returnOrigValues { my $val = returnOrigValue(@_); - my @values = split("\n", $val); + my @values = (); + if (defined($val)) { + @values = split("\n", $val); + } return @values; } diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 1a7f26e..71203be 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -32,6 +32,7 @@ my %config_rank = ( 'qos-policy' => 1100, 'firewall' => 1020, 'service nat' => 1010, + 'system host-name' => 1005, 'interfaces' => 1000, 'interfaces bridge' => 990, 'interfaces ethernet' => 980, diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 1511c12..5424b64 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -111,9 +111,6 @@ sub dhcp_conf_header { my $date = `date`; chomp $date; $output = "#\n# autogenerated by vyatta-interfaces.pl on $date\n#\n"; - $output .= "request subnet-mask, broadcast-address, time-offset, routers,\n"; - $output .= "\tdomain-name, domain-name-servers, host-name,\n"; - $output .= "\tinterface-mtu;\n\n"; return $output; } @@ -179,6 +176,15 @@ sub get_hostname { return $hostname; } +sub is_domain_name_set { + my $config = new VyattaConfig; + $config->setLevel("system"); + my $domainname = undef; + $domainname = $config->returnValue("domain-name"); + return $domainname; +} + + sub dhcp_update_config { my ($conf_file, $intf) = @_; @@ -189,6 +195,14 @@ sub dhcp_update_config { if (defined($hostname)) { $output .= "\tsend host-name \"$hostname\";\n"; } + $output .= "\trequest subnet-mask, broadcast-address, routers, domain-name-servers"; + my $domainname = is_domain_name_set(); + if (!defined($domainname)) { + $output .= ", domain-name;\n"; + } else { + $output .= ";\n"; + } + $output .= "}\n\n"; dhcp_write_file($conf_file, $output); @@ -240,10 +254,13 @@ sub run_dhclient { sub stop_dhclient { my $intf = shift; + my $new_resolv_conf = "/etc/resolv.conf.dhclient-new-$intf"; my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = generate_dhclient_intf_files($intf); - my $cmd = "$dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null"; - system ($cmd); + my $release_cmd = "$dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null"; + system ($release_cmd); + my $update_resolv_conf_cmd = "rm -f $new_resolv_conf; echo \" \" > $new_resolv_conf; /opt/vyatta/sbin/vyatta_update_resolv.pl --dhclient-script 1"; + system($update_resolv_conf_cmd); system ("rm -f $intf_config_file"); } |