<?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>Linux System Administration and Security</title>
	<atom:link href="http://www.jasonbrown.us/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonbrown.us</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 02:58: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>Mounting a USB device in a Xen Guest</title>
		<link>http://www.jasonbrown.us/2012/01/mounting-usb-device-xen-guest/</link>
		<comments>http://www.jasonbrown.us/2012/01/mounting-usb-device-xen-guest/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 00:55:42 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Dom0]]></category>
		<category><![CDATA[DomU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=194</guid>
		<description><![CDATA[Mounting a USB device Attach the USB device to the Dom0 and run &#8216;dmesg&#8217; to see if the device attached Run &#8216;fdisk -l&#8217; to see if the drive is partitioned the way you want it For instance: [root@example ~]# fdisk -l /dev/sdc Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units ]]></description>
			<content:encoded><![CDATA[<p><strong>Mounting a USB device</strong></p>
<ol>
<li>Attach the USB device to the Dom0 and run &#8216;dmesg&#8217; to see if the device attached</li>
<li>Run &#8216;fdisk -l&#8217; to see if the drive is partitioned the way you want it</li>
<li>For instance:<br />
[root@example ~]# fdisk -l /dev/sdc<br />
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes<br />
255 heads, 63 sectors/track, 121601 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Device Boot Start End Blocks Id System<br />
dev/sdc1 1 121601 976760001 8e Linux LVM</li>
<li>Now find a drive letter that is not being used on the DomU, in this instance we&#8217;ll use /dev/sde</li>
<li>To attach the USB device to the DomU run the following command
<ul>
<li>xm block-attach exampledomu phy:/dev/sdc sde w</li>
</ul>
</li>
<li>You should now see the device on the DomU, run either &#8216;dmesg&#8217; or &#8216;fdisk -l&#8217; to verify</li>
<li>Mount the device as normal
<ul>
<li>mount /dev/sde1 /mnt/usb</li>
</ul>
</li>
</ol>
<p><strong>Unmounting the device</strong></p>
<ol>
<li>You first need to get the device id number from the block list. Do this by running:
<ul>
<li>xm block-list exampledomu</li>
</ul>
</li>
<li>This will return:<br />
Vdev BE handle state evt-ch ring-ref BE-path<br />
51712 0 0 4 9 8 /local/domain/0/backend/tap/23/51712<br />
2176 0 0 4 10 1338 /local/domain/0/backend/vbd/23/2176</li>
<li>The number you need to use to remove the device is 2176</li>
<li>Unmount the USB device from the DomU
<ul>
<li>umount /mnt/usb</li>
</ul>
</li>
<li>Now on the Dom0 run:</li>
<li>xm block-detach exampledomu 2176</li>
<li>You may now remove the USB device</li>
</ol>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Mounting+a+USB+device+in+a+Xen+Guest+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D194" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2012/01/mounting-usb-device-xen-guest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>802.1q and LACP network card bonding with Xen Dom0</title>
		<link>http://www.jasonbrown.us/2011/06/802-1q-lacp-network-card-bonding-xen-dom0/</link>
		<comments>http://www.jasonbrown.us/2011/06/802-1q-lacp-network-card-bonding-xen-dom0/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 00:58:49 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Redundancy]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Xen]]></category>
		<category><![CDATA[Bonding]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Dom0]]></category>
		<category><![CDATA[DomU]]></category>
		<category><![CDATA[dot1q]]></category>
		<category><![CDATA[LACP]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[VLAN]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=161</guid>
		<description><![CDATA[As you may/may not know, bonding is the ability of taking two or more network cards and make them act as one. This not only improves fail over, but it also increases the amount of network throughput for the server. The following will show you how to set up such an environment. For this to ]]></description>
			<content:encoded><![CDATA[<p>As you may/may not know, bonding is the ability of taking two or more network cards and make them act as one. This not only improves fail over, but it also increases the amount of network throughput for the server. The following will show you how to set up such an environment. For this to work you must have a switch that is capable of combining multiple switch ports together. This can be done on either a single switch (which is still a single point of failure) or a switch that is stackable such as Cisco&#8217;s 3750 line of products.</p>
<p>There are six different kinds of NIC bonding in Linux, the one we will set up is mode 4 which follows the 802.3ad standard known as link aggregate control protocol. This allows for an active-active grouping of network cards and in testing resulted in zero ping drop, though I did see a momentary spike in response time (from 2ms to 20-30ms during convergence).</p>
<ol>
<li>First you need to check that your network card is capable of 802.1q VLAN tagging. You will need to research the capabilities of the card to make sure. Run &#8216;lspci | grep -i ethernet&#8217; and note the response.</li>
<li>Second, check to see if the 802.1q module is installed by running &#8216;lsmod | grep 8021q&#8217;.  If its not installed then run &#8216;yum install bridge-utils&#8217;</li>
<li>Once those steps are done we can start configuring the network cards.  Go to /etc/sysconfig/network-scripts, in there you should see your network card configuration files; usually named &#8216;ifcfg-eth#&#8217;.  Write down or make a backup copy of the network information in your active NIC configuration file as you will need it later.</li>
<li>Edit your first configuration file with the following<br />
<blockquote><p><code><br />
DEVICE=eth0<br />
ONBOOT=yes<br />
BOOTPROTO=none<br />
USERCTL=no<br />
MASTER=bond0<br />
SLAVE=yes<br />
</code></p></blockquote>
</li>
<li>Your secondary card will contain the same information however the &#8216;DEVICE=eth#&#8217; should match the name of the second card.</li>
<li>Next we card the bonded interface, which then becomes the main device for the server. Create a new file named &#8216;ifcfg-bond0&#8242;:<br />
<blockquote><p><code><br />
DEVICE=bond0<br />
BOOTPROTO=none<br />
ONBOOT=yes<br />
TYPE=Ethernet<br />
USERCTL=no<br />
</code></p></blockquote>
</li>
<li>We now create the configuration file which will handle the 802.1q jumbo frames. Note that the device is named &#8216;bond0.17&#8242;. This is important as the &#8217;17&#8242; is the VLAN ID which the server will listen on. Make sure you know which VLAN&#8217;s are in your environment! Create a file named &#8216;ifcfg-bond0.17&#8242;:<br />
<blockquote><p><code><br />
DEVICE=bond0.17<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
VLAN=yes<br />
TYPE=Ethernet<br />
BRIDGE=xenbr17 </code></p></blockquote>
<p>&nbsp;</li>
<li>The &#8216;BRIDGE&#8217; string is also important as this will tie the bond0.17 config file to the Xen bridge we are about to create. Repeat that step for every VLAN that you want your server to listen to.</li>
<li>Next we will create the configuration file that the DomU will be given. Create a file called &#8216;ifcfg-xenbr17&#8242; and place the following:<br />
<blockquote><p><code><br />
DEVICE=xenbr17<br />
TYPE=Bridge<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
DELAY=0<br />
STP=off </code></p></blockquote>
<p>&nbsp;</li>
<li>We will now create the management interface for the server. The management interface should have the same security restrictions as a management interface would have for a switch or any other network device. If someone compromises your Dom0, then all of your DomU&#8217;s are also compromised. ACL&#8217;s should be implemented for this network!<br />
<blockquote><p><code><br />
DEVICE=xenbr192<br />
TYPE=Bridge<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
DELAY=0<br />
STP=off<br />
IPADDR=192.168.1.12<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.1.0<br />
BROADCAST=192.168.1.255 </code></p></blockquote>
<p>&nbsp;</li>
<li>Edit the /etc/modprobe.conf file and append the following:<br />
<blockquote><p><code><br />
alias bond0 bonding<br />
options bond0 miimon=100 mode=4 lacp_rate=1 </code></p></blockquote>
<p>&nbsp;</li>
<li>That told the server what type of network bonding we will use. &#8216;mode=4&#8242; tells the server that we want to use 802.3ad as our protocol for communication to the switch device.</li>
<li>Edit the /etc/xen/xend-config.sxp file, change where it says &#8216;(network-script network-bridge)&#8217; to &#8216;(network-script &#8216;network-bridge-bonding bridge=bond0 netdev=0&#8242;)&#8217;</li>
<li>Now reboot the server</li>
</ol>
<p>The next steps we will configure a Cisco switch, create the port channel, and configure it for LACP with 802.1q trunking.</p>
<ol>
<li>Log into your switch, go to the global configuration mode and create a port channel interface by typing &#8216;int port-c 1&#8242;</li>
<li>Enter the following:<br />
<blockquote><p><code><br />
switchport trunk encapsulation dot1q<br />
switchport mode trunk </code></p></blockquote>
<p>&nbsp;</li>
<li>Now go to the actual switch interfaces and enter the following:<br />
<blockquote><p><code><br />
switchport trunk encapsulation dot1q<br />
switchport mode trunk<br />
channel-group 1 mode active </code></p></blockquote>
<p>&nbsp;</li>
<li>If the switch ports had originally been set up as an access interface, you can remove the configuration by entering:<br />
<blockquote><p><code><br />
no switchport mode access<br />
no switchport access vlan <em>VLAN ID</em> </code></p></blockquote>
<p>&nbsp;</li>
<li>Now save the configuration file</li>
</ol>
<p>Installation of new DomU&#8217;s will be the same as before by giving them a &#8216;xenbr#&#8217; interface</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=802.1q+and+LACP+network+card+bonding+with+Xen+Dom0+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D161" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2011/06/802-1q-lacp-network-card-bonding-xen-dom0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyMyDB Backup 0.5.1</title>
		<link>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/</link>
		<comments>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 17:49:09 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[PyMyDB]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=133</guid>
		<description><![CDATA[The first version of PyMyDB Backup has been released and is based on Python 2.4.3. This is a Python script that will back up your MySQL databases, calculate the size of the backed up files, tarball and compress the contents, then email the results. To use: Download the EPEL RPM which can be found at: ]]></description>
			<content:encoded><![CDATA[<p>The first version of PyMyDB Backup has been released and is based on Python 2.4.3. This is a Python script that will back up your MySQL databases, calculate the size of the backed up files, tarball and compress the contents, then email the results.</p>
<p>To use:</p>
<ol>
<li>Download the EPEL RPM which can be found at: <a href="http://download.fedora.redhat.com/pub/epel/">http://download.fedora.redhat.com/pub/epel/</a></li>
<li>Install pymydb-0.5.1-1.noarch.rpm which can be found at: <a href="https://github.com/jasonbrown17/PyMyDB">GitHub</a></li>
<ul>
<li>This script creates the necessary directories and user account</li>
</ul>
<li>After installation, there will be two scripts placed in /usr/local/bin which are pymydb.py and setup.py</li>
<li>Run the setup.py script, this will configure the pymydb.py script</li>
<ul>
<li>Logs into the MySQL server</li>
<li>Creates the backup user, sets a password, and gives him select and lock tables privileges</li>
<li>Configures the email settings</li>
</ul>
<li>Change the permissions on the pymydb.py script</li>
<ul>
<li>chown root.pymydb pymydb.py</li>
</ul>
<li>Add the pymydb.py script into cron and make sure to add a password for the system user</li>
</ol>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=PyMyDB+Backup+0.5.1+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D133" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Backup Script</title>
		<link>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/</link>
		<comments>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 04:03:18 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=122</guid>
		<description><![CDATA[I needed a place to host my scripts, so I opened an account on GitHub. If you are unaware of what GitHub is, its a great place to publish code to the public by using Git; they also offer private hosting for a fee. Even if you do not have a need for this I ]]></description>
			<content:encoded><![CDATA[<p>I needed a place to host my scripts, so I opened an account on GitHub. If you are unaware of what GitHub is, its a great place to publish code to the public by using Git; they also offer private hosting for a fee. Even if you do not have a need for this I recommend looking through the site as its a great place to view open source projects.</p>
<p>There are a lot of examples and scripts out on the Internet to automate MySQL backups but not a whole lot written in Python. This was developed to use in a MySQL replication environment and should be run on the slave server. This is an optimal solution as backup&#8217;s can run without affecting production. The script dumps each database individually, calculates the size of the sql backup, tarball them up, and emails a log when its done.</p>
<p>To run this the MySQLdb module must be installed on the server. You should also create a user specifically designed to run backups. You can effectively do this by running:</p>
<blockquote><p><code>grant select, lock tables on *.* to backup@'localhost' identified by 'password';</code></p></blockquote>
<p>The password is stored in base64 format. To encrypt the password for use in the script, run the following command within the Python terminal:</p>
<blockquote><p><code><br />
&gt;&gt;&gt; from base64 import b64encode as encode<br />
&gt;&gt;&gt; encode("password")<br />
'cGFzc3dvcmQ='</code></p></blockquote>
<p>Though this is not the most secure way to encrypt a password to use within a script, it will prevent shoulder surfers.</p>
<p>Here it is, enjoy &#8211; https://github.com/jasonbrown17/MySQL-Backups</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=MySQL+Backup+Script+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D122" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Replication</title>
		<link>http://www.jasonbrown.us/2010/12/mysql-replication/</link>
		<comments>http://www.jasonbrown.us/2010/12/mysql-replication/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 18:21:12 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Redundancy]]></category>
		<category><![CDATA[Replication]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=103</guid>
		<description><![CDATA[Setting up MySQL replication is an easy process to do. First you need to edit your my.cnf files on your two servers and add the following: Server 1 server-id=1 auto_increment_offset=1 auto_increment_increment=3 log-bin=mysql_log Server 2 server-id=2 auto_increment_offset=1 auto_increment_increment=3 log-bin=mysql_log Make sure that the server id&#8217;s in the my.cnf file are unique for each server and the ]]></description>
			<content:encoded><![CDATA[<p>Setting up MySQL replication is an easy process to do. First you need to edit your my.cnf files on your two servers and add the following:</p>
<p>Server 1</p>
<blockquote><p>server-id=1<br />
auto_increment_offset=1<br />
auto_increment_increment=3<br />
log-bin=mysql_log</p></blockquote>
<p>Server 2</p>
<blockquote><p>server-id=2<br />
auto_increment_offset=1<br />
auto_increment_increment=3<br />
log-bin=mysql_log</p></blockquote>
<p>Make sure that the server id&#8217;s in the my.cnf file are unique for each server and the auto_increment_increment is n+1 more than the total amount of servers in your environment. This way your slave servers will update correctly. Once that is complete, restart the MySQL Service</p>
<blockquote><p>service mysqld restart</p></blockquote>
<p>To configure your slave user, log into the master and type the following:</p>
<blockquote><p>mysql&gt; create user slaveuser@&#8217;slavehost.example.com&#8217; identified by &#8216;somepassword&#8217;;<br />
mysql&gt; grant replication slave on *.* to slaveuser@&#8217;slavehost.example.com&#8217;<br />
mysql&gt; flush privileges;</p></blockquote>
<p>The next step is to dump the database from your primary server and import it on the slave server. To dump the database:</p>
<blockquote><p>mysqldump -u root -p &#8211;lock-tables database &gt; database.sql</p></blockquote>
<p>Import the database on the slave server:</p>
<blockquote><p>mysql -u root -p database &lt; database.sql</p></blockquote>
<p>We need to get the log file and position information from the master server in order to sync it with the slave. First lock the tables so no changes can be made and then show the status.</p>
<blockquote><p>mysql&gt; FLUSH TABLES WITH READ LOCK;<br />
mysql&gt; show master status;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
| mysql_log.000006 | 156005305 | | |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
1 row in set (0.00 sec)</p></blockquote>
<p>Configure the slave server to attach to the master with the correct credentials. Note the MASTER_LOG_FILE and the MASTER_LOG_POS information need to be identical as the master.</p>
<blockquote><p>mysql&gt; CHANGE MASTER TO<br />
-&gt; MASTER_HOST=&#8217;masterhost.example.com&#8217;,<br />
-&gt; MASTER_USER=&#8217;slaveuser&#8217;,<br />
-&gt; MASTER_PASSWORD=&#8217;somepassword&#8217;,<br />
-&gt; MASTER_LOG_FILE=&#8217;mysql-bin.000006&#8242;,<br />
-&gt; MASTER_LOG_POS=156005305;</p></blockquote>
<p>Next start the replication</p>
<blockquote><p>mysql&gt; START SLAVE;</p></blockquote>
<p>Unlock the tables on the master</p>
<blockquote><p>mysql&gt; UNLOCK TABLES;</p></blockquote>
<p>Check to make sure that it is running properly</p>
<blockquote><p>mysql&gt; show slave status\G;<br />
*************************** 1. row ***************************<br />
Slave_IO_State: Waiting for master to send event<br />
Master_Host: masterhost.example.com<br />
Master_User: slaveuser<br />
Master_Port: 3306<br />
Connect_Retry: 60<br />
Master_Log_File: mysql_log.000006<br />
Read_Master_Log_Pos: 156005305<br />
Relay_Log_File: mysqld-relay-bin.000146<br />
Relay_Log_Pos: 107097880<br />
Relay_Master_Log_File: mysql_log.000006<br />
Slave_IO_Running: Yes<br />
Slave_SQL_Running: Yes<br />
Replicate_Do_DB:<br />
Replicate_Ignore_DB:<br />
Replicate_Do_Table:<br />
Replicate_Ignore_Table:<br />
Replicate_Wild_Do_Table:<br />
Replicate_Wild_Ignore_Table:<br />
Last_Errno: 0<br />
Last_Error:<br />
Skip_Counter: 0<br />
Exec_Master_Log_Pos: 155994592<br />
Relay_Log_Space: 107097880<br />
Until_Condition: None<br />
Until_Log_File:<br />
Until_Log_Pos: 0<br />
Master_SSL_Allowed: No<br />
Master_SSL_CA_File:<br />
Master_SSL_CA_Path:<br />
Master_SSL_Cert:<br />
Master_SSL_Cipher:<br />
Master_SSL_Key:<br />
Seconds_Behind_Master: 0<br />
1 row in set (0.00 sec)</p></blockquote>
<p>To set up a master-master replication, repeat the process on the second MySQL server.</p>
<p>That&#8217;s it!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=MySQL+Replication+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D103" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/12/mysql-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple VLAN&#8217;s with Xen Dom0</title>
		<link>http://www.jasonbrown.us/2010/08/multiple-vlans-with-xen-dom0/</link>
		<comments>http://www.jasonbrown.us/2010/08/multiple-vlans-with-xen-dom0/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 17:06:25 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Xen]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Dom0]]></category>
		<category><![CDATA[DomU]]></category>
		<category><![CDATA[dot1q]]></category>
		<category><![CDATA[VLAN]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=46</guid>
		<description><![CDATA[A great feature of Linux and Xen is the ability to run DomU&#8217;s on multiple networks. To do this we first need to set up the VLAN&#8217;s on a switch and then set the port the Dom0 is connected to allow for 802.11q traffic. On a Cisco switch, log into the IOS and change the ]]></description>
			<content:encoded><![CDATA[<p>A great feature of Linux and Xen is the ability to run DomU&#8217;s on multiple networks. To do this we first need to set up the VLAN&#8217;s on a switch and then set the port the Dom0 is connected to allow for 802.11q traffic. On a Cisco switch, log into the IOS and change the interface that the server is sitting on and type:<br />
<code>switch(config-if) switchport trunk encapsulation dot1q<br />
switch(config-if) switchport mode trunk</code></p>
<p>Once this is done we can then configure Dom0 to communicate to these networks. In CentOS, you need to change directories to <code>/etc/sysconfig/network-scripts</code>.</p>
<p>First copy the ifcfg-eth0 file to make a back up then edit the file as follows:<br />
<code>DEVICE=eth0<br />
HWADDR=<br />
ONBOOT=yes<br />
BOOTPROTO=none</code></p>
<p>Next we create four new files which will define our VLAN and non-VLAN traffic. The first two files will define which VLANs the server should listen on:</p>
<p>Create the file: <code>/etc/sysconfig/network-scripts/ifcfg-eth0.17</code>. This will define VLAN 17.<br />
Then enter in the following:<code><br />
DEVICE=eth0.17<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
VLAN=yes<br />
TYPE=Ethernet<br />
BRIDGE=xenbr17</code></p>
<p>Make a secondary file which will sit on VLAN 192, VLAN 192 is where the IP of the Dom0 will reside.<br />
<code><br />
DEVICE=eth0.192<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
VLAN=yes<br />
TYPE=Ethernet<br />
BRIDGE=xenbr192</code></p>
<p>The next two files will define the bridged interfaces. These are necessary to strip the 802.1q header so the server and DomU&#8217;s can communicate across the network. The first file will be for the publicly routable network:<br />
<code><br />
DEVICE=xenbr17<br />
TYPE=Bridge<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
DELAY=0<br />
STP=off</code></p>
<p>The next file will be for the internal network.<br />
<code><br />
DEVICE=xenbr192<br />
TYPE=Bridge<br />
BOOTPROTO=static<br />
ONBOOT=yes<br />
DELAY=0<br />
STP=off<br />
IPADDR=192.168.1.12<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.1.0<br />
BROADCAST=192.168.1.255<br />
</code><br />
After that reboot the server.</p>
<p>Next create a virtual instance with virt-install and run it as follows:<code><br />
virt-install --name test --ram 1024 --location 'centos mirror' -f /dev/lvm/test -b xenbr17 -p</code><br />
The <code>'-b'</code> is important as it will define the bridge the new server will sit on.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Multiple+VLAN%E2%80%99s+with+Xen+Dom0+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D46" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/08/multiple-vlans-with-xen-dom0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Calculate Free Space Using Python</title>
		<link>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/</link>
		<comments>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 13:45:10 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=6</guid>
		<description><![CDATA[import os diskSpace = os.statvfs(&#8216;/&#8217;) (diskSpace.f_bavail * diskSpace.f_frsize) / (1024 * 1024)]]></description>
			<content:encoded><![CDATA[<p>import os<br />
diskSpace = os.statvfs(&#8216;/&#8217;)<br />
(diskSpace.f_bavail * diskSpace.f_frsize) / (1024 * 1024)</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Calculate+Free+Space+Using+Python+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D6" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Weak Ciphers in Dovecot</title>
		<link>http://www.jasonbrown.us/2010/02/disable-weak-ciphers-in-dovecot/</link>
		<comments>http://www.jasonbrown.us/2010/02/disable-weak-ciphers-in-dovecot/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 13:50:43 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Dovecot]]></category>
		<category><![CDATA[EMail]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Encryption]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=12</guid>
		<description><![CDATA[In running my periodic Nessus scans, it picked up a few medium severity vulnerabilities against Dovecot. One was &#8220;SSL Anonymous Cipher Suites Supported&#8221; and the other, &#8220;SSL Weak Cipher Suites Supported.&#8221; Look in the Dovecot config file located in /etc/dovecot.conf under &#8220;SSL ciphers to use&#8221; and you will see: ssl_cipher_list = ALL:!LOW:!MEDIUM To disable these ]]></description>
			<content:encoded><![CDATA[<p>In running my periodic Nessus scans, it picked up a few medium severity vulnerabilities against Dovecot. One was &#8220;SSL Anonymous Cipher Suites Supported&#8221; and the other, &#8220;SSL Weak Cipher Suites Supported.&#8221;</p>
<p>Look in the Dovecot config file located in /etc/dovecot.conf under &#8220;SSL ciphers to use&#8221; and you will see:<br />
<code>ssl_cipher_list = ALL:!LOW:!MEDIUM</code></p>
<p>To disable these weak ciphers change this to:<br />
<code>ssl_cipher_list = ALL:!LOW:!MEDIUM:!MD5:!SSL2:!EXP-ADH-DES-CBC-SHA:!EXP-EDH-RSA-DES-CBC-SHA:!EXP-DES-CBC-SHA:!EXP-EDH-RSA-DES-CBC-SHA:!EXP-ADH-DES-CBC-SHA:!EXP-DES-CBC-SHA:!ADH-AES256-SHA:!ADH-AES128-SHA:!ADH-DES-CBC3-SHA:!EXP-ADH-DES-CBC-SHA:!EXP-ADH-DES-CBC-SHA:!ADH-DES-CBC3-SHA</code></p>
<p>Run the Nessus scan again and those two vulnerabilities go away <img src='http://www.jasonbrown.us/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Disable+Weak+Ciphers+in+Dovecot+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D12" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/02/disable-weak-ciphers-in-dovecot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editing SELinux Policies</title>
		<link>http://www.jasonbrown.us/2010/02/editing-selinux-policies/</link>
		<comments>http://www.jasonbrown.us/2010/02/editing-selinux-policies/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:46:55 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[NSA]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[ausearch]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[ClamAV]]></category>
		<category><![CDATA[RHEL]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=8</guid>
		<description><![CDATA[There are times where SELinux just does not want to play nice. For instance, after installing ClamAV I began running into problems where if I did not turn off SELinux while ClamAV was running, then SMTP traffic would fail. To fix this issue we must first look at the messages file under /var/log. Within this ]]></description>
			<content:encoded><![CDATA[<p>There are times where SELinux just does not want to play nice. For instance, after installing ClamAV I began running into problems where if I did not turn off SELinux while ClamAV was running, then SMTP traffic would fail. To fix this issue we must first look at the messages file under /var/log. Within this file we will see error messages like:<br />
<code>setroubleshoot: SELinux is preventing cleanup (postfix_cleanup_t) "search" to ./clamav (clamd_var_lib_t).</code></p>
<p>Which tells you to run the command:<br />
<code>sealert -l a1bc9b39-80a2-4f2e-963f-12daf766a8d4</code></p>
<p>Usually the report is very good and diagnosing and telling you which booleans to activate, however in this instance we have to create our own module.</p>
<p>First: Download and install selinux-policy-devel<br />
Second: Parse through the raw audit messages. We are looking for two things; message type and comm name.<br />
Third: Run the ausearch command and pipe it to audit2allow<br />
For instance: <code>ausearch -m AVC --comm cleanup | audit2allow -M ClamAV</code></p>
<p>Once the files have been generated then run: <code>semodule -i ClamAV.pp</code> and see if the problem has been resolved. If not, tail the messages log again to see if there is any additional SEAlerts that you should be aware of.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Editing+SELinux+Policies+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D8" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/02/editing-selinux-policies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RHEL/CentOS 5 server security</title>
		<link>http://www.jasonbrown.us/2010/01/rhelcentos-5-server-security/</link>
		<comments>http://www.jasonbrown.us/2010/01/rhelcentos-5-server-security/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 13:52:09 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[NSA]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[sysctl]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=14</guid>
		<description><![CDATA[As a part of the sys admin&#8217;s job, it is important to take a few extra minutes to go through and properly secure a newly installed Linux server. These steps include enabling SELinux on the machine, configuring the firewall, and setting user permissions. There are however additional steps one should take in order to secure ]]></description>
			<content:encoded><![CDATA[<p>As a part of the sys admin&#8217;s job, it is important to take a few extra minutes to go through and properly secure a newly installed Linux server. These steps include enabling SELinux on the machine, configuring the firewall, and setting user permissions. There are however additional steps one should take in order to secure their server. One would be to tune and secure kernel parameters, set limits on kernel dumps, prevent IPv6 from loading if you company is not using it, and turning off unnecessary services.</p>
<p><em><strong><code>Networking</code></strong></em><br />
First, lets take a look at configuring kernel parameters to prevent network based attacks. These include disallowing intruders to alter routing tables and source routed packets, preventing an intruder from configuring the server to become a router, and turning on reverse path filtering. To change these settings edit the /etc/sysctl.conf file and enter:<br />
<code>net.ipv4.conf.all.accept_source_route = 0<br />
net.ipv4.conf.all.accept_redirects = 0<br />
net.ipv4.conf.all.secure_redirects = 0<br />
net.ipv4.conf.all.log_martians = 1<br />
net.ipv4.conf.default.accept_source_route = 0<br />
net.ipv4.conf.default.accept_redirects = 0<br />
net.ipv4.conf.default.secure_redirects = 0<br />
net.ipv4.icmp_echo_ignore_broadcasts = 1<br />
net.ipv4.icmp_ignore_bogus_error_messages = 1<br />
net.ipv4.tcp_syncookies = 1<br />
net.ipv4.conf.all.rp_filter = 1<br />
net.ipv4.conf.default.rp_filter = 1</code></p>
<p>If you are currently running IPv6 at your company, here are a few kernel parameters to prevent network based attacks:<br />
<code>net.ipv6.conf.default.router_solicitations = 0<br />
net.ipv6.conf.default.accept_ra_rtr_pref = 0<br />
net.ipv6.conf.default.accept_ra_pinfo = 0<br />
net.ipv6.conf.default.accept_ra_defrtr = 0<br />
net.ipv6.conf.default.autoconf = 0<br />
net.ipv6.conf.default.dad_transmits = 0<br />
net.ipv6.conf.default.max_addresses = 1</code></p>
<p>To make these settings effective without rebooting the server type <code>sysctl -p</code></p>
<p>We can go a step further by disabling unused network functions such as IPv6 and prevent self assigned addressing.</p>
<p>To detect whether or not IPv6 is running on a server type: <code>ifconfig | grep inet6</code> which will return:<br />
<code>inet6 addr: fe80::240:5ff:fe32:ef19/64 Scope:Link<br />
inet6 addr: ::1/128 Scope:Host<br />
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link</code><br />
To prevent IPv6 from loading, run the following command:<br />
<code>echo "install ipv6 /bin/true" &gt; /etc/modprobe.d/ipv6</code><br />
Then add the following lines to <code>/etc/sysconfig/network</code>:<br />
<code>NETWORKING_IPV6=no<br />
IPV6INIT=no</code><br />
This will deactivate the IPv6 protocol from running on the server.</p>
<p>To prevent self assigned addressing on network cards, open the <code>/etc/sysconfig/network</code> file and add:<br />
<code>NOZEROCONF=yes</code></p>
<p><em><strong><code>Server security</code></strong></em><br />
Turning off the ability to create core dumps is important as intruders can use this to gather information about running services and configurations in order to exploit them. To do so, edit the <code>/etc/security/limits.conf</code> file and insert:<br />
* hard core 0<br />
We should also prevent setuid programs from creating these as well:<br />
<code>sysctl -w fs.suid_dumpable=0</code></p>
<p>There are also built in kernel features which can help protect against buffer overflow attacks. These features are turned on by default, however these kernel parameters should be enabled in case they have been turned off:<br />
<code>sysctl -w kernel.exec-shield=1<br />
sysctl -w kernel.randomize_va_space=1</code><br />
These settings ensure randomization of the stack and memory regions, which are refereed to as the ExecShield.</p>
<p>There are many services which are running on a default installation which include cups, sendmail, isdn, bluetooth, and many others. If these services are not being used on the server then they should be turned off and configured not to start up on a reboot. To do so we can run the following bash script:<br />
<code>for i in acpid autofs avahi-daemon luetooth cups firstboot gpm hidd ip6tables sendmail exim xfs xinetd yum-updatesd rhnsd pcscd readahead_early readahead_later apmd hplip isdn ip6tables mcstrans<br />
do<br />
service $i stop<br />
chkconfig $i off<br />
done</code></p>
<p>Your services will vary depending on the installation. We should also ensure that X does not run on reboot, placing the server in run level three. To do so, edit the <code>/etc/inittab</code> file and change <code>id:5:initdefault:</code> to <code>id:3:initdefault:</code></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=RHEL%2FCentOS+5+server+security+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D14" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/01/rhelcentos-5-server-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

