FreeRADIUS 1.0 RH8 NoCat=Radius client Mysql Hi.
There are certain attributes such as the FramedIPAddress, AcctTerminateCause,service type etc, are remain empty when accounting session is started and stoped. From what I seek, the RADIUS client is not sending those attributes value.Some of the values suppose to be returned from the sql table containing the user information. By Using radius.pm (some altering done here), in the log files, there are some added attributes successfully return value in detail log file. Although trying to allow some attributes such as mention before, there are still no value appear in the radacct table and the detail file (framedipaddress for now). For Dialupadmin, there are 4 remaining table remain empty, even the accounting session is started. tables are members, baduser, totacct and mtotacct.Is it because the scripts to write the value to sql db isn't running or configuration probs in radius conf or dialup conf? Below are the RADIU.pm file that we used. _______________________________________________________ package NoCat::Accounting::RADIUS; use NoCat::Source; use Authen::Radius; use strict; use vars qw( @ISA @REQUIRED ); @ISA = qw( NoCat::Accounting ); @REQUIRED = qw( RADIUS_Host RADIUS_Secret ); sub radius { my ($self) = @_; unless ($self->{Radius}) { my $r; my $Hosts = $self->{RadiusHostsToUse}; if(! defined($Hosts)) { #This is really the first time through and I need to generate my list of servers $self->{RADIUS_Host} =~ s/,,/,/g; #just to eliminate any blank entries my(@Hosts) = split(/,/,$self->{RADIUS_Host}); if($self->{RADIUS_Order} && $self->{RADIUS_Order}) { #mix em up. my @TmpHosts; my %UsedHosts; for(my $i=0;$i <= $#Hosts; $i++) { my $TmpHost; while(! $TmpHost || ($TmpHost && $UsedHosts{$TmpHost})) { $TmpHost = $Hosts[int(rand($#Hosts + 1))]; last if ! $UsedHosts{$TmpHost}; } $UsedHosts{$TmpHost} = 1; $TmpHosts[$i] = $TmpHost; } @Hosts = @TmpHosts; } $self->{RadiusHostsToUse} = [EMAIL PROTECTED]; #List generated. } if($self->{RadiusHostsToUse}) { #go through servers one by one foreach my $Host (@{$self->{RadiusHostsToUse}}) { my $Secret = $self->{RADIUS_Secret} ? $self->{RADIUS_Secret} : ""; if($Host =~ s/\*(.*)$//) { $Secret = $1; } $self->log( 0, "Connecting to RADIUS server $Host with Timeout " . $self->{RADIUS_TimeOut} ); $r = Authen::Radius->new( Host => $Host, Secret => $Secret, Timeout => $self->{RADIUS_TimeOut}, Accounting => 1 ); last if $r; #If we have a good connection, we're done $self->log( 0, "Failed to connect to RADIUS server $Host" ); } if ($r) { # This is almost always the case... $self->{Radius} = $r; } else { $self->log( 0, "Can't connect to RADIUS server(s) $self->{RADIUS_Host}" ); } } else { return undef; #no host for them! } } return $self->{Radius}; } sub usenextserver { #If I fail, take the most recent host out and my $self = shift; return unless $self->{RadiusHostsToUse}; #unless I've been through the radius sub above, forget it my @Hosts = @{$self->{RadiusHostsToUse}}; my $popped = shift(@Hosts); #say goodbye to the first one $self->log(0, "popped $popped in usenextserver"); undef($self->{Radius}); #so radius above will get a new one. $self->{RadiusHostsToUse} = [EMAIL PROTECTED]; } sub create_session_id { my $self = shift; return $self->radius->NewSessionID(); } sub start{ my ($self, $peer, $stats) = @_; if(! $peer->session_id) { $peer->session_id($self->radius->NewSessionId()); } return $self->accounting( { Name => 1, Value => $peer->user, Type => 'string'}, #User - Name { Name => 4, Value => $self->{GatewayAddr}, Type => 'ipaddr'}, #NAS-IP-Address { Name => 8, Type => 'ipaddr' , Value => $peer->id}, # Framed-IP-Address { Name => 31, Value => $peer->id, Type => 'string'}, #Calling-Station-Id { Name => 40, Value => '1', Type => 'integer' }, # Acct-Status-Type(Start) { Name => 40, Value => '7', Type => 'integer' }, # Acct-Status-Type(Accounting-On) { Name => 44, Value => $peer->session_id, Type => 'string'}, #Acct-Session-Id { Name => 42, Value => ${$stats}{'InOctets'}, Type => 'integer'}, #Acct-Input-Octet -These are not really legal on { Name => 43, Value => ${$stats}{'OutOctets'}, Type => 'integer'}, #Acct-Output-Octets - start, but everyone does it { Name => 5, Value => $self->{GatewayPort}, Type => 'integer'}, #NAS-Port { Name => 14, Value => $peer->id, Type => 'ipaddr'}, #Login-IP-Host { Name => 32, Value => $peer->{GatewayAddr}, Type => 'string'}, #NAS Identifier { Name => 45, Value => 'RADIUS', Type => 'integer'} #Acct-Authentic ); } sub stop { my ($self, $peer, $stats) = @_; return $self->accounting( { Name => 1, Value => $peer->user, Type => 'string'}, #User - Name { Name => 4, Value => $self->{GatewayAddr}, Type => 'ipaddr'}, #NAS-IP-Address { Name => 31, Value => $peer->id, Type => 'string'}, #Calling-Station-Id { Name => 40, Value => '2', Type => 'integer' }, # Acct-Status-Type(Stop) { Name => 40, Value => '8', Type => 'integer' }, # Acct-Status-Type(Accounting-Off) { Name => 44, Value => $peer->session_id, Type => 'string'}, #Acct-Session-Id { Name => 42, Value => ${$stats}{'InOctets'}, Type => 'integer'}, #Acct-Input-Octet -These are not really legal on { Name => 43, Value => ${$stats}{'OutOctets'}, Type => 'integer'}, #Acct-Output-Octets - start, but everyone does it { Name => 46, Value => $peer->session_time, Type => 'integer'}, # Acct-Session-Time { Name => 5, Value => $self->{GatewayPort}, Type => 'integer'}, #NAS-Port { Name => 14, Value => $peer->id, Type => 'ipaddr'}, #Login-IP-Host { Name => 32, Value => $peer->{GatewayAddr}, Type => 'string'}, #NAS Identifier { Name => 45, Value => 'RADIUS', Type => 'integer'} #Acct-Authentic ); } sub update { my ($self, $peer, $stats) = @_; return $self->accounting( { Name => 1, Value => $peer->user, Type => 'string'}, #User - Name { Name => 4, Value => $self->{GatewayAddr}, Type => 'ipaddr'}, #NAS-IP-Address { Name => 31, Value => $peer->id, Type => 'string'}, #Calling-Station-Id { Name => 40, Value => '3', Type => 'integer' }, # Acct-Status-Type(Update) { Name => 44, Value => $peer->session_id, Type => 'string'}, #Acct-Session-Id { Name => 42, Value => ${$stats}{'InOctets'}, Type => 'integer'}, #Acct-Input-Octet -These are not really legal on { Name => 43, Value => ${$stats}{'OutOctets'}, Type => 'integer'}, #Acct-Output-Octets - start, but everyone does it { Name => 5, Value => $self->{GatewayPort}, Type => 'integer'}, #NAS-Port { Name => 14, Value => $peer->id, Type => 'ipaddr'}, #Login-IP-Host { Name => 32, Value => $peer->{GatewayAddr}, Type => 'string'}, #NAS Identifier { Name => 45, Value => 'RADIUS', Type => 'integer'} #Acct-Authentic ); } sub accounting { my ($self, @attributes) = @_; my $result; my $loop = 0; while(! $loop) { my $radius = $self->radius(); # mimic the start_acct from Authen::Radius $radius->clear_attributes; $radius->add_attributes(@attributes); my $radiuscheckok = 0; if($radius->send_packet (Authen::Radius::ACCOUNTING_REQUEST())) { my $radiusresult = $radius->recv_packet; if(defined($radiusresult)) { $radiuscheckok = 1; } } if(! $radiuscheckok) { my(@TmpHosts) = @{$self->{RadiusHostsToUse}}; if(! $#TmpHosts) { #it failed because we've run out of servers $loop = 1; $result = 0; $self->log(0,"Out of servers to try"); } else { $self->log(0,"Going to the next server: check the secret/port/reachability of this one"); $self->usenextserver; } } else { $loop = 1; } } return $result; } _______________________________________________________ Thanks in advanced for any help. Any extra info needed please do inform me. __________________________________ Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! http://my.yahoo.com - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html