<?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>devtrends.com &#187; Ubuntu</title>
	<atom:link href="http://www.devtrends.com/index.php/category/linux/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtrends.com</link>
	<description>developing trends in information technology</description>
	<lastBuildDate>Tue, 06 Sep 2011 19:27:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Configuring SAMBA Shares in Ubuntu</title>
		<link>http://www.devtrends.com/index.php/configuring-samba-shares-in-ubuntu/</link>
		<comments>http://www.devtrends.com/index.php/configuring-samba-shares-in-ubuntu/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 23:30:21 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Microsoft O/S]]></category>
		<category><![CDATA[SMB]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux Windows Shares]]></category>
		<category><![CDATA[SAMBA]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=705</guid>
		<description><![CDATA[I needed to upgrade my file server to support larger disks (1TB SATA) and at the same time I wanted to upgrade from Windows 2000 Server. Prior to my purchasing...]]></description>
			<content:encoded><![CDATA[<p>I needed to upgrade my file server to support larger disks (1TB SATA) and at the same time I wanted to upgrade from Windows 2000 Server. Prior to my purchasing a TechNet subscription, I only had one viable option, to use Linux. I would say that the order of events (Linux then TechNet) was beneficial as I had to actually learn to use Linux. This started a whole interest in Linux/Unix (and Mac) that is still growing today.</p>
<p>As you may know, to make a Linux server replace a Windows file server you&#8217;ll need a common file sharing protocol between both server and client. Well, SAMBA is the answer. In reality I think that SAMBA is the only answer.</p>
<p><strong>Installing SAMBA</strong></p>
<p>To be honest, I just rebuilt my Linux machine this month and have already forgotten whether SAMBA came preinstalled on Ubuntu Server 9.10 or not. Even if it is already install, it doesn&#8217;t hurt to try installing it again:</p>
<blockquote><p>aaron@server:/# sudo apt-get install samba</p></blockquote>
<p>Among other files, the three files you will use the most in configuring SAMBA are the config file, /etc/samba/smb.conf, and the init script for the daemon, /etc/init.d/samba, and the SAMBA password tool, /usr/bin/smbpasswd.</p>
<p><strong>Configuring Users and Groups for SAMBA</strong></p>
<p>The first step is creating the users and groups that will be accessing the SAMBA share. In this example, we will use local Linux accounts and groups, then activate the user account in SAMBA. The group will be used to assign permissions to the directory in the Linux file system.</p>
<p>Because my set up is small, I have only a few accounts and one group that I use for SAMBA shares. The group has all SAMBA users in it and is named &#8220;dtusers&#8221;. Let&#8217;s work with my configuration as the example.</p>
<p>First, if you dare, switch to the root account (or best practice is to use sudo for every command):</p>
<blockquote><p>root@server:/# sudo su</p></blockquote>
<p>To create a new system group, use the following:</p>
<blockquote><p>root@server:/# groupadd -r dtusers</p></blockquote>
<p>Now that we have the group created, we should create some users as well. As we create the users, we will assign the group we just created as a supplemental group.</p>
<blockquote><p>root@server:/# useradd -G dtusers -p P@ssW0rd aaron</p></blockquote>
<p>Use the above command as many times as needed for your users. &#8220;aaron&#8221; is the username, by the way. Additional thought, &#8220;P@ssW0rd&#8221; is not a secure password, and even though SAMBA is configured to synchronize passwords (see &#8220;unix password sync&#8221; setting in the smb.conf file), we want to ensure a password is set prior to SAMBA configuration.</p>
<p>Finally, we need to enable these accounts using the SAMBA smbpasswd password tool.</p>
<blockquote><p>root@server:/# smbpasswd -a aaron</p></blockquote>
<p>When you are prompted for a password, use the same password as you did when you created the user. Use the above command as many times as needed for your users.</p>
<p><strong>Configuring Directories for SAMBA Sharing</strong></p>
<p>The next step is figuring out which directories you want to share through SAMBA. In my case, I created all of my shares under /datastore/. For the example, lets copy my configuration.</p>
<p>Create the /datastore/ root directory. Then create a directory named aaron, a directory named music, a directory named pictures and a directory named downloads.</p>
<blockquote><p>root@server:/# mkdir /datastore<br />
root@server:/# cd /datastore<br />
root@server:/datastore# mkdir aaron<br />
root@server:/datastore# mkdir music<br />
root@server:/datastore# mkdir pictures<br />
root@server:/datastore# mkdir downloads</p></blockquote>
<p>Now that we have our directories created, we need to ensure owners and  permissions are set correctly for each of the directories.</p>
<p>First, we need to change the user and group owners. I recommend root as the main user for any &#8220;shared&#8221; directories:</p>
<blockquote><p>root@server:/datastore# chown aaron:dtusers aaron<br />
root@server:/datastore# chown root:dtusers music<br />
root@server:/datastore# chown root:dtusers pictures<br />
root@server:/datastore# chown root:dtusers downloads</p></blockquote>
<p>Last, we need to change the permissions. I recommend 775 (see Unix Permissions at the bottom of this  article for more info on 775) for any of the &#8220;shared&#8221; directories and  750 or 700 for the user specific directories.</p>
<blockquote><p>root@server:/datastore# chmod 700 aaron<br />
root@server:/datastore# chmod 775 music<br />
root@server:/datastore# chmod 775 pictures<br />
root@server:/datastore# chmod 775 downloads</p></blockquote>
<p>Now, have a look at your directories to make sure they have the appropriate permissions:</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2011/02/SAMBA_permissions_example.jpg"><img class="alignnone size-full wp-image-711" title="SAMBA_permissions_example" src="http://www.devtrends.com/wp-content/uploads/2011/02/SAMBA_permissions_example.jpg" alt="" width="479" height="138" /></a></p>
<p><strong>Configuring SAMBA</strong></p>
<p>The final step in configuring SAMBA is, well, configuring SAMBA. The SAMBA configuration file, smb.conf, that comes with the SAMBA install is rather large. We&#8217;ll go through it and change only some of the settings and add some of our own.</p>
<p>Using your favorite text editor (mine is actually vi, but if you are new to Linux, you&#8217;ll like nano better) and open the SAMBA configuration file:</p>
<blockquote><p>root@server:/# vi /etc/samba/smb.conf</p></blockquote>
<p>Scroll through the configuration file and review the various options. Once you have looked around, start changing variables. First if you have a DNS domain defined, I would change the following:</p>
<blockquote><p>workgroup = dt.local</p></blockquote>
<p>Next, scroll to the bottom of the configuration file and add your SAMBA share definitions. In this example, I have also configured a &#8220;create mask&#8221; which forces certain permission types for all new files, &#8220;directory mask&#8221; which forces certain permission types for all new directories, and &#8220;force group&#8221; to ensure the group is always my dtusers group:</p>
<blockquote><p>[aaron]<br />
path = /datastore/aaron<br />
valid users = aaron<br />
writable = yes<br />
browseable = yes<br />
read only = no<br />
create mask = 0700<br />
directory mask = 0700<br />
guest ok = no<br />
force group = dtusers</p>
<p>[music]<br />
path = /datastore/music<br />
valid users = @dtusers<br />
writable = yes<br />
browseable = yes<br />
read only = no<br />
create mask = 0775<br />
directory mask = 0775<br />
guest ok = no<br />
force group = dtusers</p>
<p>[pictures]<br />
path = /datastore/pictures<br />
valid users = @dtusers<br />
writable = yes<br />
browseable = yes<br />
read only = no<br />
create mask = 0775<br />
directory mask = 0775<br />
guest ok = no<br />
force group = dtusers</p>
<p>[downloads]<br />
path = /datastore/downloads<br />
valid users = @dtusers<br />
writable = yes<br />
browseable = yes<br />
read only = no<br />
create mask = 0775<br />
directory mask = 0775<br />
guest ok = no<br />
force group = dtusers</p></blockquote>
<p>You&#8217;ll notice that the [aaron] share contains &#8220;valid users&#8221; of only aaron, while the other &#8220;shared&#8221; shares contain &#8220;valid users&#8221; of @dtusers. The @ sign defines a group. If you have more than one group or users, separate them with a space.</p>
<p>Save the configuration file and then restart the SAMBA service:</p>
<blockquote><p>root@server:/# /etc/init.d/samba restart</p></blockquote>
<p><strong>Using SAMBA</strong></p>
<p>Now that you have SAMBA configured with some shares, give it a whirl from your Windows machine. If the user that you sign into on your Windows machine is the same, with the same password, as the Linux/SAMBA user you will not be prompted to authenticate.</p>
<p>Click Start &gt; Run and then type in the UNC path to your Linux server. If you have a DNS host (A) record for your server it could be \\server\share_name, otherwise just use the IP address, \\192.168.0.1\share_name.</p>
<p>That&#8217;s it. Enjoy Linux!</p>
<p><strong>Unix Permissions</strong></p>
<p>764 defines the permissions for User (the 7)/Group (the 6)/Everyone (the 4). As another example, if you wanted only the User to have full permissions, assign 700, which is User (the 7)/Group (the 0)/Everyone (the 0).</p>
<p>The number represents the collective of permission types: 4 is Read, 2 is Write, 1 is Execute. So a 7 would be 4 + 2 + 1, which means that when assigned to the User, it will have all three permission types, or full control. A zero means no permission types, and therefore no permissions.</p>
<p><strong>Links</strong></p>
<p><a href="http://www.samba.org/" target="_blank">http://www.samba.org/</a><br />
<a href="http://support.quickbooks.intuit.com/support/Articles/HOW12300" target="_blank">http://support.quickbooks.intuit.com/support/Articles/HOW12300</a></p>
<p>-Aaron</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/configuring-samba-shares-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure NTP Server on Ubuntu 9.10</title>
		<link>http://www.devtrends.com/index.php/configure-ntp-server-on-ubuntu-9-10/</link>
		<comments>http://www.devtrends.com/index.php/configure-ntp-server-on-ubuntu-9-10/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 01:57:06 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[NTP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NTP Server]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=646</guid>
		<description><![CDATA[I don&#8217;t know about you, but I really don&#8217;t like when clocks all display a different time, even when it is usually at most a 5 minute difference. When it...]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know about you, but I really don&#8217;t like when clocks all display a different time, even when it is usually at most a 5 minute difference. When it comes to computer technology, time differences between devices is annoying and is also considered a security threat for some protocols, such as Kerberos.</p>
<p>This article is not to argument security threats, but instead to show you how to configure an NTP server on Ubuntu Server 9.10. Once you have the NTP Server functioning, you may configure devices that understand NTP to get time from your new NTP Server. Let&#8217;s get started.</p>
<p><strong>Install NTP Server</strong></p>
<p>Remember that installing packages in Linux will require elevated privileges, so make sure you sudo first.</p>
<p>1. root@server:/# apt-get install ntp</p>
<p><strong>Configure the NTP Server</strong></p>
<p>Next we will configure the NTP server to use a NTP pool and to allow access for your network to do NTP queries to this server.</p>
<p>1. root@server:/# vi /etc/ntp.conf</p>
<p>Locate the following section in the conf file:</p>
<blockquote><p># You do need to talk to an NTP server or two (or three).<br />
server ntp.ubuntu.com</p></blockquote>
<p>Change that to be this instead (servers from <a href="http://www.pool.ntp.org/en/" target="_blank">pool.ntp.org</a>):</p>
<blockquote><p># You do need to talk to an NTP server or two (or three).<br />
server 0.pool.ntp.org<br />
server 1.pool.ntp.org<br />
server 2.pool.ntp.org<br />
server 3.pool.ntp.org</p></blockquote>
<p>Next locate the &#8220;restrict&#8221; statements and add the following new line (replace with your subnet):</p>
<blockquote><p>restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap</p></blockquote>
<p><strong>Set Time on Server</strong></p>
<p>This is an important step, as you will not be able to synchronize your NTP Server with the NTP pool time if the time is off by too many minutes.</p>
<p>Make sure the NTP Server is stopped, as the following command will require the same port:</p>
<p>1. root@server:/# /etc/init.d/ntp stop</p>
<p>Set the system time:</p>
<p>2. root@server:/# ntpdate pool.ntp.org</p>
<p>Start the NTP Server.</p>
<p>3. root@server:/# /etc/init.d/ntp start</p>
<p><strong>Check the NTP Server Status</strong></p>
<p>In order for your clients to be able to successfully query time from your new NTP Server, your NTP Server must be synchronized with the specified Internet NTP servers. After you have started the NTP Server, this may take 10 minutes for synchronization.</p>
<p>To check the status, use:</p>
<p>1. root@server:/# ntpq -pn</p>
<p>If you server is not synchronized yet, and assuming your configured the servers as explained above, you should see something similar to the following:</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2011/02/ntp_no_sync.jpg"><img class="alignnone size-full wp-image-650" title="ntp_no_sync" src="http://www.devtrends.com/wp-content/uploads/2011/02/ntp_no_sync.jpg" alt="" width="554" height="90" /></a></p>
<p>Once it is synchronized, it will display something similar to the following:</p>
<p><a href="http://www.devtrends.com/wp-content/uploads/2011/02/ntp_sync.jpg"><img class="alignnone size-full wp-image-651" title="ntp_sync" src="http://www.devtrends.com/wp-content/uploads/2011/02/ntp_sync.jpg" alt="" width="554" height="90" /></a></p>
<p>Notice the * and + symbols next to the IP addresses, the one with the * is the server that your computer is synchronized with.</p>
<p>Note: If you try to synchronize a Windows device with the NTP Server before it is synchronized with the Internet, you will probably receive an error similar to: &#8220;An error occurred while Windows was synchronizing with 192.168.0.10. The time sample was rejected because: The peer&#8217;s stratum is less than the host&#8217;s stratum.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/configure-ntp-server-on-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure TFTP Server on Ubuntu 9.10</title>
		<link>http://www.devtrends.com/index.php/configure-tftp-on-ubuntu-9-10/</link>
		<comments>http://www.devtrends.com/index.php/configure-tftp-on-ubuntu-9-10/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 23:45:34 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[TFTP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[atftpd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu 9.10]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=642</guid>
		<description><![CDATA[I have been searching for a solution that worked for configuring a TFTP Server service on my Ubuntu 9.10 Linux server and have yet to find one that provides a...]]></description>
			<content:encoded><![CDATA[<p>I have been searching for a solution that worked for configuring a TFTP Server service on my Ubuntu 9.10 Linux server and have yet to find one that provides a working answer. So, I write my own.</p>
<p>For this example we will use atftp daemon, which is apparently the best solution for Linux at the time of this article.</p>
<p><strong>Install atftpd</strong></p>
<p>Obviously the installation requires root access, so make sure that you sudo.</p>
<p>1. root@server:/# apt-get install atftpd</p>
<p><strong>Configure atftpd</strong></p>
<p>1. root@server:/# vi /etc/default/atftpd</p>
<p>We are going to change USE_INETD to false and then if you feel like it, remove some of the options. Be sure to add the option &#8220;&#8211;daemon&#8221;, as shown below:</p>
<blockquote><p>USE_INETD=false<br />
OPTIONS=&#8221;&#8211;tftpd-timeout 300 &#8211;retry-timeout 5 &#8211;maxthread 100 &#8211;verbose=5 &#8211;daemon /var/lib/tftpboot/&#8221;</p></blockquote>
<p>If you do not add the &#8211;daemon option, then atftpd daemon will not start when you restart with /etc/init.d/atftpd restart. Instead it will display the atftpd options, as though you ran the binary file from /usr/sbin/atftpd.</p>
<p>If you are interested in learning about the options, be sure to read the <a href="http://linux.die.net/man/8/atftpd" target="_blank">atftpd man page</a>.</p>
<p>2. root@server:/# /etc/init.d/atftpd restart</p>
<p>This command will restart the deamon with the new settings.</p>
<p><strong>Testing the TFTP Server</strong></p>
<p>The final step, unless you think you are totally awesome or trust my articles, is to test the TFTP server to make sure that it works. You can accomplish this from a Windows machine by running a command similar to (the -i means binary trasnfer):</p>
<p>1. C:\tftp -i server_address put picture.gif</p>
<p>From a Linux machine, you can install tftp (apt-get install tftp).</p>
<p><strong>Other Notes</strong></p>
<p>I didn&#8217;t like the default location of /var/lib/tftpboot/ for the files to be stored. I have a directory called /datastore/ that I put all of my files into for backup purposes.</p>
<p>After attempting to configure atftpd to use a different location, such as changing the path specified in /etc/default/atftpd, I was unable to change to a new location. With that stated, I made a symbolic link in /datastore/ to point to /var/lib/tftpboot/, which is good enough for me.</p>
<p>1. root@server:/datastore# ln -s /var/lib/tftpboot/ ./tftproot</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/configure-tftp-on-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a Simple DNS Server with Bind9</title>
		<link>http://www.devtrends.com/index.php/setting-up-a-simple-dns-server-with-bind9/</link>
		<comments>http://www.devtrends.com/index.php/setting-up-a-simple-dns-server-with-bind9/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 01:11:33 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[bind9]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=456</guid>
		<description><![CDATA[I am starting to step outside of the Microsoft realm and into the Linux world. Imagine me balancing on my right leg which is in the Microsoft bucket, slowly and cautiously...]]></description>
			<content:encoded><![CDATA[<p>I am starting to step outside of the Microsoft realm and into the Linux world. Imagine me balancing on my right leg which is in the Microsoft bucket, slowly and cautiously testing the water in the Linux bucket with my bare left foot. Is the water too cold or is it too hot? Hmm, interestingly, the water seems to be quite pleasant.</p>
<p>Recently I migrated core functionality from my home Windows 2000 Server to a new host running ESXi 4.0 with three Ubuntu Server 9.10 VMs. If you want to see a simple diagram on my set up, view my article on <a href="http://www.devtrends.com/index.php/linux-backup-shell-script/" target="_self">Linux Backup Shell Script</a>. One of the core functionality that I migrated was my internal DNS services. Hence the title of this article, DNS Server with Bind9.</p>
<p><strong>bind9</strong></p>
<p>I am impressed, once again, with Linux and the services residing within this amazing operating system. The most amazing part about Linux services is that many of them have been around as long as I have &#8212; where have I been?</p>
<p>Before I begin rambling too much, let&#8217;s get started on creating DNS forward and reverse zones for your local network &#8230;</p>
<p>First ensure you have bind9 installed by running the following command:</p>
<pre style="padding-left: 30px;">whereis bind</pre>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2009/11/whereis.jpg"></a><a href="http://www.developingtrends.net/wp-content/uploads/2009/11/whereis.jpg"><img class="alignnone size-full wp-image-486" title="whereis" src="http://www.developingtrends.net/wp-content/uploads/2009/11/whereis.jpg" alt="whereis" width="523" height="36" /></a></p>
<p>If the results is blank, such as just &#8220;bind: &#8220;, then you will need to install bind9. On Ubuntu, I would imagine the command would look like this:</p>
<pre style="padding-left: 30px;">sudo apt-get install bind9</pre>
<p><strong>Forward Zones</strong></p>
<p>We need to configure your DNS forward zones, which will provide name to address resolution in your internal network. As we progress the configuration, keep in mind that your specific configuration will be slightly different than mine; adapt as needed.</p>
<p>For simple networks, such as mine at home, there are only a few changes that you will need to make for Forward lookup zones. The first file is /etc/bind/db.local.</p>
<p><span style="text-decoration: underline;">/etc/bind/db.local</span></p>
<p>The changes are fairly easy because we going to use most of what is provided in the original file. Change the Start of Authority (SOA) to be the domain environment for your network. My domain is dt.local and my primary DNS server is dtsfile.dt.local. Change the SOA to reflect your choices and also change the nameserver (NS) line to be your primary DNS server.</p>
<p>Also, you will want to add A records for your various servers/computers on the network. For this example, I added my Asterisk server:</p>
<pre style="padding-left: 30px;">dtsvoip.dt.local.	IN	A	192.168.0.11</pre>
<p>The next file to change, which we will also make changes for reverse DNS at the same time, is the /etc/bind/named.conf.default-zones file.</p>
<p><span style="text-decoration: underline;">/etc/bind/named.conf.default-zones</span></p>
<p>The line for the primary zone, which references the /etc/bind/db.local file must state your local domain in the quotes following the zone directive:</p>
<pre style="padding-left: 30px;">zone “dt.local” {
  type master;
  file “/etc/bind/db.local”;
};</pre>
<p>As we have more changes in this file, leave it open and continue to the next section.</p>
<p><strong>Reverse Lookup Zones</strong></p>
<p>As you probably know, a reverse lookup provides a name to an IP address. In Windows you would find the name of 192.168.0.10 by typing “nslookup 192.168.0.10” from a command prompt. If you have configured reverse DNS properly, you will see output similar to this:</p>
<pre style="padding-left: 30px;">C:\&gt;nslookup 192.168.0.10
Server:  dtsfile.dt.local
Address:  192.168.0.10</pre>
<pre style="padding-left: 30px;">Name:    dtsfile.dt.local
Address:  192.168.0.10</pre>
<p>You may be wondering why the entry appears twice. This is because the Server and the name that I am looking up is the same server. If I were to locate my Asterisk server, it would look like this:</p>
<pre style="padding-left: 30px;">C:\&gt;nslookup 192.168.0.11
Server:  dtsfile.dt.local
Address:  192.168.0.10</pre>
<pre style="padding-left: 30px;">Name:    dtsvoip.dt.local
Address:  192.168.0.11
</pre>
<p>On with the configuration…</p>
<p><span style="text-decoration: underline;">/etc/bind/named.conf.default-zones</span></p>
<p>If you were paying attention in the previous section you would still have that file open. Regardless, let’s add another zone to the file that represents our reverse lookup for the IP subnet in your network. In my network I use 192.168.0.0/24 which is the same as saying 192.168.0.0 with a subnet of 255.255.255.0 (192.168.0.0 to 192.168.0.255).</p>
<p>Immediately after the zone directive for your domain, add the following text for your reverse lookup:</p>
<pre style="padding-left: 30px;">zone “0.168.192.in-addr.arpa” {
  type master;
  file “/etc/bind/db.0.168.192”;
};
</pre>
<p>If you&#8217;re sharp, you’ll immediately know that the file db.0.168.192 doesn’t exist. We’ll create it next. And yes, it’s backwards; in reverse DNS lookups the IP address is reversed as part of the requirements set in the RFC and obviously for functionality pointing back to the host name of the IP. Read more: <a href="http://en.wikipedia.org/wiki/Reverse_DNS_lookup" target="_blank">http://en.wikipedia.org/wiki/Reverse_DNS_lookup</a></p>
<p>Save changes to named.conf.default-zones.</p>
<p><span style="text-decoration: underline;">/etc/bind/db.0.168.192</span></p>
<p>Next we’ll create a new zone db file for our newly created reverse lookup. Start by copying db.0 into a new file named db.0.168.192 (or whatever your local subnet IP address is).</p>
<pre style="padding-left: 30px;">cp /etc/bind/db.0 /etc/bind/db.0.168.192
</pre>
<p>Just like in your db.local file, let’s change the SOA to reflect your domain and nameserver. This includes the NS line that should already exist in the file. Now let’s add pointer (PTR) records for your servers/computers on the network. I’ll use mine for examples:</p>
<pre style="padding-left: 30px;">10	IN	PTR	dtsfile.dt.local
11	IN	PTR	dtsvoip.dt.local
</pre>
<p>Save changes to db.0.168.192.</p>
<p><strong>Forwarders</strong></p>
<p>The last section, assuming you want to use this DNS server as your primary DNS on all computers, is to set up a forwarder for all names that are not a part of your network. You will need to edit /etc/bind/named.conf.options.</p>
<p><span style="text-decoration: underline;">/etc/bind/named.conf.options</span></p>
<p>The change is really simple, uncomment the forwarders directive and modify the IP address within to be your local router or your ISP DNS servers. Mine is similar to the following:</p>
<pre style="padding-left: 30px;">forwarders {
  192.168.0.1;
};
</pre>
<p><strong>Local Name Resolution</strong></p>
<p>The final step is to change your /etc/resolv.conf file to point your DNS server and to set the domain and search realm. This is what mine looks like:</p>
<pre style="padding-left: 30px;">domain dt.local
search dt.local
nameserver 192.168.0.1
</pre>
<p><strong>Restart the bind9 daemon</strong></p>
<p>After making all of these changes, the final is to restart the bind9 daemon. Oh, one other step is to change your computers to use this DNS server as the primary.</p>
<p><strong>Configuration Files Examples</strong></p>
<p><span style="text-decoration: underline;">/etc/bind directory listing</span></p>
<pre style="padding-left: 30px;">/etc/bind# ls -la
drwxr-sr-x   2 root bind  4096 2010-08-01 17:52 .
drwxr-xr-x 141 root root 12288 2010-08-01 17:54 ..
-rw-r--r--   1 root root   237 2009-08-19 15:00 db.0
-rw-r--r--   1 root root   271 2009-08-19 15:00 db.127
-rw-r--r--   1 root bind   295 2010-08-01 17:22 db.0.168.192
-rw-r--r--   1 root root   237 2009-08-19 15:00 db.255
-rw-r--r--   1 root root   353 2009-08-19 15:00 db.empty
-rw-r--r--   1 root root   316 2010-08-01 17:14 db.local
-rw-r--r--   1 root root  2940 2009-08-19 15:00 db.root
-rw-r--r--   1 root bind   463 2009-08-19 15:00 named.conf
-rw-r--r--   1 root bind   573 2010-08-01 16:50 named.conf.default-zones
-rw-r--r--   1 root bind   165 2009-08-19 15:00 named.conf.local
-rw-r--r--   1 root bind   570 2010-07-16 11:58 named.conf.options
-rw-r-----   1 bind bind    77 2010-01-30 11:50 rndc.key
-rw-r--r--   1 root root  1317 2009-08-19 15:00 zones.rfc1918</pre>
<p><span style="text-decoration: underline;">./db.0.168.192</span></p>
<pre style="padding-left: 30px;">;
; BIND reverse data file for broadcast zone
;
$TTL    604800
@       IN      SOA     dt.local. dtsfile.dt.local. (
        1         ; Serial
   604800         ; Refresh
    86400         ; Retry
  2419200         ; Expire
   604800 )       ; Negative Cache TTL
;
@       IN      NS      dt.local.
10     IN      PTR     dtsfile.dt.local.
11     IN      PTR     dtsvoip.dt.local.
</pre>
<p><span style="text-decoration: underline;">./db.local</span></p>
<pre style="padding-left: 30px;">;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     dt.local. dtsfile.dt.local. (
        2         ; Serial
   604800         ; Refresh
    86400         ; Retry
  2419200         ; Expire
   604800 )       ; Negative Cache TTL
;
@       IN      NS      dtsfile.dt.local.
@       IN      A       127.0.0.1
@       IN      AAAA    ::1
dtsvoip.dt.local.       IN      A       192.168.0.11
</pre>
<p><span style="text-decoration: underline;">./named.conf.default-zones</span></p>
<pre style="padding-left: 30px;">// prime the server with knowledge of the root servers
zone "." {
  type hint;
  file "/etc/bind/db.root";
};</pre>
<pre style="padding-left: 30px;">// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912</pre>
<pre style="padding-left: 30px;">zone "dt.local" {
  type master;
  file "/etc/bind/db.local";
};</pre>
<pre style="padding-left: 30px;">zone "0.168.192.in-addr.arpa" {
  type master;
  file "/etc/bind/db.0.168.192";
};</pre>
<pre style="padding-left: 30px;">zone "127.in-addr.arpa" {
  type master;
  file "/etc/bind/db.127";
};</pre>
<pre style="padding-left: 30px;">zone "0.in-addr.arpa" {
  type master;
  file "/etc/bind/db.0";
};</pre>
<pre style="padding-left: 30px;">zone "255.in-addr.arpa" {
  type master;
  file "/etc/bind/db.255";
};
</pre>
<p><span style="text-decoration: underline;">./named.conf.options</span></p>
<pre style="padding-left: 30px;">options {
directory "/var/cache/bind";</pre>
<pre style="padding-left: 30px;">// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk.  See http://www.kb.cert.org/vuls/id/800113</pre>
<pre style="padding-left: 30px;">// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.</pre>
<pre style="padding-left: 30px;">forwarders {
  192.168.0.1;
};</pre>
<pre style="padding-left: 30px;">auth-nxdomain no;    # conform to RFC1035
  listen-on-v6 { any; };
};
</pre>
<p><span style="text-decoration: underline;">/etc/resolv.conf</span></p>
<pre style="padding-left: 30px;">domain dt.local
search dt.local
nameserver 192.168.0.1</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/setting-up-a-simple-dns-server-with-bind9/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux Backup Shell Script</title>
		<link>http://www.devtrends.com/index.php/linux-backup-shell-script/</link>
		<comments>http://www.devtrends.com/index.php/linux-backup-shell-script/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 06:39:39 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=467</guid>
		<description><![CDATA[Once again, I am pushing my knowledge limits with the Linux world. The exciting part is that, the deeper I go, the better Linux gets. Today, it is Shell scripting,...]]></description>
			<content:encoded><![CDATA[<p>Once again, I am pushing my knowledge limits with the Linux world. The exciting part is that, the deeper I go, the better Linux gets. Today, it is Shell scripting, which quite frankly puts DOS batch files out of business. Wait a moment, which came first?</p>
<p>Onward and upward, today I will share a script I use for backing files on my Ubuntu Server. To start off and to help explain what the script does, let me first explain my configuration. I have an ESXi 4.0 server with 3 VMs, all Ubuntu Server instances for Core services (DNS, DHCP, Directory services), Email (Yahoo&#8217;s Zimbra), and File (SAMBA shares, LAMP). All of the servers have 30GB primary partitions, provisioned through VMware and located on an internal 500GB SATA. The File server has a additional partition on the 500GB drive for all SAMBA shares and a partition located on an internal 1TB SATA drive that is used for backup.</p>
<p><a href="http://www.developingtrends.net/wp-content/uploads/2009/11/ESX-network.jpg"><img class="alignnone size-medium wp-image-472" title="ESX network" src="http://www.devtrends.com/wp-content/uploads/2009/11/ESX-network-300x272.jpg" alt="ESX network" width="300" height="272" /></a></p>
<p>The script provides backup functionality for my music, pictures, user&#8217;s folders, et cetera to the backup drive. The secondary partition on the 500GB drive is mounted to /datashare/ and the tertiary partition on the 1TB drive is mounted to /databackup/.</p>
<p><strong>The Script</strong></p>
<pre style="padding-left: 30px;">#!/bin/sh
#####
#  backup files script, version 1.
#
#  this script keeps one tar file per month for 12 months and rsyncs the entire contents
#  to $destination/daily_replica.
#  the idea is to run this script at least once per day to ensure proper sync and monthly tar.
#
#  created by Aaron @ www.devtrends.com
#####

# location of backup files (recursive sub-folders).
backup_files="/datastore/share"

# location to place tar files and /daily_replica/ directory.
destination="/databackup/share"

#### no editing beyong this line is required!
#### function for TARing
funcTar()
{
 options="--create --file="
 echo " -- tar'ing up $1 to $2/$3"
 echo "   \ creating new archive file: $3"
 tar $options$2/$3 $1
 echo "   \ tar backup completed."
}
#### end funcion

#### CREATE MONTHLY TAR FILE
# Create new archive filename.
month=$(date +%m)
year=$(date +%Y)
archive_file="backup-$month.tar"
full_path_archive_file="$destination/$archive_file"

# do I need to create a new monthly archive file?
# check if the file exists
if [ -f $full_path_archive_file ]; then

 # get file date
 filedate=$(stat -c %y $full_path_archive_file)
 # extract only the year of the file
 filedate=${filedate:0:4}

 # check if the file year is not the current year
 if [ ! $filedate == $year ]; then

 # remove old file
 rm $full_path_archive_file
 # create new tar
 funcTar $backup_files $destination $archive_file

 else

 echo " -- no tar'ing required today."

 fi

else

 # create new tar
 funcTar $backup_files $destination $archive_file

fi
#### DONE WITH TAR

#### rsync time...
echo " -- rsync $backup_files to $destination/daily_replica"
rsync -a $backup_files $destination/daily_replica
echo "   \ rsync completed."
####</pre>
<p>If you hate copy and paste, you may download the script <a href="http://www.devtrends.com/downloads/backup_share.zip" target="_blank">here</a>.</p>
<p><strong>Explanation</strong></p>
<p>For those that care, let me explain the script. The first two variables, $backup_files and $destination, should be the only variables you will need to change if you wish to use the script as I do.</p>
<pre style="padding-left: 30px;"># location of backup files (recursive sub-folders).
backup_files="/datastore/share"

# location to place tar files and /daily_replica/ directory.
destination="/databackup/share"</pre>
<p>The next block of code is the function used to create the tar file. The reason I made it into a function is because I use the same block of code twice in the main section of the script. No reason to duplicate code. However, the way I implemented the function may cause a problem if your $backup_files or $destination variables contain spaces. If anyone would like to revised, please share. The $1, $2, et cetera, are the argument variables as passed by the calling statement.</p>
<pre style="padding-left: 30px;">funcTar()
{
 options="--create --file="
 echo " -- tar'ing up $1 to $2/$3"
 echo "   \ creating new archive file: $3"
 tar $options$2/$3 $1
 echo "   \ tar backup completed."
}</pre>
<p>Next I define some variables that I will use throughout the script. The first two are date strings that contain the month (e.g. 11) and the year (e.g. 2009). The third and fourth variables hold the location of the tar file. The tar file name is comprised of the word &#8220;backup-&#8221; and then the variable of the month.</p>
<pre style="padding-left: 30px;">month=$(date +%m)
year=$(date +%Y)
archive_file="backup-$month.tar"
full_path_archive_file="$destination/$archive_file"</pre>
<p>The main section of code is next and consists of a nested if statement. The first if statement checks if a current backup tar file exists, if not, then it will create one, otherwise it will check the status of the current backup tar file. If the current tar file modified date is not in the current year, then it removes that tar file and recreates it, otherwise there is no need to tar anything. The most interesting piece is the substring command, ${filedate:0:4} which only returns characters 0,1,2,3 from the variable $filedate. You will also notice the use of stat, which, depending on your distribution of Linux, you may need to manually acquire.</p>
<pre style="padding-left: 30px;"># do I need to create a new monthly archive file?
# check if the file exists
if [ -f $full_path_archive_file ]; then
 # get file date
 filedate=$(stat -c %y $full_path_archive_file)
 # extract only the year of the file
 filedate=${filedate:0:4}

 # check if the file year is not the current year
 if [ ! $filedate == $year ]; then
  # remove old file
  rm $full_path_archive_file
  # create new tar
  funcTar $backup_files $destination $archive_file
 else
  echo " -- no tar'ing required today."
 fi

else
 # create new tar
 funcTar $backup_files $destination $archive_file
fi</pre>
<p>The last statement is the rsync command which synchronizes the entire content of the $backup_files location to the $destination/daily_replica/ location.</p>
<pre style="padding-left: 30px;">echo " -- rsync $backup_files to $destination/daily_replica"
rsync -a $backup_files $destination/daily_replica
echo "   \ rsync completed."</pre>
<p>Use this script at your own risk. If it turns out it didn&#8217;t back up your stuff, that is entirely your problem, not mine.</p>
<p>-Aaron Gilbert</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/linux-backup-shell-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Linux Console Modes (80&#215;25 &#8211; really?)</title>
		<link>http://www.devtrends.com/index.php/linux-console-modes-80x25-really/</link>
		<comments>http://www.devtrends.com/index.php/linux-console-modes-80x25-really/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 04:35:04 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[zFeatured]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[VGA Modes]]></category>

		<guid isPermaLink="false">http://www.devtrends.com/?p=243</guid>
		<description><![CDATA[I grew up using DOS, starting with DOS 2 something. I had a father that never stuck with the default settings, which included modifying the command prompt design/colors and the...]]></description>
			<content:encoded><![CDATA[<p>I grew up using DOS, starting with DOS 2 something. I had a father that never stuck with the default settings, which included modifying the command prompt design/colors and the screen text dimensions of the DOS window. The default was 80 characters or columns wide with 25 lines or rows high, or 80&#215;25. It seems this is STILL the default setting &#8211; I guess old school video modes stick around for quite some time. Regardless, 80&#215;25 does not work for me in Linux &#8211; I have to &#8220;less&#8221; everything to be able to work with the help files, et cetera.</p>
<p><strong>VGA Mode</strong></p>
<p>For those DOS&#8217;ers, do you remember &#8220;mode 80&#8243; or &#8220;mode 40&#8243;? If you know of a quick command for Linux consoles let me know &#8230; otherwise, you can use the tip below to modify your screen resolution.</p>
<p><em><span style="text-decoration: underline;">/boot/grub/menu.lst</span></em></p>
<p>The key to changing the screen mode / screen resolution is to modify the menu.lst file and add the vga=[mode #] some where in the kernel call line &#8211; or at the end of it. After searching the Internet for some time, I compiled a list here of many of the vga modes available:</p>
<pre style="padding-left: 30px;">VGA MODE          MODE#
80x25              3840
80x50              3841
80x43              3842
80x28              3843
80x30              3845
80x34              3846
80x60              3847
320x200x8bit        816
320x200x16bit       782
320x200x32bit       783
320x240x8bit        820
320x240x16bit       821
320x240x32bit       822
640x480x8bit        769
640x480x16bit       785
640x480x32bit       786
800x600x8bit        771
800x600x16bit       788
800x600x32bit       789
1024x768x8bit       773
1024x768x16bit      791
1024x768x32bit      792
1280x800x8bit       864
1280x800x32bit      865
1440x900x8bit       868
1440x900x32bit      869</pre>
<p>On my Ubuntu Server, the kernel line was:</p>
<pre style="padding-left: 30px; white-space: pre-wrap; word-wrap: break-word;">kernel         /vmlinuz-2.6.28-11-server root=/dev/mapper/ubuntuserver-root ro quiet splash</pre>
<p>and I added vga=792 to the end of it:</p>
<pre style="padding-left: 30px; white-space: pre-wrap; word-wrap: break-word;">kernel         /vmlinuz-2.6.28-11-server root=/dev/mapper/ubuntuserver-root ro quiet splash vga=792</pre>
<p>I&#8217;m out&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtrends.com/index.php/linux-console-modes-80x25-really/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

