Hi all.
Can someone point me in the right direction on what to send to port 1700 for the radius incoming so I can disconnect a user?
I cant find a lot of information on the MikroTik website.
Thanks, Jeremy
$cmd = "echo NAS-IP-Address=$nasip,User-Name=$macaddr,Framed-IP-Address=$framedip,Acct-Sess
ion-Id=$sessid | /usr/local/bin/radclient $nasip:1700 disconnect somesecret";
exec($cmd);
#!/usr/local/bin/php -q
<?php
if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
This will search the radacct table for a mac address and disconnect the user from the appropiate NAS.
example: <? print $_SERVER['PHP_SELF']; ?> 00:00:00:00:00:00
<?php
} else {
$macaddr = $argv[1];
// Let's try and connect up to the database....
$link = mysql_connect("localhost", "dbusername", "dbpassword");
if (!$link) {
die('Could not connect: ' . mysql_error());
echo 'Error connecting to mysql';
}
mysql_select_db("database") or die(mysql_error());
$query = "SELECT * FROM `radacct` WHERE `UserName` LIKE '$macaddr' ORDER BY `RadAcctId` DESC LIMIT 0,1";
$result=mysql_query($query);
$num=mysql_numrows($result);
//Close out mysql connection!
mysql_close($link);
$i=0;
while ($i < $num) {
//All our variables from our query.
$RadAcctId=mysql_result($result,$i,"RadAcctId");
$AcctSessionId=mysql_result($result,$i,"AcctSessionId");
$AcctUniqueId=mysql_result($result,$i,"AcctUniqueId");
$UserName=mysql_result($result,$i,"UserName");
$Realm=mysql_result($result,$i,"Realm");
$NASIPAddress=mysql_result($result,$i,"NASIPAddress");
$NASPortId=mysql_result($result,$i,"NASPortId");
$AcctStartTime=mysql_result($result,$i,"AcctStartTime");
$AcctStopTime=mysql_result($result,$i,"AcctStopTime");
$AcctSessionTime=mysql_result($result,$i,"AcctSessionTime");
$AcctAuthentic=mysql_result($result,$i,"AcctAuthentic");
$ConnectInfo_start=mysql_result($result,$i,"ConnectInfo_start");
$ConnectInfo_stop=mysql_result($result,$i,"ConnectInfo_stop");
$AcctInputOctets=mysql_result($result,$i,"AcctInputOctets");
$AcctOutputOctets=mysql_result($result,$i,"AcctOutputOctets");
$CalledStationId=mysql_result($result,$i,"CalledStationId");
$CallingStationId=mysql_result($result,$i,"CallingStationId");
$AcctTerminateCause=mysql_result($result,$i,"AcctTerminateCause");
$ServiceType=mysql_result($result,$i,"ServiceType");
$FramedProtocol=mysql_result($result,$i,"FramedProtocol");
$FramedIPAddress=mysql_result($result,$i,"FramedIPAddress");
$AcctStartDelay=mysql_result($result,$i,"AcctStartDelay");
$AcctStopDelay=mysql_result($result,$i,"AcctStopDelay");
// The 4 lines below are commented out as they were for debugging.
// echo "Username: $UserName\n";
// echo "Client IP: $FramedIPAddress\n";
// echo "NAS IP Address: $NASIPAddress\n";
// echo "AcctSessionId: $AcctSessionId\n";
// This is the command we will pass on for php to execute
$cmd = "echo NAS-IP-Address=$NASIPAddress,User-Name=$UserName,Framed-IP-Address=$FramedIPAddress,Acct-Session-Id=$AcctSessionId | /usr/local/bin/radclient $NASIPAddress:1700 disconnect SomeSecret";
// Let's actually execute the command now
exec($cmd);
$i++;
}
}
?>