push(@{$v6cfg->{'netmask6'}}, $3);
}
}
+ if ($method eq "manual" && !@{$v6cfg->{'address6'}}) {
+ $v6cfg->{'auto6'} = 1;
+ }
$v6map{$name} = $v6cfg;
}
}
my @options6;
my @address6 = @{$cfg->{'address6'}};
my @netmask6 = @{$cfg->{'netmask6'}};
-if (@address6) {
+if (@address6 || $cfg->{'auto6'}) {
push(@options6, ['pre-up', '/sbin/modprobe -q ipv6 ; /bin/true']);
}
if (@address6) {
push(@options6, [ "up","ifconfig $cfg->{'fullname'} inet6 add $a/$n" ]);
}
-if (!$found6 && @{$cfg->{'address6'}}) {
+# Add, update or delete IPv6 inteface
+my $method = $cfg->{'auto6'} ? "manual" : "static";
+if (!$found6 && @options6) {
# Need to add IPv6 block
&new_interface_def($cfg->{'fullname'},
- 'inet6', 'static', \@options6);
+ 'inet6', $method, \@options6);
}
-elsif ($found6 && @{$cfg->{'address6'}}) {
+elsif ($found6 && @options6) {
# Need to update IPv6 block
&modify_interface_def($cfg->{'fullname'},
- 'inet6', 'static', \@options6, 0);
+ 'inet6', $method, \@options6, 0);
}
-elsif ($found6 && !@{$cfg->{'address6'}}) {
+elsif ($found6 && !@options6) {
# Need to delete IPv6 block
&delete_interface_def($cfg->{'fullname'}, 'inet6');
}
$b->{'netmask6'}->[$i] || 64, 10) ]);
}
$table6 .= &ui_columns_end();
- print &ui_table_row($text{'ifcs_mode6'}, $table6, 3);
+ print &ui_table_row($text{'ifcs_mode6'},
+ &ui_radio_table("mode6", $b->{'auto6'} ? "auto" : "address",
+ [ [ "auto", $text{'ifcs_auto6'} ],
+ [ "address", $text{'ifcs_static2'}, $table6 ] ]));
}
# MTU
ifcs_act=Activate
ifcs_bootp=From BOOTP
ifcs_dhcp=From DHCP
+ifcs_auto6=From IPv6 discovery
ifcs_broad=Broadcast
ifcs_auto=Automatic
ifcs_mtu=MTU
ifcs_range=Range $1
ifcs_static2=Static configuration
ifcs_mode=IPv4 address
-ifcs_mode6=Static IPv6 addresses
+ifcs_mode6=IPv6 addresses
ifcs_address6=IPv6 address
ifcs_netmask6=Netmask
ifcs_mode6a=IPv6 addresses
push(@cols, $a->{'netmask'} ? &html_escape($a->{'netmask'})
: $text{'ifcs_auto'});
if (&supports_address6()) {
- push(@cols, join("<br>\n", map { &html_escape($_) }
+ push(@cols, $a->{'auto6'} ? $text{'ifcs_auto6'} :
+ join("<br>\n", map { &html_escape($_) }
@{$a->{'address6'}}));
}
}
if ($conf{'IPV6ADDR'});
push(@ip6s, map { [ split(/\//, $_) ] }
split(/\s+/, $conf{'IPV6ADDR_SECONDARIES'}));
- $b->{'address6'} = [ map { $_->[0] } @ip6s ];
- $b->{'netmask6'} = [ map { $_->[1] } @ip6s ];
+ if (@ip6s) {
+ # Static IPv6 addresses
+ $b->{'address6'} = [ map { $_->[0] } @ip6s ];
+ $b->{'netmask6'} = [ map { $_->[1] } @ip6s ];
+ }
+ elsif ($conf{'IPV6INIT'}) {
+ $b->{'auto6'} = 1;
+ }
$b->{'edit'} = ($b->{'name'} !~ /^ppp|irlan/);
$b->{'desc'} = $conf{'NAME'};
$b->{'index'} = scalar(@rv);
push(@ip6s, $b->{'address6'}->[$i]."/".
$b->{'netmask6'}->[$i]);
}
- if (@ip6s && lc($conf{'IPV6INIT'}) ne 'yes') {
+ if ((@ip6s || $b->{'auto6'}) && lc($conf{'IPV6INIT'}) ne 'yes') {
$conf{'IPV6INIT'} = 'yes';
}
- $conf{'IPV6ADDR'} = shift(@ip6s);
- $conf{'IPV6ADDR_SECONDARIES'} = join(" ", @ip6s);
+ if (@ip6s) {
+ $conf{'IPV6ADDR'} = shift(@ip6s);
+ $conf{'IPV6ADDR_SECONDARIES'} = join(" ", @ip6s);
+ }
}
$conf{'NAME'} = $_[0]->{'desc'};
&write_env_file("$net_scripts_dir/ifcfg-$name", \%conf);
}
# Save IPv6 addresses
- if (&supports_address6($b) && defined($in{'address6_0'})) {
+ if (&supports_address6($b) && $in{'mode6'} eq 'auto') {
+ # Dynamic configuration
+ delete($b->{'address6'});
+ delete($b->{'netmask6'});
+ $b->{'auto6'} = 1;
+ }
+ elsif (&supports_address6($b) && $in{'mode6'} eq 'address') {
+ # Static addresses
@address6 = ( );
@netmask6 = ( );
%clash6 = ( );
push(@netmask6, $in{'netmask6_'.$i});
$clash6{$in{'address6_'.$i}} = $b;
}
+ delete($b->{'auto6'});
$b->{'address6'} = \@address6;
$b->{'netmask6'} = \@netmask6;
}
$ifc{'dhcp'}++;
}
$ifc{'up'}++;
+ if (open(FILE6, "$etc/hostname6\.$ifc{'fullname'}")) {
+ # Also has an IPv6 address
+ local $address6 = <FILE6>;
+ chop($address6);
+ close(FILE6);
+ if ($address6) {
+ local $netmask6;
+ ($address6, $netmask6) = split(/\//, $address6);
+ $netmask6 ||= 64;
+ $ifc{'address6'} = [ $address6 ];
+ $ifc{'netmask6'} = [ $netmask6 ];
+ }
+ else {
+ $ifc{'auto6'} = 1;
+ }
+ }
push(@rv, \%ifc);
}
}
&print_tempfile(IFACE, $_[0]->{'address'},"\n");
}
&close_tempfile(IFACE);
+if (@{$_[0]->{'address6'}} || $_[0]->{'auto6'}) {
+ &open_lock_tempfile(IFACE6, ">/etc/hostname6.$name");
+ if (!$_[0]->{'auto6'}) {
+ &print_tempfile(IFACE6, $_[0]->{'address6'}->[0],"\n");
+ }
+ &close_tempfile(IFACE6);
+ }
+else {
+ &unlink_logged("/etc/hostname6.$name");
+ }
}
# delete_interface(&details)
local $name = $_[0]->{'virtual'} ne "" ? $_[0]->{'name'}.":".$_[0]->{'virtual'}
: $_[0]->{'name'};
&unlink_logged("/etc/hostname.$name");
+&unlink_logged("/etc/hostname6.$name");
}
# iface_type(name)