<?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>lejnieks &#187; iptables</title>
	<atom:link href="http://www.lejnieks.com/tag/iptables/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lejnieks.com</link>
	<description></description>
	<lastBuildDate>Fri, 29 Jan 2010 19:22:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Setting up a CentOS server</title>
		<link>http://www.lejnieks.com/2008/11/17/setting-up-a-centos-server/</link>
		<comments>http://www.lejnieks.com/2008/11/17/setting-up-a-centos-server/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 05:14:49 +0000</pubDate>
		<dc:creator>klejnieks</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Webmin]]></category>

		<guid isPermaLink="false">http://lejnieks.com/?p=51</guid>
		<description><![CDATA[More recently I have been having some issues with Plesk, I&#8217;ve felt like I&#8217;ve been fighting with Plesk&#8217;s default generic templates and cookie cutter processes. What should be simple such as adding custom wars to Tomcat end up proving more times then not to be a royal pain. This passed month I ended up playing [...]]]></description>
			<content:encoded><![CDATA[<p>More recently I have been having some issues with Plesk, I&#8217;ve felt like I&#8217;ve been fighting with Plesk&#8217;s default generic templates and cookie cutter processes. What should be simple such as adding custom wars to Tomcat end up proving more times then not to be a royal pain. This passed month I ended up playing around with <a href="https://hudson.dev.java.net/">Hudson</a>, a Continous Integration server, and I found myself struggling through what should have been a seamless installation. Basically it took me 10 minutes to setup, install, and configure my first build in Hudson on my Mac but to be honest I ended up giving up after 3 days of struggling to get Hudson installed on my dedicated CentOS server that ran Plesk. Dont get me wrong, there are plenty of other things that bug me about Plesk but this latest thing was what ended up pushing me to get a basic server setup from scratch and configured exactly as I wanted it.</p>
<p><span id="more-51"></span></p>
<p>With that said, I would be remiss if I didn&#8217;t also mention that fact that, while I have some issue with plesk and its somewhat cookie cutter approach to web administration, it still is a great web administration tool for the most part.</p>
<p>My goal is basically to get a bare server up and running and administer-able without using Plesk or CPanel. The more I play around with this setup the more I will update the server section of this site with new configurations and additions as I learn them.</p>
<p><strong>Setting up a fresh CentOS server</strong></p>
<ol>
<li>Get a dedicated server from someone, I used <a href="http://aplus.net">aplus.net</a></li>
<li>Choose a basic installation, this means no plesk, cpanel etc&#8230; (keep in mind, eventually we will setup Webmin)</li>
<li>Start setting up your new box</li>
</ol>
<p><strong>The setup</strong><br />
shell into you server</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ssh root@111.111.11.111</span></pre></div></div>

<p>Install LAMP (Linux Apache MySQL PHP) installed.<br />
You will do this using <a href="http://en.wikipedia.org/wiki/Yellow_dog_Updater,_Modified">yum</a>. Yum is an rpm wrapper that will allow you to install various services and applications with a lot more ease.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum -y install httpd</span>
<span style="color: #666666; font-style: italic;"># yum -y install php</span>
<span style="color: #666666; font-style: italic;"># yum -y install mysql</span>
<span style="color: #666666; font-style: italic;"># yum -y install mysql-server</span>
<span style="color: #666666; font-style: italic;"># yum -y install php-mysql</span></pre></div></div>

<p><em>note: the -y switch forces &#8220;yes&#8221; when prompted, so you don&#8217;t have to</em></p>
<p>Next configure the services you just installed to start automatically when the server restarts</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /sbin/chkconfig httpd on</span>
<span style="color: #666666; font-style: italic;"># /sbin/chkconfig --add mysqld</span>
<span style="color: #666666; font-style: italic;"># /sbin/chkconfig mysqld on</span>
<span style="color: #666666; font-style: italic;"># /sbin/service httpd start</span>
<span style="color: #666666; font-style: italic;"># /sbin/service mysqld start</span></pre></div></div>

<p>At this point, you now have mysql installed, but you will want to set up the mysql database root password. Without a password, any user on the box can login to mysql as database root. The mysql root account is a separate password from the machine root account.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mysqladmin -u root password 'new-password'</span></pre></div></div>

<p>At this point, some of you may be able to navigate to your public ip address and see the default CentOS page, I was not able to see this. Basically at this point, what I had was LAMP installed on my shiny new server but no one would ever know because port 80 was blocked.</p>
<p><strong>Enter iptables.</strong>..<br />
Iptables is your firewall, its baked into CentOS, and its extremely powerful. I don&#8217;t know the complete depth of iptables but for this tutorial you&#8217;ll need to just get a few ports opened up and that&#8217;s it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># iptables -F</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p udp -m udp --dport domain -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp --dport 22 -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp --dport 10000 -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp --dport 25 -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp --dport 8080 -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp --dport 80 -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -p tcp -m tcp --dport domain -j ACCEPT</span>
<span style="color: #666666; font-style: italic;"># iptables -A FORWARD -o eth0 -j LOG  --log-level 7 --log-prefix BANDWIDTH_OUT:</span>
<span style="color: #666666; font-style: italic;"># iptables -A FORWARD -i eth0 -j LOG  --log-level 7 --log-prefix BANDWIDTH_IN:</span>
<span style="color: #666666; font-style: italic;"># iptables -A OUTPUT -o eth0 -j LOG  --log-level 7 --log-prefix BANDWIDTH_OUT:</span>
<span style="color: #666666; font-style: italic;"># iptables -A INPUT -i eth0 -j LOG  --log-level 7 --log-prefix BANDWIDTH_IN:</span></pre></div></div>

<p>make sure you save your iptables configuration so you don&#8217;t have to re-edit it when you reboot your server</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /sbin/service iptables save</span></pre></div></div>

<p>now just restart your firewall</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/iptables restart</span></pre></div></div>

<p>now you can check your configuration</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># iptables -L -v</span></pre></div></div>

<p>at this point, for good measure you might want to reboot your server</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># reboot</span></pre></div></div>

<p>once your server reboots you should now be able to browse to your public IP address and get the default CentOS page.</p>
<p>you can learn more about iptables here: <a href="http://wiki.centos.org/HowTos/Network/IPTables">http://wiki.centos.org/HowTos/Network/IPTables</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lejnieks.com/2008/11/17/setting-up-a-centos-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
