<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ServerAdminBlog &#187; Networks</title>
	<atom:link href="http://www.serveradminblog.com/category/networks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serveradminblog.com</link>
	<description>Short Circuit...</description>
	<lastBuildDate>Sat, 04 Feb 2012 16:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dia &#8211; diagram creation program</title>
		<link>http://www.serveradminblog.com/2012/01/dia-diagram-creation-program/</link>
		<comments>http://www.serveradminblog.com/2012/01/dia-diagram-creation-program/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 13:01:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networks]]></category>
		<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=405</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2012/01/dia-diagram-creation-program/' addthis:title='Dia &#8211; diagram creation program '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>In case you need to draw a diagram from time to time, you should think about Dia. Dia is a GTK+ based diagram creation program for GNU/Linux, MacOS X, Unix, and Windows, and is released under the GPL license. It is a very nice replacement for Visio which is commercial product. It can be used [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2012/01/dia-diagram-creation-program/' addthis:title='Dia &#8211; diagram creation program '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>In case you need to draw a diagram from time to time, you should think about Dia. Dia is a GTK+ based diagram creation program for GNU/Linux, MacOS X, Unix, and Windows, and is released under the GPL license.</p>
<p>It is a very nice replacement for Visio which is commercial product. It can be used to draw many different kinds of diagrams. It currently has special objects to help draw entity relationship diagrams, UML diagrams, flowcharts, network diagrams, and many other diagrams. It is also possible to add support for new shapes by writing simple XML files, using a subset of SVG to draw the shape.</p>
<p>It can load and save diagrams to a custom XML format (gzipped by default, to save space), can export diagrams to a number of formats, including EPS, SVG, XFIG, WMF and PNG, and can print diagrams (including ones that span multiple pages).</p>
<p>I almost bought LanFlow for 99$ but then I found Dia <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The next step is donation to this project <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img class="size-full wp-image-408 aligncenter" title="dia" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/dia.png" alt="" width="500" height="313" /></p>
<p>Here is the link <a href="http://live.gnome.org/Dia">http://live.gnome.org/Dia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2012/01/dia-diagram-creation-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeRadius install howto (4) &#8211; populating tables</title>
		<link>http://www.serveradminblog.com/2011/12/freeradius-install-howto-4-populating-tables/</link>
		<comments>http://www.serveradminblog.com/2011/12/freeradius-install-howto-4-populating-tables/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 23:45:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Networks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=315</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/12/freeradius-install-howto-4-populating-tables/' addthis:title='FreeRadius install howto (4) &#8211; populating tables '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>In the last article about FreeRadius (Here), I wrote about basic settings and now I&#8217;ll write something about inserting users into database (MySQL). The FreeRadius database schema contains several tables: nas This table contains data about NASes (radius clients) and it is a &#8220;replacement&#8221; for clients.conf file. It is much easier to maintain the clients [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/12/freeradius-install-howto-4-populating-tables/' addthis:title='FreeRadius install howto (4) &#8211; populating tables '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>In the last article about FreeRadius (<a href="http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/">Here</a>), I wrote about basic settings and now I&#8217;ll write something about inserting users into database (MySQL).</p>
<p>The FreeRadius database schema contains several tables:</p>
<p><strong>nas</strong></p>
<p>This table contains data about NASes (radius clients) and it is a &#8220;replacement&#8221; for clients.conf file. It is much easier to maintain the clients in the database than inside config file. If you want to use database for NAS list, skip the step in the last howto (the part about clients.conf). Also, in case you want to keep your NASes in the nas table, you&#8217;ll need to uncomment the <strong>readclients = yes</strong> inside sql.conf.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">        # Set to 'yes' to read radius clients from the database ('nas' table)
        # Clients will ONLY be read on server startup.  For performance
        # and security reasons, finding clients via SQL queries CANNOT
        # be done &quot;live&quot; while the server is running.
        #
        readclients = yes</pre></div></div>

<p>As you can see from the comment, you will need to restart radiusd process to allow/disallow specific NAS.</p>
<p>nas table schema is located inside raddb/sql/mysql/nas.sql</p>
<p>To add IP 192.168.0.15 inside nas table, exec next query:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span>  nas <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'192.168.0.15'</span><span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'myNAS'</span><span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'other'</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'mysecret'</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>  <span style="color: #ff0000;">'RADIUS Client'</span>
<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>and you will have</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; select * from nas;
+----+--------------+-----------+-------+-------+----------+--------+-----------+---------------+
| id | nasname      | shortname | type  | ports | secret   | server | community | description   |
+----+--------------+-----------+-------+-------+----------+--------+-----------+---------------+
|  1 | 192.168.0.15 | myNAS     | other |  NULL | mysecret | NULL   | NULL      | RADIUS Client |
+----+--------------+-----------+-------+-------+----------+--------+-----------+---------------+
1 row in set (0.00 sec)</pre></div></div>

<p><strong>radacct</strong></p>
<p>This table is used for accounting data. In case you want to collect traffic stats, you will need to uncomment <strong>sql</strong> inside accounting {} section in <strong>/usr/local/etc/raddb/sites-available/default.</strong> The same table can be used for simultaneous use checking which is faster than radutmp. All you need to do is to uncomment <strong>sql</strong> inside session {} section inside <strong>/usr/local/etc/raddb/sites-available/default </strong>and uncomment <strong>simul_count_query</strong> inside <strong>/usr/local/etc/raddb/sql/mysql/dialup.conf</strong></p>
<p><strong>radcheck</strong></p>
<p>This table keeps the check attributes for users (User-Password, Cleartext-Password, Expiration, Simultaneous-Use, Auth-Type, &#8230;)</p>
<p><strong>radreply</strong></p>
<p>Is used for reply attributes for specific user. For example Framed-IP-Address, upload and download speed, etc&#8230;</p>
<p><strong>radgroupcheck</strong></p>
<p>This table keeps the check attributes for groups (which means, all users inside specific group will be checked against this attributes).</p>
<p><strong>radgroupreply</strong></p>
<p>The same like radreply but for groups. (all users in specific group will get the same speed, etc). Also, Framed-Pool attribute goes here.</p>
<p><strong>radpostauth</strong></p>
<p>This table is used for logging failed login attempts. To use this, you&#8217;ll need to uncomment sql inside postauth section (<strong>/usr/local/etc/raddb/sites-available/default.</strong>). Think twice before you enable this option because it can overload your server with constant inserts. Your customers will probably spend their money on wireless or wired routers so the logging attempts will come over and over.</p>
<p><strong>radusergroup</strong></p>
<p>This table keeps relation between username and specific group and group priority. In Freeradius 1.x this table was named &#8220;<strong>usergroup</strong>&#8221; so in case you have your own billing which is made for old schema, rename this table to <strong>usergroup</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">        # Table to keep group info
        usergroup_table = &quot;radusergroup&quot;</pre></div></div>

<p>Examples</p>
<p>We will create a sample service with the next attributes:<br />
- 512kbps download speed<br />
- 128kbps upload speed<br />
- we will use PPPoE – Point to Point Protocol Over Ethernet<br />
- we will assign dynamic IP addresses to our clients from &#8220;internet&#8221; IP pool</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radgroupreply`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`groupname`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testservice'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Ascend-Xmit-Rate'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'524288'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testservice'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Ascend-Data-Rate'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'131072'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testservice'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Framed-Pool'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'internet'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>As you can see the speed is converted to bps.</p>
<p><img src="http://www.serveradminblog.com/wp-content/uploads/2011/12/kreiranje-paketa.png" alt="" title="service" width="296" height="101" class="alignnone size-full wp-image-392" /></p>
<p>After you created the service, lets create a sample user (assigned with created service).</p>
<p>As I noticed above, check attributes should be placed inside radcheck table.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radcheck`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`username`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'User-Password'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testpassword'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Simultaneous-Use'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>In this sample, the password is in plain text format which is not reccommended. Insted User-Password (which is alternative to Cleartext-Password for Mikrotik) better option is to use MD5-Password but keep in mind that you won&#8217;t be able to use CHAP.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radcheck`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`username`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'MD5-Password'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> MD5<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'testpassword'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> 
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Simultaneous-Use'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><img src="http://www.serveradminblog.com/wp-content/uploads/2011/12/kreiranje-korisnika.png" alt="" title="kreiranje-korisnika" width="461" height="79" class="alignnone size-full wp-image-394" /></p>
<p>Then we need to assign this user with created service (group)</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radusergroup`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`username`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`groupname`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`priority`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testservice'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><img src="http://www.serveradminblog.com/wp-content/uploads/2011/12/uparivanje-korisnika.png" alt="" title="uparivanje-korisnika" width="215" height="48" class="alignnone size-full wp-image-396" /></p>
<p>After those inserts, lets test</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@ns2 raddb]# radtest testuser testpassword 127.0.0.1 0 testing123
Sending Access-Request of id 228 to 127.0.0.1 port 1812
        User-Name = &quot;testuser&quot;
        User-Password = &quot;testpassword&quot;
        NAS-IP-Address = 192.168.0.10
        NAS-Port = 0
        Message-Authenticator = 0x00000000000000000000000000000000
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=228, length=54
        Ascend-Xmit-Rate = 524288
        Ascend-Data-Rate = 131072
        Framed-Pool = &quot;internet&quot;
[root@ns2 raddb]#</pre></div></div>

<p>As you can see, the username/password combination is valid and RADIUS server returned all attributes assigned with user&#8217;s group. </p>
<p>To suspend user&#8217;s account you can insert Auth-Type := Reject for user.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radcheck`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`username`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testuser'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Auth-Type'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Reject'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>and we have</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@ns2 raddb]# radtest testuser testpassword 127.0.0.1 0 testing123
.....
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=145, length=20</pre></div></div>

<p>Another option for disabling users is assigning with specific group which has Auth-Type := Reject inside radgroupcheck</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radgroupcheck`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`groupname`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'suspended'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Auth-Type'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Reject'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Assigning with suspended group can be done with</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`radusergroup`</span> 
<span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`groupname`</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'suspended'</span> 
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`username`</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'testuser'</span> 
<span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #ff0000;">`priority`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>;</pre></div></div>

<p><img src="http://www.serveradminblog.com/wp-content/uploads/2011/12/reject-grupe.png" alt="" title="reject-grupe" width="249" height="51" class="alignnone size-full wp-image-397" /></p>
<p>and we have</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=198, length=20</pre></div></div>

<p>Also, keep in mind that routers will try to connect again and again so you will have a big problems in case you have thousands of users. Another option is to assign users with specific group which doesn&#8217;t have Auth-Type attribute. Instead rejecting you can assign internal IPs and redirect them to suspended page.</p>
<p>Many questions on FreeRadius mailing list are about Simultaneus-Use. Solution to this problem is very simple and it is very rude to ask this question again and again&#8230; </p>
<p>All you need to do is to insert Simultaneous-Use := 1 for specific user (radcheck table) or inside radgroupcheck if you want to limit all users inside specific group.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`radgroupcheck`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`groupname`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`attribute`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`op`</span> <span style="color: #66cc66;">,</span><span style="color: #ff0000;">`value`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'testservice'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Simultaneous-Use'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">':='</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>In case you want to set Expiration attribute you can insert the date and the time inside radcheck table.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">INSERT INTO `radcheck` (`id` ,`username` ,`attribute` ,`op` ,`value` )
VALUES (NULL , 'testuser', 'Expiration', '==', 'November 30 2011 00:00:00');</pre></div></div>

<p>then we have</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@ns2 raddb]# radtest testuser testpassword 127.0.0.1 0 testing123
Sending Access-Request of id 28 to 127.0.0.1 port 1812
        User-Name = &quot;testuser&quot;
        User-Password = &quot;testpassword&quot;
        NAS-IP-Address = 192.168.0.10
        NAS-Port = 0
        Message-Authenticator = 0x00000000000000000000000000000000
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=28, length=60
        Ascend-Xmit-Rate = 524288
        Ascend-Data-Rate = 131072
        Framed-Pool = &quot;internet&quot;
        Session-Timeout = 670889</pre></div></div>

<p>You can note Session-Timeout attribute which contains the time in seconds between this moment and the date inside Expiration field. According to this value, the NAS will auto disconnect user when this time expire (in our case 670889 seconds). In case you set the time which already passed (for example yesterdays date) the user will be rejected. </p>
<p><strong>Please keep in mind that this date format works for Mikrotik. I didn&#8217;t have chance to test it with other NASes.</strong> </p>
<p>If you want to reconnect users at regular intervals (for example every 24 hours &#8211; 86400 seconds) you can insert Session-Timeout inside radreply table (because it isn&#8217;t check attribute).<br />
To recconect every user inside specific group, add this attribute inside radgroupreply table. </p>
<p>To assign a static IP for specific user insert Framed-IP-Address attribute inside radreply table where Value will be that IP address. Operator should be :=. </p>
<p>Please keep in mind that all inserts inside those tables are visible to radius server right after insert. Only inserts inside nas table won&#8217;t be until the restart (service radiusd restart)</p>
<p>I hope this post will help you to set up your own RADIUS server. Also, keep in mind that this is just an example and all this can done in many other ways. </p>
<p>In case you find a spelling errors please contact me so I can fix them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/12/freeradius-install-howto-4-populating-tables/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>FreeRadius install howto (3)</title>
		<link>http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/</link>
		<comments>http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 15:14:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[Networks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=281</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/' addthis:title='FreeRadius install howto (3) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>In this post I will say something about FreeRadius config files, database connection, basic instruction how to insert user in database, etc. Before you step inside this post, I recommend reading part 1 and part 2. I suppose you&#8217;re using RH based distros (Red Hat, CentOS, Fedora,..) and you already installed FreeRadius from source (config [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/' addthis:title='FreeRadius install howto (3) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>In this post I will say something about FreeRadius config files, database connection, basic instruction how to insert user in database, etc. Before you step inside this post, I recommend reading <a href="http://www.serveradminblog.com/2011/01/freeradius-howto-part-1/">part 1</a> and <a href="http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/">part 2</a>. </p>
<p>I suppose you&#8217;re using RH based distros (Red Hat, CentOS, Fedora,..) and you already installed FreeRadius from source (config files are located in /usr/local/etc/raddb/). Now lets get back to FreeRadius source dir (the place where you extracted the tar.gz).</p>
<p>Inside redhat dir you can find <em>freeradius-radiusd-init</em> script which can be used for easy start/stop radiusd process. Copy this script to /etc/init.d/ dir</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># cp freeradius-radiusd-init /etc/init.d/radiusd</pre></div></div>

<p>Now open /etc/init.d/radiusd script and change the next lines</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">exec=${exec:=/usr/sbin/$prog}
config_dir=${config_dir:=/etc/raddb}
config=${config:=$config_dir/radiusd.conf}
pidfile=${pidfile:=/var/run/$prog/$prog.pid}
lockfile=${lockfile:=/var/lock/subsys/radiusd}</pre></div></div>

<p>into</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">exec=${exec:=/usr/local/sbin/$prog}
config_dir=${config_dir:=/usr/local/etc/raddb}
config=${config:=$config_dir/radiusd.conf}
pidfile=${pidfile:=/usr/local/var/run/$prog/$prog.pid}
lockfile=${lockfile:=/var/lock/subsys/radiusd}</pre></div></div>

<p>Save changes and exit from editor. (Notice above that we actually changed the path from / to /usr/local/)</p>
<p>Now you can easily start/stop radiusd process.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@ms /]# service radiusd
Usage: /etc/init.d/radiusd {start|stop|status|restart|condrestart|try-restart|reload|force-reload}</pre></div></div>

<p>Also, you can exec <strong>chkconfig &#8211;level 235 radiusd on</strong> to start radiusd on boot. </p>
<p>Now lets get back to our setup. </p>
<p>I suppose you have at least one NAS (A Network Access Server (NAS) is a system that provides access to a network. In some cases also known as a Terminal Server or Remote Access Server (RAS).) NAS is a CLIENT for your radiusd server so please do not mess users and clients. Freeradius doesn&#8217;t interact with your users directly so &#8220;radius client&#8221; is another term for NAS. </p>
<p>The first step is to add your NAS to client list and to create a unique password. Inside clients.conf (/usr/local/etc/raddb/clients.conf) you can find the next lines</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#client 192.168.0.0/24 {
#       secret          = testing123-1
#       shortname       = private-network-1
#}</pre></div></div>

<p>Uncomment those lines and set up client IP address according to your addresses. In the example shown above, all IPs from 192.168.0.0/24 network will be able to use your radiusd server. </p>
<p>You can allow any IP with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">client 0.0.0.0/0 {
       secret          = mysecret
       shortname       = myNAS
}</pre></div></div>

<p>which means all IPs in the world can use my radius server (<strong>which is not recommended</strong>)&#8230; </p>
<p>To allow only one IP (in this case 192.168.0.15),</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">client 192.168.0.15 {
       secret          = mysecret
       shortname       = myNAS
}</pre></div></div>

<p>Delete <strong>user Cleartext-Password := &#8220;password&#8221;</strong> line from users because we don&#8217;t need this any more. </p>
<p>Stop radiusd and start in debugging mode (radiusd -X).</p>
<p>You should see the similar lines</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">...............
radiusd: #### Loading Clients ####
 client localhost {
        ipaddr = 127.0.0.1
        require_message_authenticator = no
        secret = &quot;testing123&quot;
        nastype = &quot;other&quot;
 }
 client 192.168.0.15 {
        require_message_authenticator = no
        secret = &quot;mysecret&quot;
        shortname = &quot;myNAS&quot;
 }
...........</pre></div></div>

<p>This means that radiusd will allow NAS with IP address 192.168.0.15 and secret mysecret. Ctrl+C to stop radiusd. </p>
<p>In case you want to use MySQL with freeradius, you should do the next steps. Before anything, you need to create a database for freeradius.</p>
<p>Connect as root to your mysql and exec next queries.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">USER</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span>  <span style="color: #ff0000;">'radpass'</span>;
<span style="color: #993333; font-weight: bold;">GRANT</span> USAGE <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">.</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">TO</span>  <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span>  <span style="color: #ff0000;">'radpass'</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span>  <span style="color: #ff0000;">`radius`</span> ;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span>  <span style="color: #ff0000;">`radius`</span> <span style="color: #66cc66;">.</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">TO</span>  <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span>;</pre></div></div>

<p>Another option is to use admin.sql script from raddb/sql/mysql dir.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">USER</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span>;
<span style="color: #993333; font-weight: bold;">SET</span> PASSWORD <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #66cc66;">=</span> PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'radpass'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">ON</span> radius<span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span>;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> <span style="color: #993333; font-weight: bold;">ON</span> radius<span style="color: #66cc66;">.</span>radacct <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span>;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> <span style="color: #993333; font-weight: bold;">ON</span> radius<span style="color: #66cc66;">.</span>radpostauth <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'radius'</span>@<span style="color: #ff0000;">'localhost'</span>;</pre></div></div>

<p>This script will set a little bit safer permissions where radius will be able only to write radacct and radpostauth tables. (<strong>Do not forget to change default username/pass shown above</strong>).</p>
<p>The next step is to import default Freeradius tables (the sql files can be found inside raddb/sql/mysql dir). You should import nas.sql and schema.sql. The nas.sql will create a table for your NASes. It is much easier to maintain the NAS list inside database then inside clients.conf. Also, you can add more fields to nas table so you can do other operations with your NAS. </p>
<p>After this operations you should have something like:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>root@ms mysql<span style="color: #66cc66;">&#93;</span># mysql <span style="color: #66cc66;">-</span>u radius <span style="color: #66cc66;">-</span>p
Enter password:
Welcome <span style="color: #993333; font-weight: bold;">TO</span> the MySQL monitor<span style="color: #66cc66;">.</span>  Commands <span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">WITH</span> ; <span style="color: #993333; font-weight: bold;">OR</span> \g<span style="color: #66cc66;">.</span>
Your MySQL connection id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #cc66cc;">23387</span>
Server version: 5<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>77<span style="color: #66cc66;">-</span>log <span style="color: #993333; font-weight: bold;">SOURCE</span> distribution
&nbsp;
<span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #ff0000;">'help;'</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\h</span>'</span> <span style="color: #993333; font-weight: bold;">FOR</span> help<span style="color: #66cc66;">.</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\c</span>'</span> <span style="color: #993333; font-weight: bold;">TO</span> clear the buffer<span style="color: #66cc66;">.</span>
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">USE</span> radius;
Reading <span style="color: #993333; font-weight: bold;">TABLE</span> information <span style="color: #993333; font-weight: bold;">FOR</span> completion <span style="color: #993333; font-weight: bold;">OF</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> names
You can turn off this feature <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #993333; font-weight: bold;">GET</span> a quicker startup <span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #66cc66;">-</span>A
&nbsp;
<span style="color: #993333; font-weight: bold;">DATABASE</span> changed
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SHOW</span> <span style="color: #993333; font-weight: bold;">TABLES</span>;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------+</span>
<span style="color: #66cc66;">|</span> Tables_in_radius <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------+</span>
<span style="color: #66cc66;">|</span> nas              <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radacct          <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radcheck         <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radgroupcheck    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radgroupreply    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radpostauth      <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radreply         <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> radusergroup     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------+</span>
<span style="color: #cc66cc;">8</span> <span style="color: #993333; font-weight: bold;">ROWS</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Now we have a working database and we need to configure FreeRadius to use SQL. </p>
<p><strong>radiusd.conf</strong></p>
<p>Open radiusd.conf file (/usr/local/etc/raddb/radiusd.conf), and uncomment <strong>$INCLUDE sql.conf</strong> line inside modules section. Save changes and exit. </p>
<p><strong>sql.conf</strong></p>
<p>Open sql.conf and edit next lines</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">        # Connection info:
        server = &quot;localhost&quot;
        #port = 3306
        login = &quot;radius&quot;
        password = &quot;radpass&quot;
&nbsp;
        # Database table configuration for everything except Oracle
        radius_db = &quot;radius&quot;</pre></div></div>

<p>to fit your settings (database name, username and password).</p>
<p><strong>dialup.conf</strong></p>
<p>Then open /usr/local/etc/raddb/sql/mysql/dialup.conf and find the next lines (near the end)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> # Uncomment simul_count_query to enable simultaneous use checking
        simul_count_query = &quot;SELECT COUNT(*) \
                             FROM ${acct_table1} \
                             WHERE username = '%{SQL-User-Name}' \
                             AND acctstoptime IS NULL&quot;</pre></div></div>

<p>Sometimes you will need to check users for simultaneous use and uncommenting <strong>sql</strong> in session section and uncommenting the query shown above will help you to do this. </p>
<p><strong>default</strong></p>
<p>Now open /usr/local/etc/raddb/sites-available/default and uncomment <strong>sql</strong> lines inside authorize, accounting and session sections. You can uncomment sql inside post-auth section too if you want to log login attempts (notice that this is not recommended for production servers. Your database can grow and eat up all free space in case someone tries to brute force your NAS.). </p>
<p>Then comment the next lines: <strong>files</strong> inside authorize section, <strong>detail</strong>, <strong>unix</strong> and <strong>radutmp</strong> inside accounting section and <strong>radutmp</strong> inside session section.</p>
<p>Please note that those lines we commented above are not important for now and commenting those lines can improve performance. Also, note that <strong>detail</strong> should remain uncommented in case you want to create &#8216;detail&#8217;ed log of the packets for accounting requests. You will need this in case you want to proxy accounting to another server. </p>
<p>Then save the file and check your config with radiusd -X (debugging mode).</p>
<p>After this you should see something like</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rlm_sql (sql): Driver rlm_sql_mysql (module rlm_sql_mysql) loaded and linked
rlm_sql (sql): Attempting to connect to radius@localhost:/radius
rlm_sql (sql): starting 0
rlm_sql (sql): Attempting to connect rlm_sql_mysql #0
rlm_sql_mysql: Starting connect to MySQL server for #0
rlm_sql (sql): Connected new DB handle, #0
rlm_sql (sql): starting 1
rlm_sql (sql): Attempting to connect rlm_sql_mysql #1
rlm_sql_mysql: Starting connect to MySQL server for #1
rlm_sql (sql): Connected new DB handle, #1
rlm_sql (sql): starting 2
rlm_sql (sql): Attempting to connect rlm_sql_mysql #2
rlm_sql_mysql: Starting connect to MySQL server for #2
rlm_sql (sql): Connected new DB handle, #2
rlm_sql (sql): starting 3
rlm_sql (sql): Attempting to connect rlm_sql_mysql #3
rlm_sql_mysql: Starting connect to MySQL server for #3
rlm_sql (sql): Connected new DB handle, #3
rlm_sql (sql): starting 4
rlm_sql (sql): Attempting to connect rlm_sql_mysql #4
rlm_sql_mysql: Starting connect to MySQL server for #4
rlm_sql (sql): Connected new DB handle, #4</pre></div></div>

<p>which means your freeradius server successfully connected to MySQL database. </p>
<p>There are hundreds of options inside the files shown above and it is impossible to explain all of them. Read comments inside config files and try to figure yourself about them. If you&#8217;re using another database scheme, you will need to set up sql.conf and dialup.conf according to your tables. All parameters are editable and it is very easy to understand them. For example if you have a large number on users (1000-xxxx) open sql.conf and increase num_sql_socks from 5 to 15 or 20. </p>
<p><strong>You should not change/delete any other lines in the config file without reading and understanding the comments!</strong></p>
<p><strong>Populating tables and testing</strong></p>
<p>This is the most important part. Before you continue, you need to know what actually do you want from FreeRadius. Which kind of connection do you expect, etc. Also, you need to know something about tables, attributes, operators, etc. </p>
<p>This is it for now&#8230;. Next time we will add some users inside database and see what we can do.</p>
<p>Stay tuned&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/03/freeradius-install-howto-3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>FreeRadius install howto (2)</title>
		<link>http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/</link>
		<comments>http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 08:46:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[Networks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=269</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/' addthis:title='FreeRadius install howto (2) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Last post about FreeRadius (available on this LINK) introduced FreeRadius and basic installation steps (install from RPM and directly from source). My advice is to install from source (frequent updates, less bugs, etc). Also, please remember that FreeRadius is active project and you should always stick to the official site and wiki. Very often all [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/' addthis:title='FreeRadius install howto (2) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Last post about FreeRadius (available on this <a href="http://www.serveradminblog.com/2011/01/freeradius-howto-part-1/">LINK</a>) introduced FreeRadius and basic installation steps (install from RPM and directly from source). My advice is to install from source (frequent updates, less bugs, etc).  Also, please remember that FreeRadius is active project and you should always stick to the official site and wiki. Very often all of the documentation on &#8220;third party&#8221; web sites is outdated.<br />
<span id="more-269"></span></p>
<p>I suppose you already installed the FreeRadius (from source) and now I will try to explain a few basic steps.</p>
<p><strong>Files</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-rw-r----- 1 root root   671 Jan 27 15:54 acct_users
-rw-r----- 1 root root  4174 Jan 27 15:54 attrs
-rw-r----- 1 root root   513 Jan 27 15:54 attrs.access_challenge
-rw-r----- 1 root root   458 Jan 27 15:54 attrs.access_reject
-rw-r----- 1 root root   437 Jan 27 15:54 attrs.accounting_response
-rw-r----- 1 root root  2022 Jan 27 15:54 attrs.pre-proxy
drwxr-x--- 2 root root  4096 Jan 27 16:00 certs
-rw-r----- 1 root root  6703 Jan 27 15:54 clients.conf
-rw-r----- 1 root root   883 Jan 27 15:54 dictionary
-rw-r----- 1 root root 18063 Jan 27 15:54 eap.conf
-rwxr-xr-x 1 root root  4744 Jan 27 15:54 example.pl
-rw-r----- 1 root root 12722 Jan 27 15:54 experimental.conf
-rw-r----- 1 root root  2352 Jan 27 15:54 hints
-rw-r----- 1 root root  1604 Jan 27 15:54 huntgroups
-rw-r----- 1 root root  3218 Jan 27 15:54 ldap.attrmap
drwxr-x--- 2 root root  4096 Jan 27 15:54 modules
-rw-r----- 1 root root  2840 Jan 27 15:54 policy.conf
-rw-r----- 1 root root  4873 Jan 27 15:54 policy.txt
-rw-r----- 1 root root   984 Jan 27 15:54 preproxy_users
-rw-r----- 1 root root 26529 Jan 27 15:54 proxy.conf
-rw-r----- 1 root root 27238 Jan 27 15:54 radiusd.conf
drwxr-x--- 2 root root  4096 Jan 27 15:54 sites-available
drwxr-x--- 2 root root  4096 Jan 27 15:54 sites-enabled
drwxr-x--- 7 root root  4096 Jan 27 15:54 sql
-rw-r----- 1 root root  3042 Jan 27 15:54 sql.conf
-rw-r----- 1 root root  2475 Jan 27 15:54 sqlippool.conf
-rw-r----- 1 root root  3597 Jan 27 15:54 templates.conf
-rw-r----- 1 root root  6524 Jan 27 15:54 users</pre></div></div>

<p><strong>Initial test</strong></p>
<p>Start the server with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># radiusd</pre></div></div>

<p>The easiest way to test your radius installation is via radtest utility. It is a fast and convenient way to test a radius server. The radtest syntax is</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">radtest [-d raddb_directory] [-t pap/chap/mschap] [-x ] user password radius-server nas-port-number secret [ppphint] [nasname]</pre></div></div>

<p>In this case lets test with user &#8220;user&#8221; and password &#8220;password&#8221; on localhost (127.0.0.1) with secret testing123</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># radtest user password 127.0.0.1 0 testing123</pre></div></div>

<p>You should see something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@test raddb]# radtest user password 127.0.0.1 0 testing123
Sending Access-Request of id 245 to 127.0.0.1 port 1812
        User-Name = &quot;user&quot;
        User-Password = &quot;password&quot;
        NAS-IP-Address = 192.168.1.10
        NAS-Port = 0
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=245, length=20</pre></div></div>

<p>Notice the <strong>Access-Reject</strong> message. This is the normal message because user &#8220;user&#8221; doesn&#8217;t exist.</p>
<p>Now add</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">user Cleartext-Password := &quot;password&quot;</pre></div></div>

<p>inside users file (at the top, before anything else). Save the file, restart radius server (pkill radiusd, radiusd) and test again.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># radtest user password 127.0.0.1 0 testing123</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@test raddb]# radtest user password 127.0.0.1 0 testing123
Sending Access-Request of id 53 to 127.0.0.1 port 1812
        User-Name = &quot;user&quot;
        User-Password = &quot;password&quot;
        NAS-IP-Address = 192.168.1.10
        NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=53, length=20</pre></div></div>

<p>Fine. Now we have a Access-Accept message.</p>
<p>If you notice some problems wile testing, start the server in debug mode (radiusd -X) and test it from the new terminal window. In debug mode you will have more details so it is very easy to find out where the problem is.</p>
<p>In next post, I will write something about basic configuration (which config files you should check), how to assign FreeRadius and MySQL (or other database).</p>
<p>Stay tuned. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/03/freeradius-install-howto-2/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Neighbour table overflow &#8211; sysctl.conf tunning</title>
		<link>http://www.serveradminblog.com/2011/02/neighbour-table-overflow-sysctl-conf-tunning/</link>
		<comments>http://www.serveradminblog.com/2011/02/neighbour-table-overflow-sysctl-conf-tunning/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 11:23:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Networks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=254</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/02/neighbour-table-overflow-sysctl-conf-tunning/' addthis:title='Neighbour table overflow &#8211; sysctl.conf tunning '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you have a big network with the hundreds of hosts you can expect &#8220;Neighbour table overflow&#8221; error which occurs in large networks when there are two many ARP requests which the server is not able to reply. For example you&#8217;re using server as a DHCP server, cable modems provisioning, etc. Nov 10 03:18:17 myhost [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/02/neighbour-table-overflow-sysctl-conf-tunning/' addthis:title='Neighbour table overflow &#8211; sysctl.conf tunning '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you have a big network with the hundreds of hosts you can expect &#8220;Neighbour table overflow&#8221; error which occurs in large networks when there are two many ARP requests which the server is not able to reply. For example you&#8217;re using server as a DHCP server, cable modems provisioning, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Nov 10 03:18:17 myhost Neighbour table overflow.
Nov 10 03:18:23 myhost printk: 12 messages suppressed.</pre></div></div>

<p><span id="more-254"></span></p>
<p>Of curse, this can be fixed. The solution is to increase the threshhold values in /etc/sysctl.conf. Add following lines to /etc/sysctl.conf (RH based distros)</p>
<p>net.ipv4.neigh.default.gc_thresh1 = 4096<br />
net.ipv4.neigh.default.gc_thresh2 = 8192<br />
net.ipv4.neigh.default.gc_thresh3 = 8192<br />
net.ipv4.neigh.default.base_reachable_time = 86400<br />
net.ipv4.neigh.default.gc_stale_time = 86400</p>
<p>Save sysctl.conf and exec <strong>sysctl -p</strong>. You can also reboot but it isn&#8217;t necessary. </p>
<p>The default sysctl.conf file</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">net.ipv4.ip_forward=0
kernel.shmmax=68719476736
kernel.msgmax=65536
kernel.msgmnb=65536
net.ipv4.conf.default.rp_filter=1
kernel.sysrq=0
net.ipv4.conf.default.accept_source_route=0
kernel.shmall=4294967296
kernel.core_uses_pid=1
net.ipv4.tcp_syncookies=1</pre></div></div>

<p>&#8220;Tuned&#8221; systctl.conf</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">net.ipv4.ip_forward=0
kernel.shmmax=4294967295
kernel.msgmax=65536
kernel.msgmnb=65536
net.ipv4.conf.default.rp_filter=1
kernel.sysrq=0
net.ipv4.conf.default.accept_source_route=0
kernel.shmall=268435456
kernel.core_uses_pid=1
net.ipv4.tcp_syncookies=1
net.ipv4.neigh.default.gc_thresh1 = 4096
net.ipv4.neigh.default.gc_thresh2 = 8192
net.ipv4.neigh.default.gc_thresh3 = 8192
net.ipv4.neigh.default.base_reachable_time = 86400
net.ipv4.neigh.default.gc_stale_time = 86400</pre></div></div>

<p>Explanation&#8230; </p>
<p>The neighbour table is generally known as ARP table and the default value for gc_thresh1 is 128 (Adjust where the gc will leave arp table alone)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@myServer ~]# cat /proc/sys/net/ipv4/neigh/default/gc_thresh1
128</pre></div></div>

<p>which is not enough for large networks (more than 128 hosts). Thats why we need to tune this value. The gc_thresh2 is a soft limit (Tell the gc when to become aggressive with arp table cleaning.) and the gc_thresh3 is a hard limit (Don&#8217;t allow the arp table to become bigger than this). </p>
<p>To enlarge the ARP cache table on the live system run:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># sysctl -w net.ipv4.neigh.default.gc_thresh3=8192
# sysctl -w net.ipv4.neigh.default.gc_thresh2=8192
# sysctl -w net.ipv4.neigh.default.gc_thresh1=4096</pre></div></div>

<p>It is possible that after distro update your systctl.conf will be replaced with the default values. Check this file periodically..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/02/neighbour-table-overflow-sysctl-conf-tunning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Check what ports are open</title>
		<link>http://www.serveradminblog.com/2010/07/check-what-ports-are-open/</link>
		<comments>http://www.serveradminblog.com/2010/07/check-what-ports-are-open/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 09:37:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networks]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=127</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/07/check-what-ports-are-open/' addthis:title='Check what ports are open '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>To see what ports are open in your Linux box, you can use nmap port scanner or you can use netstat. nmap can be used with following command: # nmap -sS -O 127.0.0.1 The answer will be something like: Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-07-08 11:31 CEST Interesting ports on localhost.localdomain (127.0.0.1): Not [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/07/check-what-ports-are-open/' addthis:title='Check what ports are open '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>To see what ports are open in your Linux box, you can use nmap port scanner or you can use netstat. </p>
<p>nmap can be used with following command:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># nmap -sS -O 127.0.0.1</pre></div></div>

<p>The answer will be something like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-07-08 11:31 CEST
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1663 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
111/tcp  open  rpcbind
143/tcp  open  imap
993/tcp  open  imaps
995/tcp  open  pop3s
3306/tcp open  mysql
8009/tcp open  ajp13
8080/tcp open  http-proxy
8443/tcp open  https-alt
No exact OS matches for host (If you know what OS is running on it, see http://www.insecure.org/cgi-bin/nmap-submit.cgi).
......
&nbsp;
Uptime 15.472 days (since Wed Jun 23 00:12:46 2010)
&nbsp;
Nmap finished: 1 IP address (1 host up) scanned in 9.558 seconds</pre></div></div>

<p>and nmap can be used to scan remote hosts (keep in mind that many admins will notice this as hack attempt). Simple replace 127.0.0.1 with host IP address. </p>
<p>Another way to check open ports is via netstat. Netstat can show hidden ports and programs associated with ports. Simple execute next command as root:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># netstat -nap</pre></div></div>

<p>The output list can be very long (depending from your network activity).</p>
<p>Note: Use this tips carefully. I&#8217;m not responsible for any potential damage&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/07/check-what-ports-are-open/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tftp server on CentOS/RHEL/Fedora</title>
		<link>http://www.serveradminblog.com/2010/01/tftp-server-on-centosrhelfedora/</link>
		<comments>http://www.serveradminblog.com/2010/01/tftp-server-on-centosrhelfedora/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 23:16:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Networks]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=49</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/01/tftp-server-on-centosrhelfedora/' addthis:title='tftp server on CentOS/RHEL/Fedora '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Trivial File Transfer Protocol (TFTP) is a file transfer protocol, with the functionality of a very basic form of File Transfer Protocol (FTP). It was first defined in 1980 and it is used for operations like firmware upgrade on network devices. This post won&#8217;t be the history lesson . To install tftp server on RH [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/01/tftp-server-on-centosrhelfedora/' addthis:title='tftp server on CentOS/RHEL/Fedora '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Trivial File Transfer Protocol (TFTP) is a file transfer protocol, with the functionality of a very basic form of File Transfer Protocol (FTP). It was first defined in 1980 and it is used for operations like firmware upgrade on network devices. This post won&#8217;t be the history lesson <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . To install tftp server on RH based distros, follow the next steps</p>
<p>Install tftp-server with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># yum install tftp-server xinetd</pre></div></div>

<p>Now you will need to set up some things before you can start and use tftp server</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># nano /etc/xinetd.d/tftp</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}</pre></div></div>

<p>To enable tftp server, set “disable” to no. Also, check server_args. In this case, all files will be/must be in /var/lib/tftpboot. If you have any problems with permissions, try to chmod 777 /var/lib/tftpboot and fix perms later. </p>
<p>Restart xinetd to apply settings you just made</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># service xinetd restart</pre></div></div>

<p>Setting &#8220;disable&#8221; to yes will disable tftp server and for security reasons, you should disable tftp whenever you don&#8217;t need it. </p>
<p>TFTP has been implemented on top of the User Datagram Protocol (UDP) using port number 69. TFTP is designed to be small and easy to implement, therefore, lacks most of the features of a regular FTP. TFTP only reads and writes files (or mail) from/to a remote server. It cannot list directories, and currently has no provisions for user authentication.</p>
<p>In TFTP, any transfer begins with a request to read or write a file, which also serves to request a connection. If the server grants the request, the connection is opened and the file is sent in fixed length blocks of 512 bytes. Each data packet contains one block of data, and must be acknowledged by an acknowledgment packet before the next packet can be sent. A data packet of less than 512 bytes signals termination of a transfer. If a packet gets lost in the network, the intended recipient will timeout and may retransmit his last packet (which may be data or an acknowledgment), thus causing the sender of the lost packet to retransmit that lost packet. The sender has to keep just one packet on hand for retransmission, since the lock step acknowledgment guarantees that all older packets have been received. Notice that both machines involved in a transfer are considered senders and receivers. One sends data and receives acknowledgments, the other sends acknowledgments and receives data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/01/tftp-server-on-centosrhelfedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

