<?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</title>
	<atom:link href="http://www.serveradminblog.com/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>FreeRadius install howto (5) – Mikrotik settings</title>
		<link>http://www.serveradminblog.com/2012/01/freeradius-install-howto-5-mikrotik-settings/</link>
		<comments>http://www.serveradminblog.com/2012/01/freeradius-install-howto-5-mikrotik-settings/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 23:18:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeRadius]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=414</guid>
		<description><![CDATA[&#160; I&#8217;m receiving so many questions about FreeRadius and I&#8217;m sorry to tell this but I can&#8217;t and I won&#8217;t give you tech support 4 free. I can and I will answer on one or two questions but do not bother me every single day via email and IM clients when I already wrote on [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>I&#8217;m receiving so many questions about FreeRadius and I&#8217;m sorry to tell this but <strong>I can&#8217;t and I won&#8217;t give you tech support 4 free</strong>. I can and I will answer on one or two questions but do not bother me every single day via email and IM clients when I already wrote on this blog all you need to know.</p>
<p>I understand that RADIUS protocol is marginalized but there are more than enough articles which just laying around and waiting for you. All you need is Google and the right search term.</p>
<p><span id="more-414"></span></p>
<p>Before you continue to this read this article, please:<br />
turn on your brain<br />
find out what exactly do you want from your RADIUS server<br />
read the four articles I posted on this blog<br />
be sure that you Mikrotik can reach the Internet (has properly configured IP addresses, DNS, default route, etc)</p>
<p>In this post, I will explain how to set up a Mikrotik router to act as a NAS (but only the part related to RADIUS).</p>
<p>The first step you need to do is to be sure that Mikrotik and RADIUS server “can talk” which means you can ping RADIUS server from Mikrotik and vice verse. Of course, the connection must be reliable and without packet loss.</p>
<p>In the last example, our RADIUS server had an IP address 192.168.0.10 and if you remember we added IP 192.168.0.15 inside the nas table with mysecret as a RADIUS secret. This means that only NAS from IP address 192.168.0.15 would be able to talk with RADIUS server but only if the secret is correct.</p>
<p>So, lets define the RADIUS server inside Mikrotik.</p>
<p>Connect to Mikrotik via Winbox utility. Click on RADIUS and click on the + to add a new RADIUS server.</p>
<p><img class="size-full wp-image-420 aligncenter" title="1" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/1.png" alt="" width="336" height="449" /></p>
<p>&nbsp;</p>
<p>Enter RADIUS server IP address (in this case 192.168.0.10), enter secret and select ppp.</p>
<p>The next step is to enable Incoming requests so you will be able to disconnect users via PoD (Packet of Disconnect). Click on the Incoming button (RADIUS -&gt; Incoming) and enable Accept checkbox.</p>
<p><img class="size-full wp-image-415 aligncenter" title="2" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/2.png" alt="" width="261" height="200" /></p>
<p>Add new PPPoE server (PPP &#8211; PPPoE Servers and click Add).</p>
<p><img class="aligncenter" title="3" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/3.png" alt="" width="336" height="347" /></p>
<p>The most important thing here is to choose the right interface. I your LAN interface is connected to the network where are the users, select LAN. My recommendation is to leave only pap and chap inside Auth. section.</p>
<p>The next step is to define a IP pool which will be used for address allocation.</p>
<p><img class="size-full wp-image-417 aligncenter" title="4" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/4.png" alt="" width="275" height="186" /></p>
<p>Be sure that pool name is the same like you defined in the database because radius server will return the pool name to Mikrotik and if the pool with that name doesn&#8217;t exists, the users won&#8217;t get an IP address.</p>
<p>The next step is to properly configure the default profile for PPPoE users.</p>
<p><img class="size-full wp-image-418 aligncenter" title="5" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/5.png" alt="" width="341" height="551" /></p>
<p>Enter local IP address (your public IP address), select remote address pool (the IP pool which we defined above) and add DNS servers which will be returned to the users.You can use the same Mikrotik as a DNS server but you need to turn on Allow remote requests inside DNS settings.</p>
<p>The last step is to turn on RADIUS for accounting inside PPP &#8211; Secret menu. Interim update is the time and I do not recommend the values less than 5 minutes.</p>
<p><img class="size-full wp-image-419 aligncenter" title="6" src="http://www.serveradminblog.com/wp-content/uploads/2012/01/6.png" alt="" width="324" height="132" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2012/01/freeradius-install-howto-5-mikrotik-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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[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[<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>Facebook you’re doing it wrong</title>
		<link>http://www.serveradminblog.com/2011/12/facebook-youre-doing-it-wrong/</link>
		<comments>http://www.serveradminblog.com/2011/12/facebook-youre-doing-it-wrong/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 21:26:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=401</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-402 aligncenter" title="facebook-you-doing-it-wrong" src="http://www.serveradminblog.com/wp-content/uploads/2011/12/facebook-you-doing-it-wrong.png" alt="" width="324" height="271" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/12/facebook-youre-doing-it-wrong/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[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[<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>PhpMyAdmin you&#8217;re doing it wrong</title>
		<link>http://www.serveradminblog.com/2011/12/phpmyadmin-youre-doing-it-wrong/</link>
		<comments>http://www.serveradminblog.com/2011/12/phpmyadmin-youre-doing-it-wrong/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 10:14:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=387</guid>
		<description><![CDATA[Icons are just fine&#8230; No need for repeating text labels&#8230;]]></description>
			<content:encoded><![CDATA[<p>Icons are just fine&#8230; No need for repeating text labels&#8230;</p>
<p><img class="aligncenter" src="/wp-content/uploads/2011/12/phpmyadmin.png" alt="phpmyadmin" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/12/phpmyadmin-youre-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Performance – Howto – part 2 (write cache dependance)</title>
		<link>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/</link>
		<comments>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 16:23:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=379</guid>
		<description><![CDATA[I already wrote about Sysbench and MySQL tunning scripts. Those articles can be found HERE and HERE. Now lets do some tests and lets see the dependance from write cache enabled/disabled option on your disks. Keep in mind that RH based distros will probably disable write cache (I tried Ubuntu on this server and the [...]]]></description>
			<content:encoded><![CDATA[<p>I already wrote about Sysbench and MySQL tunning scripts. Those articles can be found <a href="http://www.serveradminblog.com/2010/02/sysbench-on-centos-howto/">HERE</a> and <a href="http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/">HERE</a>. </p>
<p>Now lets do some tests and lets see the dependance from write cache enabled/disabled option on your disks. Keep in mind that RH based distros will probably disable write cache (I tried Ubuntu on this server and the same thing happen &#8211; write cache was disabled after installation). </p>
<p><span id="more-379"></span></p>
<p>The first step is to check the disk with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@s1 sysbench-0.4.12]# hdparm -i /dev/sda
&nbsp;
/dev/sda:
&nbsp;
 Model=GB0250EAFYK                             , FwRev=HPG1    , SerialNo=WCAT1E535427
 Config={ HardSect NotMFM HdSw&gt;15uSec SpinMotCtl Fixed DTR&gt;5Mbs FmtGapReq }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
 BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=268435455
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2
 AdvancedPM=no WriteCache=disabled
 Drive conforms to: unknown:  ATA/ATAPI-1 ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6 ATA/ATAPI-7</pre></div></div>

<p>Note <strong>WriteCache=disabled</strong> line</p>
<p>I suppose you know how to create a database, assign a user and set password</p>
<p>Read-write test for InnoDB</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># sysbench --num-threads=16 --max-requests=10000 --test=oltp --oltp-table-size=500000 --mysql-socket=/var/lib/mysql/mysql.sock --oltp-test-mode=complex --mysql-user=test_database --mysql-password=test_database_password run</pre></div></div>

<p>gave me the next results</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&nbsp;
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 16
&nbsp;
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using &quot;BEGIN&quot; for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
&nbsp;
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (42.63 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (809.95 per sec.)
    other operations:                    20000  (85.26 per sec.)
&nbsp;
Test execution summary:
    total time:                          234.5821s
    total number of events:              10000
    total time taken by event execution: 3751.1329
    per-request statistics:
         min:                                 17.33ms
         avg:                                375.11ms
         max:                               3850.27ms
         approx.  95 percentile:             766.79ms
&nbsp;
Threads fairness:
    events (avg/stddev):           625.0000/1.73
    execution time (avg/stddev):   234.4458/0.08</pre></div></div>

<p><strong>The total time is more than 234 seconds which is terrible result.</strong> </p>
<p>Now, delete sbtest table and recreate it again (please see the sysbench howto). </p>
<p>Enable write cache with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># hdparm -W1 /dev/sda</pre></div></div>

<p>and start test again</p>
<p>The result is</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 16
&nbsp;
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using &quot;BEGIN&quot; for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
&nbsp;
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (621.08 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (11800.43 per sec.)
    other operations:                    20000  (1242.15 per sec.)
&nbsp;
Test execution summary:
    total time:                          16.1011s
    total number of events:              10000
    total time taken by event execution: 255.8624
    per-request statistics:
         min:                                  2.49ms
         avg:                                 25.59ms
         max:                                689.84ms
         approx.  95 percentile:              41.84ms
&nbsp;
Threads fairness:
    events (avg/stddev):           625.0000/4.68
    execution time (avg/stddev):   15.9914/0.03</pre></div></div>

<p><strong>Now we have a 16.1011 seconds for a complete test. </strong> I repeated the test several time with the same results. </p>
<p>We have a 14.62 times better result.</p>
<p>It is obvious that write cache is very important for MySQL but keep in mind that something can be lost in case of power failure and you should think about battery backups. </p>
<p><strong>Tuning Kernel parameters</strong></p>
<p>It is good idea to tune a few kernel parameters too. For this purpose you can install ktune (yum install ktune). (more info https://fedorahosted.org/ktune/)</p>
<p>With &#8220;service ktune start&#8221; you will set up scheduler on deadline instead of cfq (which can be up to 20% slower)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@s1 bekap]# service ktune start
Applying ktune sysctl settings:
/etc/sysctl.ktune:                                         [  OK  ]
Applying sysctl settings from /etc/sysctl.conf:            [  OK  ]
Applying deadline elevator: sda                            [  OK  ]</pre></div></div>

<p>After Ktune I have a little faster time (around 15 seconds)</p>
<p>More info about disk elevators can be found here <a href="http://www.redhat.com/magazine/008jun05/features/schedulers/" target="_blank">http://www.redhat.com/magazine/008jun05/features/schedulers/</a></p>
<p><strong>Optimizing the EXT3 file system on CentOS</strong></p>
<p>noatime<br />
This mount option tells the system not to update inode access times. This is a good option for web servers, news servers or other uses with high access file systems.</p>
<p>Open  /etc/fstab and add noatime like shown below</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/dev/VolGroup00/LogVol00 /                       ext3    defaults,noatime        1 1</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List the last created file</title>
		<link>http://www.serveradminblog.com/2011/11/list-the-last-created-file/</link>
		<comments>http://www.serveradminblog.com/2011/11/list-the-last-created-file/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 15:00:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=375</guid>
		<description><![CDATA[If you want to find the newest file inside directory, you can use the ls &#038; tail combination. ls -t &#124; head -1 Output bash$ ls -t &#124; head -1 id695.txt Another option is with the next command ls -lrth &#124; tail -1 Output bash$ ls -lrth &#124; tail -1 -rw-r----- 1 user ugroup 85 [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to find the newest file inside directory, you can use the ls &#038; tail combination.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ls -t | head -1</pre></div></div>

<p>Output</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bash$ ls -t | head -1
id695.txt</pre></div></div>

<p>Another option is with the next command</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ls -lrth | tail -1</pre></div></div>

<p>Output</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bash$ ls -lrth | tail -1
-rw-r-----   1 user      ugroup         85 Nov 11 15:38 id695.txt</pre></div></div>

<p>Note:<br />
| is used to send the output of the first command as input to the second one.<br />
tail &#8212; outputs the last files<br />
-1 &#8212; denotes the number of lines u want to display (in case you don&#8217;t set -1, by default you will get the last 10 lines)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/11/list-the-last-created-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dafizilla Table2Clipboard Firefox addon</title>
		<link>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/</link>
		<comments>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 22:39:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=371</guid>
		<description><![CDATA[If you need to copy HTML tables into Excel, Libreoffice Calc or other datasheet applications, you can think about Firefox and Dafizilla Table2Clipboard firefox addon. This addon will allow you to select rows and columns from a table simply pressing Control key and picking rows/columns with left mouse button. The selection can be copied to [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to copy HTML tables into Excel, Libreoffice Calc or other datasheet applications, you can think about Firefox and Dafizilla Table2Clipboard firefox addon. </p>
<p>This addon will allow you to select rows and columns from a table simply pressing Control key and picking rows/columns with left mouse button. The selection can be copied to clipboard and pasted into datasheet applications but without ugly results. </p>
<p>Pasting in plain text editors is also supported as CSV file.</p>
<p>Here is the <a href="https://addons.mozilla.org/en-US/firefox/addon/dafizilla-table2clipboard/" target="_blank">LINK</a> for this great tool. </p>
<p>Do not forget to donate <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dennis Ritchie: 1941-2011</title>
		<link>http://www.serveradminblog.com/2011/10/dennis-ritchie-1941-2011/</link>
		<comments>http://www.serveradminblog.com/2011/10/dennis-ritchie-1941-2011/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 21:22:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=369</guid>
		<description><![CDATA[#include &#60;stdio.h&#62; &#160; int main&#40;&#41; &#123; printf&#40;&#34;goodbye, dad\n&#34;&#41;; return 0; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;goodbye, dad<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/10/dennis-ritchie-1941-2011/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UTF-8 with MySQL and PDO</title>
		<link>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/</link>
		<comments>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 08:51:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=365</guid>
		<description><![CDATA[If you are using PDO (PHP Data Objects) and you&#8217;re having problems with utf-8, try to add PDO::MYSQL_ATTR_INIT_COMMAND option inside PDO definition like I wrote below. $db = new PDO&#40; 'mysql:host=example.com;dbname=dbName', &#34;username&#34;, &#34;password&#34;, array&#40;PDO::MYSQL_ATTR_INIT_COMMAND =&#62; &#34;SET NAMES utf8&#34;&#41;&#41;;]]></description>
			<content:encoded><![CDATA[<p>If you are using PDO (PHP Data Objects) and you&#8217;re having problems with utf-8, try to add PDO::MYSQL_ATTR_INIT_COMMAND option inside PDO definition like I wrote below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'mysql:host=example.com;dbname=dbName'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>PDO<span style="color: #339933;">::</span><span style="color: #004000;">MYSQL_ATTR_INIT_COMMAND</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;SET NAMES utf8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

