<?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>Server &#8211; SophieDogg</title>
	<atom:link href="https://sophiedogg.com/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>https://sophiedogg.com</link>
	<description>Dogg of all trades, Master of no one.</description>
	<lastBuildDate>Sat, 09 Oct 2021 12:02:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6</generator>
	<item>
		<title>Blocking Services with Fail2Ban</title>
		<link>https://sophiedogg.com/blocking-services-with-fail2ban/</link>
					<comments>https://sophiedogg.com/blocking-services-with-fail2ban/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Tue, 17 Apr 2012 17:19:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[IPTables]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=695</guid>

					<description><![CDATA[There are many different methods of securing a publicly accessible server, and one of the best things a system administrator can do is use fail2ban to dynamically block potential attackers before they can do any damage. First, you will want to install Fail2ban, so head over to Fail2Ban.org and follow their instructions for installing on [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>There are many different methods of securing a publicly accessible server, and one of the best things a system administrator can do is use fail2ban to dynamically block potential attackers before they can do any damage. <span id="more-695"></span></p>
<p>First, you will want to install Fail2ban, so head over to <a href="http://www.fail2ban.org">Fail2Ban.org</a> and follow their instructions for installing on your distribution.  On CentOS or RedHat, you will need to first install the <a href="http://fedoraproject.org/wiki/EPEL">EPEL</a> repository.  After doing so, fail2ban can be installed with the yum command <tt>yum install fail2ban</tt>.  That takes care of the installation! </p>
<p>Once you have Fail2Ban installed, you can start configuring it!  One of the problems that I run into with Fail2Ban is that it will try to load all the firewall rules too fast, resulting in errors like this:<br />
<tt>iptables -I INPUT -p all -j fail2ban-w00tw00t returned 400</tt><br />
You may also get some 100 or 200 errors as well.  Well, the fix for this is easy enough (and hopefully it will be incorporated into upcoming versions; as of version 0.8.4 is is not).  Simply edit the file <tt>/usr/bin/fail2ban-client</tt> and add the line <tt>time.sleep(0.1)</tt> into the <tt>__processCmd</tt> function.  This is added around line #145.  The first few lines of the function should look like this:</p>
<pre>def __processCmd(self, cmd, showRet = True):
    beautifier = Beautifier()
    for c in cmd:
        time.sleep(0.1)
        beautifier.setInputCmd(c)
        try:</pre>
<p>So, now that we have a working Fail2Ban setup, we can start configuring some rules!</p>
<p>First, take a look at <tt>/etc/fail2ban/fail2ban.conf</tt>.  This lets us specify some log options.  The only one that I am really concerned about is the logtarget, which I like to set to <tt>/var/log/fail2ban.log</tt>.</p>
<p>Next, let us look at the <tt>/etc/fail2ban/jail.conf</tt> file. Here you will want to configure your list of ignore IP&#8217;s, which should include localhost, and your trusted machine(s) or subnet (ex: <tt>ignoreip = 127.0.0.1 192.168.0.0/24 8.8.8.8</tt>).  You can also adjust the bantime, findtime, and maxretry options, all of which are explained within the file.</p>
<p>Next you can pick what jails to run, and override any global settings with specific settings set here.  Spend some time reading through the different jail configurations to get an idea for how to set yours up.  I&#8217;m always a little more paranoid about security; I don&#8217;t want any cats in my dogghouse, so I will usually completely ban any user that fits one of my rules.  You could optionally just ban them from using the service they are attempting to exploit, if you wish.</p>
<p>Lets take a look at a jail configuration that I wrote myself.</p>
<pre>[dns-root]
enabled  = true
filter   = dns-root
action   = iptables-allports[name=DNS-ROOT]
           sendmail-whois[name=dns-root, dest=jerp@herpandderp.com, sender=fail2ban@myserver.com]
logpath  = /var/named/chroot/var/log/bind.log
maxretry = 2
bantime  = 86400</pre>
<p>One of my nameservers was getting a large number of NS lookup requests for the root domains.  Well, our server isn&#8217;t authoritative for the root zone, so we respond with a REFUSED notice, however this didn&#8217;t keep the requests from coming.  At first I thought that it was some sort of lame DOS attack against one of my nameservers, but after investigation I found that this was likely a <a href="http://securityaffairs.co/wordpress/3184/cyber-crime/anonymous-dns-amplification-attacks-for-operation-global-blackout.html"> Root DNS Amplification Attack</a> against Facebook!  I would get approximately one request per minute for the root NS records, sending out one REFUSED response per minute to an IP address owned by Facebook.  In order to combat these annoyances, I created the <tt>[dns-root]</tt> jail for Fail2Ban.</p>
<p>Lets take a look at what each setting in this jail does.  First, the enabled line dictates whether or not the jail is active.  Next, the filter line specifies the name of the filter that will be used to match undesired behavior.  The action line in this case says to run the <tt>iptables-allports</tt> action, inserting an iptables rule into the chain named <tt>DNS-ROOT</tt>, which will drop traffic from the banned host on all ports.  Optionally, you can select to only have specific ports dropped, instead of banning the host from your entire server.  The <tt>sendmail-whois</tt> line lets us send an email, with whois inforation about the banned host, to whoever you like.  Finally the logpath specifies the actual log to be checked against, and the maxretry along with the bantime values will override the global variables you specified earlier in that file.</p>
<p>Next, take a look at the matching filter.  After removing some extra comments, we are left with this:</p>
<pre># Fail2Ban DNS-ROOT configuration file

[Definition]
failregex = ^.* security: info: client <HOST>#.*: query \(cache\) './(NS|A|AAAA|MX|CNAME)/IN' denied

ignoreregex =</pre>
<p>What we have are two variables.  The first is failregex, which is a regex formatted statement to match denied root zone lookup lines in our log files.  The next variable, ignoreregex, lets us specify something to search for, which will cause a matched line to be ignored.  Basically, if the failregex line is matched, the host is banned.  If both lines are matched, the host is not banned.</p>
<p>Now, once you have everything configured, you should be able to set the service to start at boot with the <tt>chkconfig fail2ban on</tt> command, and immediately make the service start with the <tt>service fail2ban start</tt> command.</p>
<p>Now you can finally have some piece of mind, knowing that those pesky internet cats wont be able to get into your dogghouse and steal your bone!</p>
<p>If you are interested in creating your own rules, check out <a href="http://regexpal.com/">Regexpal.com</a> for help in writing and debugging regex.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/blocking-services-with-fail2ban/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Installing PS3 Media Server on CentOS 6</title>
		<link>https://sophiedogg.com/installing-ps3-media-server-on-centos-6/</link>
					<comments>https://sophiedogg.com/installing-ps3-media-server-on-centos-6/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Fri, 27 Jan 2012 20:46:02 +0000</pubDate>
				<category><![CDATA[Info]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[upnp]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=289</guid>

					<description><![CDATA[So after recently rebuilding one of the servers in my dogghouse, I realized that I hadn&#8217;t installed a uPNP/DLNA AV media server. Previously I had been using Fuppes, but the lack of active development and some other quirks made me re-think what I wanted to use. So, after comparing available packages, I decided to give [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>So after recently rebuilding one of the servers in my dogghouse, I realized that I hadn&#8217;t installed a uPNP/DLNA AV media server.  Previously I had been using Fuppes, but the lack of active development and some other quirks made me re-think what I wanted to use.  So, after comparing available packages, I decided to give the PS3 media server a try.  I specifically wanted something that could run without a GUI on a headless machine as a service/daemon if necessary, that would support an XBox 360 and various Android devices.  <span id="more-289"></span></p>
<p>Installation was fairly easy, however the documentation to make it work how I wanted on an RPM based distro was conflicting, spread across multiple sites, and somewhat lacking&#8230;</p>
<p>First, we need to add the rpmforge repo, in order to install the prerequesites with yum.  Instructions for installing RPMForge can be found at the <a href="http://wiki.centos.org/AdditionalResources/Repositories/RPMForge" title="CentOS RPMForge Howto" target="_blank" rel="noopener">CentOS RPMForge Howto</a>, but it basically consists of the following:</p>
<pre>rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -i http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm</pre>
<p>Next, we need to install some prerequisite packages:</p>
<pre>yum install gcc mplayer ffmpeg mencoder java-1.7.0-openjdk ImageMagick</pre>
<p>If you wish to stream web content, you will also want to install vlc:</p>
<pre>yum install vlc</pre>
<p>If you are having problems installing vlc, because of version conflicts with libupnp, add the line <tt>exclude=libupnp</tt> to your <tt>/etc/yum.repos.d/epel.repo</tt>, in the main <tt>[epel]</tt> section</p>
<p>We will also want to install libzen and libmediainfo for some additional features.  You can skip this step if you like, but not all the features will work!</p>
<p>You can get RPM packages for libzen and libmediainfo from the <a href="http://mediainfo.sourceforge.net/en/Download" title="MediaInfo Download" target="_blank" rel="noopener">MediaInfo Download Page</a>, just select the appropriate distro and architecture, download the package, then install like this:</p>
<pre>wget http://mediaarea.net/download/binary/libzen0/0.4.29/libzen0-0.4.29-1.x86_64.CentOS_6.rpm
rpm -Uvh libzen0-0.4.29-1.x86_64.CentOS_6.rpm
wget http://mediaarea.net/download/binary/libmediainfo0/0.7.64/libmediainfo0-0.7.64-1.x86_64.CentOS_6.rpm
rpm -Uvh libmediainfo0-0.7.64-1.x86_64.CentOS_6.rpm</pre>
<p>Finally, we are ready to install ps3mediaserver!  Go grab the latest ps3mediaserver package from the <a href="https://code.google.com/p/ps3mediaserver/wiki/Download" title="ps3mediaserver Download Page" target="_blank" rel="noopener">ps3mediaserver download page</a>, and extract it somewhere.  I like to put it in my <tt>/usr/local/share</tt> directory so that I can run it as a service in the background or as a non-privileged user.</p>
<p>Next, we will follow Geoff Hodder&#8217;s advice and create a symlink from /usr/local/share/pms to the current version of pms, which we can change in the future when upgrading, making the upgrade process easier!</p>
<pre>ln -s /usr/local/share/pms-1.90.0 /usr/local/share/pms</pre>
<p>Double check the ownership here on the pms-1.90.0 folder.  I have mine owned as root:root.  The default permissions should be correct.  Below are what my folder permissions look like.</p>
<pre>lrwxrwxrwx   1 root root   27 Nov 19 21:07 pms -> /usr/local/share/pms-1.90.0
drwx------   5 root root 4.0K Jan 29 07:48 pms-1.90.0</pre>
<p>Now go to the directory you just created with the <tt>ln</tt> command above, (<tt>/usr/local/share/pms/</tt> in my case), and edit the file PMS.conf, changing the following settings:</p>
<pre>minimized = true
network_interface = br0
folders = /data/movies,/data/music,/data/pics</pre>
<p>Optionally, edit the following settings to enable chapters on .mkv files, and disable forced subtitles:</p>
<pre>chapter_support = true
mencoder_disablesubs = true</pre>
<p>If you are upgrading from a previous version of ps3mediaserver, don&#8217;t just copy your old config file.  Variable names are often changed, new variables are added, and old ones may be removed.  Double check your settings and apply them to the new file!</p>
<p>Obviously you will want to change the folders and network_interface settings to match your setup.  The defaults for the rest of the settings should be fine, but take a look through the other settings if you wish.</p>
<p>One additional change was made to the <tt>/usr/local/share/pms/renderers/XBOX360.conf</tt> file to allow avi streaming to the XBox 360.  Find the <tt>StreamExtensions=</tt> line and avi to the end, so it will look like this:</p>
<pre>StreamExtensions=wma,asf,avi</pre>
<p>Phew&#8230;  We&#8217;re almost there!</p>
<p>One of the things I specifically wanted was to be able to run this as a service on boot.  I also wanted to specify my config file, instead of having it use one from my home folder.  In order to do this we are going to edit the <tt>/usr/local/share/pms/PMS.sh</tt> file.  Comment out the <tt>DIRNAME=`dirname $CMD`</tt> line and add a line like <tt>DIRNAME="/usr/local/share/pms/"</tt> right below it.  Here is what the first few lines of my <tt>PMS.sh</tt> file look like:</p>
<pre>#!/bin/sh

CMD=`readlink -f $0`
#DIRNAME=`dirname $CMD`
DIRNAME="/usr/local/share/pms/"</pre>
<p>One more thing that I wanted was the ability to simply run a command from anywhere, as any user, and start the service.  I just created a symbolic link in the <tt>/usr/local/bin</tt> to the PMS.sh script like so:</p>
<pre>ln -s /usr/local/share/pms/PMS.sh /usr/local/bin/pms</pre>
<p>We must now allow TCP traffic on port 5001 and UDP traffic on port 1900 through our firewall, along with multicast IGMP traffic, to actually let this thing work!  Open the appropriate ports with some lines like this in your <tt>/etc/sysconfig/iptables</tt> file:</p>
<pre>-A INPUT -s 10.0.0.0/24 -i br0 -p tcp -m tcp --dport 5001 -j ACCEPT
-A INPUT -s 10.0.0.0/24 -i br0 -p udp -m udp --dport 1900 -j ACCEPT
-A INPUT -d 224.0.0.0/4 -i br0 -p igmp -j ACCEPT</pre>
<p>You will also need to set the default multicast address route.  This can be set in the <tt>/etc/sysconfig/network-scripts/route-br0</tt> file, looking like this:</p>
<pre># /etc/sysconfig/network-scripts/route-br0
224.0.0.0/4 dev br0</pre>
<p>Make sure to change the source address mask to match your local network addresses, and the interface to match your local network interface.  <del datetime="2012-12-26T16:37:56+00:00">If you have IPv6 running, you should also open those same ports in your <tt>/etc/sysconfig/ip6tables</tt> firewall:</p>
<pre>-A INPUT -p tcp -m tcp -s 2001:1234:5678:abcd::/64 -i br0 -j ACCEPT --dport 5001
-A INPUT -p udp -m udp -s 2001:1234:5678:abcd::/64 -i br0 -j ACCEPT --dport 1900</pre>
<p></del></p>
<p><del datetime="2012-12-26T16:37:56+00:00">PLEASE NOTE!!!  If you have IPv6 running, you will want to remove the <tt>-Djava.net.preferIPv4Stack=true</tt> parameter from the last line of the <TT>PMS.sh</tt> file.</del>  More details below&#8230;</p>
<p>Again, make sure that your source address mask and interface match your network configuration, and don&#8217;t forget to restart your firewalls to apply the new rules!</p>
<p>Now, before we go any further, we can attempt to run the server and make sure that everything is actually working correctly.  Just type <tt>pms</tt> from a command prompt and watch it go!</p>
<p>If everything is working correctly, you will either have the GUI window pop up, or get a message like this:</p>
<pre>GUI environment not available
Switching to console mode</pre>
<p>or you may get a bunch of debug messages fly by.  If there are any errors, double check everything before moving on.</p>
<p>If you are in the console mode, press crtl-c to stop the ps3mediaserver.</p>
<p>Finally, the last thing I want to do is set this thing to run as a service/daemon in the background and start on boot.  In order to do this we need a startup script!</p>
<p>Create the <tt>/etc/init.d/ps3mediaserver</tt> file and put the following in it:</p>
<pre>#!/bin/sh
#
# chkconfig: - 91 50
# description: Starts and stops the ps3mediaserver
# version: 0.8
# pidfile: /usr/local/share/pms/ps3mediaserver.pid
# config:  /usr/local/share/pms/PMS.conf

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 1
fi

# Avoid using root's TMPDIR
unset TMPDIR

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1

PROG_NAME='ps3mediaserver'
PROG_ROOT='/usr/local/share/pms'
PROG_JAR='pms.jar'
PROG_EXEC='PMS.sh'

RETVAL=0

start() {
        KIND="$PROG_NAME"
        echo -n $"Starting $KIND services: "
        cd $PROG_ROOT
        daemon $PROG_ROOT/$PROG_EXEC
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && echo `ps axo pid,args | grep $PROG_JAR | grep -v grep | awk {'print $1'}` > $PROG_ROOT/$PROG_NAME.pid || \
           RETVAL=1
           ps axo pid,args | grep $PROG_JAR | grep -v grep | awk {'print $1'} > $PROG_ROOT/$PROG_NAME.pid
        return $RETVAL
}

stop() {
        KIND="$PROG_NAME"
        echo -n $"Shutting down $KIND services: "
        killproc -p $PROG_ROOT/$PROG_NAME.pid
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f $PROG_ROOT/$PROG_NAME.pid
        return $RETVAL
}

restart() {
        stop
        start
}

rhstatus() {
        status -p $PROG_ROOT/$PROG_NAME.pid $PROG_NAME
        return $?
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        rhstatus
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 2
esac
exit $?</pre>
<p>One of the last things we need to do is make a small change to the last line of our PMS.sh script, to allow it to run in the background, and log to a file.  The last line should look like this <del datetime="2012-12-26T16:37:56+00:00">(note the difference between IPv4 and IPv6 networks!)</del>:<br />
IPv4:</p>
<pre>exec "$JAVA" $JAVA_OPTS -Xmx768M -Xss1024k -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djna.nosys=true -classpath "$PMS_JARS" net.pms.PMS "$@" >> /var/log/ps3mediaserver.log 2>> /var/log/ps3mediaserver.log &</pre>
<p><del datetime="2012-12-26T16:37:56+00:00">IPv6:</p>
<pre>exec "$JAVA" $JAVA_OPTS -Xmx768M -Xss1024k -Dfile.encoding=UTF-8 -Djna.nosys=true -classpath "$PMS_JARS" net.pms.PMS "$@" >> /var/log/ps3mediaserver.log 2>> /var/log/ps3mediaserver.log &</pre>
<p></del><br />
I have not been able to get the IPv6 configuration for PS3 Media Server to work reliably on all my devices&#8230;  If you have any suggestions please let me know!</p>
<p>Finally, install the startup script and set it to run on boot!</p>
<pre>cd /etc/init.d
chmod +x ps3mediaserver
chkconfig --add ps3mediaserver
chkconfig --level 345 ps3mediaserver on</pre>
<p>Now, we can start the ps3mediaserver and be done!</p>
<pre>service ps3mediaserver start
Starting ps3mediaserver services:                          [  OK  ]</pre>
<p>Now that we are done, go ahead and get yourself a dogg treat!</p>
<p>Thanks to Geoff Hodder for some good tips left in the comments below.  Go check out his page at <a href="http://phreek.org/" title="http://phreek.org/">PHReeK.oRG</a></p>
<p>Also, thanks to the following webpages for giving me some of the information necessary to get this thing working:<br />
<a href="http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&#038;t=4374" title="http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&#038;t=4374" target="_blank" rel="noopener">http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&#038;t=4374</a><br />
<a href="https://help.ubuntu.com/community/Ps3MediaServer" title="https://help.ubuntu.com/community/Ps3MediaServer" target="_blank" rel="noopener">https://help.ubuntu.com/community/Ps3MediaServer</a><br />
<a href="http://otmanix.de/english/2009/05/17/java-ps3-media-server-for-dummies-chapter-3-installation-and-basic-configuration/" title="http://otmanix.de/english/2009/05/17/java-ps3-media-server-for-dummies-chapter-3-installation-and-basic-configuration/" target="_blank" rel="noopener">http://otmanix.de/english/2009/05/17/java-ps3-media-server-for-dummies-chapter-3-installation-and-basic-configuration/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/installing-ps3-media-server-on-centos-6/feed/</wfw:commentRss>
			<slash:comments>39</slash:comments>
		
		
			</item>
		<item>
		<title>Radvd and DHCPd6 Server Configuration for Dynamic DNS</title>
		<link>https://sophiedogg.com/radvd-and-dhcpd6-server-configuration-for-dynamic-dns/</link>
					<comments>https://sophiedogg.com/radvd-and-dhcpd6-server-configuration-for-dynamic-dns/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Sat, 14 Jan 2012 16:59:08 +0000</pubDate>
				<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=264</guid>

					<description><![CDATA[I&#8217;ve been using radvd for a while now to hand out IPv6 addresses to all the different devices in my Dogghouse, and I thought that it would be nice to have a working dynamic DNS setup for IPv6, in the same way as I have DDNS for IPv4. First, we need to configure radvd to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been using radvd for a while now to hand out IPv6 addresses to all the different devices in my Dogghouse, and I thought that it would be nice to have a working dynamic DNS setup for IPv6, in the same way as I have DDNS for IPv4.  <span id="more-264"></span></p>
<p>First, we need to configure radvd to advertise the IPv6 routing on our network, so lets take a look at our radvd configuration.</p>
<pre># RADVD with DHCPd6 configuration
# /etc/radvd.conf
interface br0 {
        AdvManagedFlag on;
        AdvSendAdvert on;
        AdvAutonomous off;
        AdvOtherConfigFlag on;
        MinRtrAdvInterval 3;
        MaxRtrAdvInterval 60;
};</pre>
<p>This is a very basic radvd setup, which will just advertise the routing gateway to the network, and nothing more.  If we are going to use DHCPd6 to hand out addresses, then this is exactly what we want for our radvd configuration.  Make sure to change the interface name in the example to the interface name you will be handing out IPv6 addresses on; I have multiple interfaces bridged for my internal network and use interface br0.</p>
<p>If you want to use radvd to hand out addresses, then just use the following example instead.</p>
<pre># RADVD with no DHCPd6 configuration
# /etc/radvd.conf
interface br0 {
        AdvManagedFlag on;
        AdvSendAdvert on;
        AdvAutonomous on;
        AdvLinkMTU 1480;
        AdvOtherConfigFlag on;
        MinRtrAdvInterval 3;
        MaxRtrAdvInterval 60;
        prefix 2001:0db8:edfa:1234::/64 {
                AdvOnLink on;
                AdvRouterAddr on;
        };
};</pre>
<p>Again, make sure to change the interface to your interface name, and change the IPv6 network prefix to your addresses.</p>
<p>Now, to use DHCPd for IPv6, we need a separate configuration and service/daemon to handle the IPv6 addresses, since DHCPd can&#8217;t give out both IPv4 and IPv6 addresses at the same time.  If you already have a working IPv4 DHCPd setup, you can use a lot of the same configuration values in your DHCPd6 setup.  Below is a basic configuration for DHCPd6.</p>
<pre># /etc/dhcp/dhcpd6.conf

ddns-update-style interim;
ddns-updates on;
ddns-domainname "your.domain.com";
ddns-rev-domainname "ip6.arpa";
allow client-updates;
update-conflict-detection false;
update-optimization false;
authoritative;
option domain-name-servers dns.your.domain.com;
default-lease-time 86400;
preferred-lifetime 80000;
allow leasequery;
option dhcp6.name-servers 2001:0db8:edfa:1234::1;
option dhcp6.domain-search "your.domain.com","domain.com";
include "/etc/rndc.key";
option dhcp6.preference 255;

zone a.f.d.e.8.b.d.0.1.0.0.2.ip6.arpa. {
        primary 10.0.0.1;
        key rndckey;
}
zone your.domain.com {
        primary 10.0.0.1;
        key rndckey;
}

subnet6 2001:0db8:edfa:1234::/64 {
        # Range for clients
        range6 2001:0db8:edfa:1234:5678::aaaa 2001:0db8:edfa:1234:5678::ffff;
        # Example of a fixed host address
        host client.your.domain.com {
               host-identifier option dhcp6.client-id 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd;
               fixed-address6 2001:0db8:edfa:1234:5678::1;
        }
}</pre>
<p>This configuration will get also give out a fixed address to one of our clients, to ensure that it always gets the same IPv6 addresses from our server.  Make sure that you replace the IPv6 addresses, domain names, zone, host, and subnet settings with the correct info for your network.</p>
<p>Notice the line <tt>include "/etc/rndc.key";</tt>.  This is where I keep the key that the DHCP and DNS servers use to allow updates, so we don&#8217;t have unknown unauthorized outside sources modifying our DNS records!  Below is what my rndc.key file looks like.</p>
<pre># /etc/rndc.key

key "rndckey" {
        algorithm hmac-md5;
        secret "super-secret-key 31337";
};</pre>
<p>Finally, we need to make sure that our DNS server is configured to accept updates for our zones.</p>
<p>In our <tt>named.conf</tt> file, we need our rndc key, controls, and zone info.</p>
<pre>key rndckey {
        algorithm hmac-md5;
        secret "super-secret-key 31337";
        };
controls {
        inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { rndckey; };
        inet ::1 port 953 allow { ::1; } keys { rndckey; };
        };


zone "your.domain.com" {
	type master;
	file "/var/named/your.domain.com.hosts";
        notify yes;
        allow-update {
                key rndckey;
        };
};
zone "a.f.d.e.8.b.d.0.1.0.0.2.ip6.arpa" {
	type master;
	file "/var/named/2001:0db8:edfa::_48.rev";
	allow-update {
		key rndckey;
		};
	};</pre>
<p>Finally, make sure that you have the correct firewall rules in place to accept DHCPd6 requests!  You&#8217;re going to need to accept ipv6-icmp traffic, and both TCP and UDP traffic on ports 546 and 547 from the link-local address range fe80::/16 to the all-dhcp-agents link-local multicast group ff02::1:2.  Here are some basic ip6tables rule examples for DNS and DHCP via IPv6:</p>
<pre>-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p tcp -m tcp -m multiport -s fe80::/16 -d ff02::1:2 -i br0 -j ACCEPT --dports 546,547
-A INPUT -p udp -m udp -m multiport -s fe80::/16 -d ff02::1:2 -i br0 -j ACCEPT --dports 546,547</pre>
<p>Now, this is a pretty basic setup, but should get you rolling with a working DHCPd6 DDNS setup!</p>
<p>One thing to note, I have found that Android devices (a 2.3 phone and a 3.2 tablet) don&#8217;t like to get IPv6 addresses from our DHCPd6 server; however everything else on the network (including other wifi devices) will correctly get addresses from the DHCPd6 server.  Android devices will however get stateless autoconfiguration addresses from a radvd standalone setup.  Perhaps this is a misconfiguration on my part, or an incompatibility in the Android OS; if you have any idea please let me know!  Arf!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/radvd-and-dhcpd6-server-configuration-for-dynamic-dns/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>KVM Clocks and Time Zone Settings</title>
		<link>https://sophiedogg.com/kvm-clocks-and-time-zone-settings/</link>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Wed, 21 Dec 2011 17:13:36 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[KVM]]></category>
		<category><![CDATA[QEMU]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Virtualization]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=221</guid>

					<description><![CDATA[So the other day there was an extended power outage down at the dogg pound, and one of my non-essential server racks had to be taken off-line. This particular server rack only has UPS battery backup, but no generator power (like the others), and upon reboot, the clocks in all my QEMU Linux VM&#8217;s were [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>So the other day there was an extended power outage down at the dogg pound, and one of my non-essential server racks had to be taken off-line.  This particular server rack only has UPS battery backup, but no generator power (like the others), and upon reboot, the clocks in all my QEMU Linux VM&#8217;s were wrong!  They kept getting set to UTC time instead of local time&#8230;  After much searching and testing, I finally found out what was necessary to fix this issue.  <span id="more-221"></span></p>
<p>First, we need to make sure that all of our time settings are correct.  Let&#8217;s compare the hardware clock settings to the current real time, which is <b>11:13AM EST</b>:</p>
<pre>[16:13] root@ns3:~ # hwclock
Wed 21 Dec 2011 04:13:49 PM EST  -0.297984 seconds
[16:13] root@ns3:~ # date
Wed Dec 21 16:13:07 EST 2011
[16:13] root@ns3:~ #</pre>
<p>Well, here we can see that the hardware and system clocks are wrong!  KVM/QEMU likes to keep its &#8220;hardware time&#8221; as UTC, so it takes the time from the host system and adjusts it to UTC, based off of the host system&#8217;s timezone setting.  The host system shows the correct time (and actually this physical host machine&#8217;s hardware time is set to local, not UTC).</p>
<p>Ok, well lets make sure our timezone is set correct.  The /etc/localtime file represents the timezone info for your particular time zone.  This can either be a symbolic link to the correct file, or a copy of the correct file.  On my system, it looks like this:</p>
<pre>[16:20] root@ns3:~ # ls -alh /etc/localtime
lrwxrwxrwx 1 root root 36 Dec 21 15:14 /etc/localtime -> /usr/share/zoneinfo/America/New_York
[16:21] root@ns3:~ #</pre>
<p>Now, you can either make a symbolic link using the command</p>
<pre>ln -s /usr/share/zoneinfo/America/New_York /etc/localtime</pre>
<p>or you can copy the zone file with the command</p>
<pre>cp /usr/share/zoneinfo/America/New_York /etc/localtime</pre>
<p>There are arguments for and against each method, use whichever method you prefer.</p>
<p>Next, we need to check our <tt>/etc/sysconfig/clock</tt> file to make sure it is correct.  My file looks like this:</p>
<pre>ZONE="America/New_York"</pre>
<p>Some users will add a line that says <tt>UTC="true"</tt> (or false), but it isn&#8217;t needed and can just add confusion.</p>
<p>Finally, we need to check the <tt>/etc/adjtime</tt> file; this file was the key!  The 3rd line in the file will say either UTC or LOCAL.  Since our hardware clock was set to UTC time (as shown above), we need to change our adjtime file to say UTC instead of LOCAL.  Here is what mine looks like:</p>
<pre>-15185.281863 1324482636 0.000000
1324482636
UTC</pre>
<p>So now everything should be set to keep the system time correct after a hard reboot (power off &#038; on), but our current clock is still wrong!  Well, we can fix the current time with the following command:</p>
<pre>[16:24] root@ns3:~ # hwclock --utc -s
[11:24] root@ns3:~ #</pre>
<p>This will set our system time from the hardware clock, stating that the hardware clock is kept in UTC time.</p>
<p>Now, in order to test everything, we need to completely power down the virtual machine and restart it.  Simply issuing a <tt>reboot</tt> won&#8217;t force our host machine to apply it&#8217;s time settings to the VM.  Previously, after every hard boot the time would be wrong, but now it&#8217;s correct!</p>
<p>You should also set up some NTP time synchronization to keep your time accurate; but this will at least keep the zone correct between power cycles.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Linux Server Send Email on Boot</title>
		<link>https://sophiedogg.com/linux-server-send-email-on-boot/</link>
					<comments>https://sophiedogg.com/linux-server-send-email-on-boot/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 16:42:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=245</guid>

					<description><![CDATA[It is always nice to have notification of when a server reboots, especially when you are on vacation, away from the office, or just lounging around! In order to send an email on reboot, we can easily create a cron job to run on reboot. Depending on your specific Linux distro, you may encounter some [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>It is always nice to have notification of when a server reboots, especially when you are on vacation, away from the office, or just lounging around!  In order to send an email on reboot, we can easily create a cron job to run on reboot.  Depending on your specific Linux distro, you may encounter some problems with this email going out in a timely manner! <span id="more-245"></span></p>
<p>First, in order to have a command run on boot we can either create a reboot cron job, or add a line to the <tt>/etc/rc.d/rc.local</tt> file.  Note that the crontab @reboot job may only run when the machine is rebooted, not from a cold-boot (like after the power goes out).</p>
<p>To use the crontab @reboot option, start by editing your crontab file and adding a line like the following (edit your crontab file with the <tt>crontab -e</tt> command):</p>
<pre>@reboot /root/emailnotify.sh</pre>
<p>If you instead want a script that will run every time a server is booted, add the link to your script in the <tt>/etc/rc.d/rc.local</tt> file:</p>
<pre>#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/root/emailnotify.sh</pre>
<p>Now, on reboot our server will run the /root/emailnotify.sh script!</p>
<p>Next, we actually need to write the emailnotify script.  This script will send us an email with some basic info when the server is started.  The contents of my script are below:</p>
<pre>
#!/bin/bash

sleep 60

#/bin/systemctl restart sendmail.service
/sbin/service sendmail restart

IP=`hostname -i`
HOSTNAME=`hostname -f`
echo "$HOSTNAME online.  IP address: $IP" > /root/email.txt
echo >> /root/email.txt
date >> /root/email.txt

mail -s "$HOSTNAME online" -r restart@server.domain.tld myemail@mydomain.tld < /root/email.txt
mail -s "$HOSTNAME online" -r restart@server.domain.tld myotheremail@myotherdomain.tld < /root/email.txt
mail -s "$HOSTNAME online" -r restart@server.domain.tld mycellphone@txt.carrier.tld < /root/email.txt

#cat /root/email.txt
rm -rf /root/email.txt

#/bin/systemctl restart sendmail.service
/sbin/service sendmail restart</pre>
<p>Ok, so let's take a look at what this script is doing.<br />
First, the bash script waits for 60 seconds, to give everything on the system ample time to startup.  This isn't really necessary, but if the power goes back off within that 60 seconds, you won't get hit with multiple emails.  This will also help keep our server from trying to send an email when the network equipment (switches/routers) hasn't fully recovered yet.</p>
<p>Next, we want to restart the sendmail service.  This was very important on my Fedora 16 test machine.  Without restarting sendmail, the email would get deferred and placed in a queue, and not actually be sent for a while.  The actual error was in the <tt>/var/log/maillog</tt> file, and looked like this:</p>
<pre>sendmail[1076]: pBMFxVSH001076: from=<restart@server.domain.tld>, size=607, class=0, nrcpts=1, msgid=<4ef353e3.ZS93/Yzasdfp1B4q%restart@server.domain.tld>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]</pre>
<p>Also notice that there are two different lines in the script to restart the sendmail service.  The top line will work on newer Fedora systems, while the bottom line should work on any RPM based system, at least for the foreseeable future.</p>
<p>Now we will find the IP address and hostname of our server, and create our email message.<br />
Finally we are going to send our email to three email addresses.  I like to have one sent to my corporate email, one sent to my personal email, and another sent to my phone as a text message.  This ensures that I get the message in a timely manner.</p>
<p>Finally we will delete our text file now that the email has been sent, and restart the sendmail service again just for good measure!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/linux-server-send-email-on-boot/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Disabling SELinux</title>
		<link>https://sophiedogg.com/disabling-selinux/</link>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Fri, 09 Sep 2011 17:20:38 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=210</guid>

					<description><![CDATA[One of the first things I usually do with most of my servers is disable SELinux. Optimally, you should configure SELinux to allow the services you need, but instead you can just disable the whole darn thing! SELinux has 3 basic operating modes: Enforcing &#8211; SELinux security policy is fully enforced. Permissive &#8211; SELinux prints [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One of the first things I usually do with most of my servers is disable SELinux.  Optimally, you should configure SELinux to allow the services you need, but instead you can just disable the whole darn thing!<span id="more-210"></span></p>
<p>SELinux has 3 basic operating modes:<br />
Enforcing &#8211; SELinux security policy is fully enforced.<br />
Permissive &#8211; SELinux prints warnings instead of denying actions.<br />
Disabled &#8211; SELinux is completely disabled.</p>
<p>If you plan on ever utilizing the extra security available with SELinux, you should choose the Permissive mode, so you can log any potential problems and create policies within SELinux to allow those actions.</p>
<p>We can check what mode SELinux is currently running in with the following command:</p>
<pre>bash# cat /selinux/enforce
0bash#</pre>
<p>Notice the 0 at the beginning of the second line; that is our current SELinux mode.</p>
<p>To temporarily put SELinux into disabled mode (until the next reboot) use the following command:</p>
<pre>bash# echo 0 > /selinux/enforce</pre>
<p>Conversely, to switch back to enforcing mode:</p>
<pre>bash# echo 1 > /selinux/enforce</pre>
<p>Nest, to permanently change the SELinux mode, edit <tt>/etc/selinux/config</tt></p>
<pre># This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted</pre>
<p>Change the <tt>SELINUX=</tt> line to match your desired level.</p>
<p>Also, some Linux distributions use kernel flags at boot time to enable or disable SELinux.  If you don&#8217;t have a <tt>/etc/selinux/config</tt> file, then look in your <tt>/boot/grub/grub.conf</tt> file, and add <tt>enforcing=0</tt> to the end of your kernel boot line, like this:</p>
<pre># grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_kickstart-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/vda
default=0
timeout=0
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.40.4-5.fc15.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.40.4-5.fc15.x86_64 ro root=/dev/mapper/vg_kickstart-lv_root rd_LVM_LV=vg_kickstart/lv_root rd_LVM_LV=vg_kickstart/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet enforcing=0
        initrd /initramfs-2.6.40.4-5.fc15.x86_64.img</pre>
<p>To re-enable SELinux you must complete some additional steps.</p>
<p>First change the SELinux type to permissive and reboot.  Next run the <tt>touch /.autorelabel</tt> command, reboot again to relabel all the files.  Finally change the SELinux type to enabled and reboot again!  Please note that all the files will be relabeled for SELinux, which can take some time if there are a lot of files.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Creating a new KVM server on a headless machine</title>
		<link>https://sophiedogg.com/creating-a-new-kvm-server-on-a-headless-machine/</link>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 16:40:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Virtualization]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=166</guid>

					<description><![CDATA[One of the things any good sysadmin dogg wants to do is setup some virtual servers. Who wants to actually stand in front of a server to do that?! What if the machine is headless (no monitor attached)? Well, as long as we have SSH access to the machine, we can do everything from the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One of the things any good sysadmin dogg wants to do is setup some virtual servers. Who wants to actually stand in front of a server to do that?! What if the machine is headless (no monitor attached)? Well, as long as we have SSH access to the machine, we can do everything from the dogghouse!<span id="more-166"></span></p>
<p>The first thing you want is to start with a nice server with a good OS installed. I&#8217;m starting with the CentOS 6 operating system, and a newer Dell Poweredge server. Obviously the more powerful the hardware, the better, but you will want something that supports full hardware virtualization, which is important for security, stability, and speed, among other things.  Check in your BIOS for something like &#8220;Enable Virtualization.&#8221;  Check with your hardware manufacturer for details.</p>
<p>After you have your initial server set up, you&#8217;ll need to add some packages for virtualization support. We&#8217;ll use the yum groupinstall command to get our necessary package groups, then install the bridge software separately, make sure everything is up to date, and finally restart the server so that we have the latest kernel running.</p>
<pre>bash# yum groupinstall "Virtualization" "Virtualization Client"
bash# yum groupinstall "Virtualization Platform" "Virtualization Tools"
bash# yum install bridge-utils
bash# yum update
bash# reboot</pre>
<p>When you reconnect to your host machine, make sure to forward some ports so you can tunnel to the VM&#8217;s console display! With putty, you can use a command like this:</p>
<pre>putty.exe -L 5900:127.0.0.1:5900 -L 5901:127.0.0.1:5901 user@server</pre>
<p>This will forward two ports for us, 5900 and 5901 to the localhost (the machine we&#8217;re connecting to) that we will use for VNC connections.  Our first VM will use port 5900, our second VM will use port 5901, and so on.  You can easily add more port forwards to your SSH connection to enable connecting to additional VM&#8217;s.</p>
<p>The first thing we need to do are set up some network bridges. There are a lot of different ways to configure network bridges, but we&#8217;re going to keep this one simple. Let&#8217;s say our machine has two physical network interfaces, eth0 and eth1. We&#8217;re going to assume that both interfaces are connected to the same network (so we can&#8217;t bridge them together), that we will use eth0 to connect to our physical machine (aka hypervisor, dom0, host, or manager), and that eth1 has no IP address. So, just create a separate bridge for each physical interface, br0 and br1.</p>
<p>Start by configuring eth0 (/etc/sysconfig/network-scripts/ifcfg-eth0):</p>
<pre>DEVICE="eth0"
HWADDR="12:34:56:78:90:ab"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR=10.0.0.100
GATEWAY=10.0.0.1
TYPE=Ethernet
BOOTPROTO=none
NETMASK=255.255.255.0
USERCTL=no
PEERDNS=yes
IPV6INIT=no
SEARCH=mydomain.com
DNS1=10.0.0.1
DNS2=10.0.0.2
DNS2=8.8.8.8
BRIDGE=br0</pre>
<p>You could optionally configure eth0 to use DHCP, if desired. Be careful when remotely making changes to your active network connection; a misconfiguration could make you unable to connect!</p>
<p>Next, lets configure eth1 (/etc/sysconfig/network-scripts/ifcfg-eth1):</p>
<pre>DEVICE="eth1"
HWADDR="12:34:56:78:90:cd"
NM_CONTROLLED="no"
ONBOOT="yes"
BRIDGE=br1</pre>
<p>Restart the network connections to make sure everything is working so far:</p>
<pre>bash# service network restart</pre>
<p>Now that our physical interfaces are configured, lets configure some bridges! We can just edit the bridge scripts, so open the files and configure them already!</p>
<p>Bridge device br0 (/etc/sysconfig/network-scripts/ifcfg-br0):</p>
<pre>DEVICE=br0
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge</pre>
<p>Bridge device br1 (/etc/sysconfig/network-scripts/ifcfg-br1):</p>
<pre>DEVICE=br1
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge</pre>
<p>Restart the network services again, and we&#8217;re ready to go!</p>
<pre>bash# service network restart</pre>
<p>Check that our bridge devices exist with the following command:</p>
<pre>bash# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.842b2b03fa01       no              eth0
br2             8000.0010186e94e8       no              eth2</pre>
<p>This shows us that br0 has interface eth0, and br1 has interface eth1.</p>
<p>Ok, so now that we have our host correctly configured, we need an OS to install! You can use a disk drive with the OS installation, install from something provided on the network, or go get a .iso of your favorite OS, and install from there. We&#8217;ll just use an .iso. Take a look at the following command:</p>
<pre>bash# virt-install -n newbawx --vcpus=1 -f /home/vm/newbawx -s 60 -r 2048 --nonsparse -w bridge:br1 --vnc --accelerate -c /tmp/Fedora-15-x86_64-DVD.iso --os-type=linux --os-variant=fedora13 --noautoconsole
Starting install...
Creating storage file newbawx                            |  60 GB     04:43
Creating domain...                                       |    0 B     00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.</pre>
<p>First we use the <tt>virt-install</tt> command to create a new virutal machine named newbawx. We give it a hard drive size of 60GB (-s 60), 2GB of RAM (-r 2048), tell it to use bridge 1 (-w bridge:br1), and have it use a Fedora 15 .iso as a virtual CD drive to install from (-c /tmp/Fedora-15-x86_64-DVD.iso). Don&#8217;t forget the <tt>--vnc</tt> option to enable VNC access to the guest console. Notice that the os-variant is fedora13; that is because it is the highest os-variant parameter currently supported for Fedora!</p>
<p>After the <tt>virt-install</tt> command is run, we can optionally set the VM to automatically start with the host server:</p>
<pre>bash# virsh autostart newbawx
Domain newbawx marked as autostarted</pre>
<p>Next, fire up your favorite VNC client and connect to 127.0.0.1:5000. You will be greeted with the installation walkthrough for your guest OS!</p>
<p>Also, if you wanted to delete and remove a virtual machine named newbawx:</p>
<pre>bash# virsh destroy newbawx
bash# virsh undefine newbawx
bash# rm -rf /home/vm/newbawx</pre>
<p>XML files containing your virtual machine settings are located in <tt>/etc/libvirt/qemu/</tt>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Lockd and Statd NFS Errors</title>
		<link>https://sophiedogg.com/lockd-and-statd-nfs-errors/</link>
					<comments>https://sophiedogg.com/lockd-and-statd-nfs-errors/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Sat, 30 Jul 2011 15:37:24 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=141</guid>

					<description><![CDATA[The other day, the NFS clients at the pound stopped working correctly. Programs that use a NFS share for caching data or locking files (such as Firefox) stopped working without any explanation. My doggs were also unable to compile any programs, which led to a lot of barking and growling from all of them! Looking [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The other day, the NFS clients at the pound stopped working correctly.  Programs that use a NFS share for caching data or locking files (such as Firefox) stopped working without any explanation.  My doggs were also unable to compile any programs, which led to a lot of barking and growling from all of them! <span id="more-141"></span></p>
<p>Looking through the logs on the client didn&#8217;t reveal anything significant, however the logs on the NFS server were filled with these:</p>
<pre>kernel: statd: server localhost not responding, timed out
kernel: lockd: cannot monitor client</pre>
<p>At first it seemed that the statd daemon was not functioning.  After restarting lockd and statd, the problem persisted.  Even restarting the server didn&#8217;t fix the problem.  The next thought was that something was blocking the loopback interface from communicating, since the localhost server wasn&#8217;t responding.  After running some network tests, checking firewall and tcpwrapper rules, I found nothing that was keeping the server from communicating with itself.</p>
<p>After reading through the man page for statd and conversing with some of my doggs, I decided to attempt to remove the statd monitor and notify lists on the NFS server.  This was the key!  These files had somehow become locked or corrupted.  These lists are located in the directories below:</p>
<pre>/var/lib/nfs/statd/sm/ - directory containing statd monitor list
/var/lib/nfs/statd/sm.bak/ - directory containing statd notify list</pre>
<p>Before removing these files, you should stop the rpcbind, statd, and lockd services.  Below is a list of commands to run to fix this issue on a RPM based distro.</p>
<pre>service rpcbind stop
service nfslock stop
rm -rf /var/lib/nfs/statd/sm/*
rm -rf /var/lib/nfs/statd/sm.bak/*
service rpcbind start
service nfslock start</pre>
<p>After running these commands, it may be best to restart your NFS server.</p>
<p>Also check the permissions on these files and folders, to make sure that the NFS service can access them.  Here are the permissions from my NFS server:</p>
<pre>drwx------ 4 rpcuser rpcuser 4.0K Aug  1 15:00 .
drwxr-xr-x 5 root    root    4.0K Aug  1 15:00 ..
drwx------ 2 rpcuser rpcuser 4.0K Aug  1 15:00 sm
drwx------ 2 rpcuser rpcuser 4.0K Aug  1 15:00 sm.bak
-rw-r--r-- 1 root    root       4 Aug  1 15:00 state</pre>
<p>A NFS FAQ can also be found here: <a href="http://www.sunhelp.org/faq/nfs.html" title="http://www.sunhelp.org/faq/nfs.html">http://www.sunhelp.org/faq/nfs.html</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/lockd-and-statd-nfs-errors/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Configuring SSH on a New Server</title>
		<link>https://sophiedogg.com/configuring-ssh-on-a-new-server/</link>
					<comments>https://sophiedogg.com/configuring-ssh-on-a-new-server/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Tue, 12 Apr 2011 17:21:14 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=58</guid>

					<description><![CDATA[I recently showed everyone how to install a new CentOS server, and now that we have a running system, we need to do some basic configuration to SSH to make sure our server is secure. When you install your operating system, you should have created an initial root password. We will use this to log [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I recently showed everyone how to install a new CentOS server, and now that we have a running system, we need to do some basic configuration to SSH to make sure our server is secure.  When you install your operating system, you should have created an initial root password.  We will use this to log in to our system and start configuration.</p>
<p>One of the first things we need to do is <span id="more-58"></span> create a user account for our self.  Whenever we are logged in, we should be a normal user, not a super-user!  This is one of the biggest problems with Windows operating systems; normal users are given administrative privileges by default.  When you download something malicious on a Windows PC, the malicious software can easily wreak havoc on your computer, because you have the permissions necessary to do so!  Under Linux, we are just a normal user, and only request administrative (root) privileges when necessary.  This way, even if I did download a virus on my Linux machine, unless I executed the virus as root, there is very little damage that the virus can do, because my normal user only has a restricted set of privileges.</p>
<p>Create a new user using the <code>useradd</code> command.  This will allow us to add a new user, and then we can create a password for this new user using the <code>passwd</code> command.  So, go ahead and create a new account for yourself, as I am doing below.  Replace [username] with your desired username.  Remember that we have to be an administrative (root) user to run the useradd command.</p>
<pre>[root@machine ~]# useradd [username]
[root@machine ~]# passwd [username]
Changing password for user username.
New UNIX Password:
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
[root@machine ~]#</pre>
<p>Next, we will need to enable sudo access for our newly created user, so that we will still be able to run commands as root.  To do this, run the <code>visudo</code> command, and add the following line to the bottom of the file, replacing [username] with the username you created above.</p>
<pre>[username]		ALL=(ALL)	ALL</pre>
<p>The <code>visudo</code> command will have you editing the sudoers file with the vi editor.  If you&#8217;re not familiar with vi, here are some basics.  Pressing <code>i</code> will put you into insert mode, where you can make changes much like any other editor.  Pressing <code>esc</code> will take you out of the editor mode.  You can then type <code>:wq!</code> to write your changes and exit, or just <code>:q!</code> to quit without saving.</p>
<p>Now that we have our own user account set up, and our user has sudo access, we want to disable root SSH logins.  Script kiddies will often search for machines configured with weak root passwords, and gain access using a brute-force or dictionary password attack.  I&#8217;ve seen it before; <code>wallpaper</code> isn&#8217;t a very good choice for a root password&#8230;  But for some extra security, lets disable the ability of root logging on via SSH.</p>
<p>First, open <code>/etc/ssh/sshd_config</code> in your favorite text editor, and find the line containing <code>PermitRootLogin</code> and change the entire line to this:</p>
<pre>PermitRootLogin no</pre>
<p>Now, to make our changes to the sshd_config file take effect, we must restart the SSHD service.  Run a simple <code>service sshd restart</code> as root, and you should see something like this:</p>
<pre>[root@machine ~]# service sshd restart
Stopping sshd:								[  OK  ]
Starting sshd:								[  OK  ]
[root@machine ~]#</pre>
<p>Now, before going any further, test that you can log in with the account that you created earlier, and that you can use the <code>sudo -i</code> command to enter an interactive sudo session.  If everything is working, then lets keep going! BARK!</p>
<p>Next, we can optionally change the port that SSH is listening on.  There are some pro&#8217;s and con&#8217;s of changing the port.  We can hopefully avoid some of the script kiddies who are only scanning port 22.  This won&#8217;t keep any determined hacker from finding the port number with a simple <code>nmap</code> command however.  Also, if you change the port, keep the port number below 1024.  Only users in the root group can listen on ports below 1024, so a standard user can&#8217;t replace our SSH daemon with their own, listening to incoming requests, stealing passwords, etc.</p>
<p>To change the SSH listening port, open <code>/etc/ssh/sshd_config</code> in your favorite text editor, find the <code>Port 22</code> line, and change it to look like the line below:</p>
<pre>Port 1000</pre>
<p>This will have our SSHD server listening to port 1000 for SSH connections.  Note that we must again restart the sshd service for our changes to take effect.</p>
<p>That should take care of securing our SSHD configuration.  Next time we can work on configuring our firewall!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/configuring-ssh-on-a-new-server/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Deploying a New CentOS Server</title>
		<link>https://sophiedogg.com/deploying-a-new-centos-server/</link>
					<comments>https://sophiedogg.com/deploying-a-new-centos-server/#comments</comments>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Thu, 07 Apr 2011 00:36:53 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=33</guid>

					<description><![CDATA[All my doggs keep asking me how to set up a server. I ask them what kind of server, but they never really know. They want to learn Linux, and I want them to too! So I barked to myself, &#8220;Why don&#8217;t we write up a post to show them how!&#8221; Yea! So here I&#8217;ll [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>All my doggs keep asking me how to set up a server.  I ask them what kind of server, but they never really know.  They want to learn Linux, and I want them to too!  So I barked to myself, &#8220;Why don&#8217;t we write up a post to show them how!&#8221;  Yea!  So here I&#8217;ll write up how to install a nice new CentOS 5.5 Linux server.</p>
<p>First, we will need to download the necessary software and <span id="more-33"></span> burn it to a disc, so go grab yourself a copy of CentOS from one of their <a href="http://mirror.centos.org/centos/5/isos/">mirrors</a>.  There are both 32bit (i386) and 64bit (x86_64) versions.  Download the best one for your hardware.  If you aren&#8217;t sure, get the 32bit version.  There are both CD and DVD editions available; again get the version that your hardware supports.  There is no difference in the CD vs. DVD, except for the size and quantity of discs.</p>
<p>After you have downloaded the .iso image, burn it to a disc with your favorite image burning software.  <a href="http://cdburnerxp.se/en/home">CDBurnerXP</a> is a free disc burning application that works on many different Windows operating systems, and can burn many different types of discs.</p>
<p>Well, now we can actually get started with the installation!  We&#8217;re going to have to boot from the CD we just created, and your BIOS must be set to boot from CD-ROM.  Sometimes this is already configured for you, but you may have to configure it yourself.  Configuration is accomplished by entering the BIOS immediately after turning on the computer, and configuring the boot order.  To get in to the BIOS we must press the correct key, which can be different for each BIOS brand.  Sometimes there will be a message telling you what button to press, other times there isn&#8217;t.  Most common options are the F1, F10, DEL, and ESC keys.  If you aren&#8217;t sure, and you don&#8217;t see a message telling you what to press immediately after turning on your PC, head over to <a href="http://www.google.com">Google</a> and search for how to enter the BIOS on your specific PC.</p>
<p>Once we boot from the disc, we will see a message similar to what is below:</p>
<p><a href="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install1.jpg"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-37" title="centos-install1" src="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install1-300x225.jpg" alt="" width="300" height="225" srcset="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install1-300x225.jpg 300w, https://sophiedogg.com/wp-content/uploads/2011/04/centos-install1.jpg 400w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Here you can enter any special instructions to be used during boot.Â  We won&#8217;t need any here, so just hit enter and wait for the next screen:</p>
<p><a href="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install2.jpg"><img decoding="async" class="alignnone size-medium wp-image-38" title="centos-install2" src="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install2-300x168.jpg" alt="" width="300" height="168" srcset="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install2-300x168.jpg 300w, https://sophiedogg.com/wp-content/uploads/2011/04/centos-install2.jpg 400w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>You can test the media here, to ensure that the disc was burned correctly.Â  After testing we will be transported into a magical land of fire hydrants and graphical installers!Â  Ok, maybe no fire hydrants, but a dogg can dream!</p>
<p>The next few screens will ask you to select your language and keyboard layout, then move into setting up the hard disk:</p>
<p><a href="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install3.jpg"><img decoding="async" class="alignnone size-medium wp-image-39" title="centos-install3" src="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install3-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Select the option to &#8220;Remove all partitions on selected drives and create default layout&#8221; from the drop down menu.Â  Also check the box next to &#8220;Remove and modify partitioning layout.&#8221;</p>
<p>It is important to know that after this point, we will be erasing everything on the hard drive, so any data on the drive will be lost!</p>
<p>We also need to talk about the disk partitioning structure real quick.Â  We can just choose the default layout, and with larger hard disks or less used servers, that is fine.Â  But that&#8217;s not what this dogg is all about!Â  So we are going to create a better layout.</p>
<p>We don&#8217;t want a rogue user or runaway log file to take up all our disk space (which can bring our server to a halt), so we&#8217;re gonna separate the /home directory (where all users will  store their files), the /tmp directory (where temporary files are  stored), the /var directory (which contains the log files, among other things), and the / directory (the root directory), which will contain everything else.</p>
<p>Some people will separate the directories even further, creating an additional separate partition specifically for the log files (/var/log), along with some others.Â  Take a look at the image below for a basic idea.Â  If you are lost at this point, just go back to the previous screen and uncheck the box next to &#8220;Remove and modify partitioning layout.&#8221;</p>
<p><a href="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install4.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-42" title="centos-install4" src="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install4-300x225.jpg" alt="" width="300" height="225" srcset="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install4-300x225.jpg 300w, https://sophiedogg.com/wp-content/uploads/2011/04/centos-install4.jpg 628w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Next we find ourselves at the GRUB boot loader setup.Â  Keep the default options here and continue to the network setup.Â  I like to specify the fully qualified domain name here in the hostname box.Â  You can just specify the hostname, if you don&#8217;t have a domain name yet.Â  Leave everything else as default, and continue on to the time zone configuration.Â  Select your time zone, and keep going!Â  Next we will create a root password, which we are going to need later, so don&#8217;t forget it!Â  Now we are finally ready to start selecting the software to install!</p>
<p>I like to install my servers with a minimum amount of software, and add what is necessary later.Â  This helps keep disk usage low, and avoids installing unnecessary software which can use up resources down the road.Â  Select just the option for the Server configuration, and click next.Â  You can optionally select the &#8220;Customize Now&#8221; option, and add any additional software you want, along with removing anything you don&#8217;t want.</p>
<p><a href="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install5.jpg"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-44" title="centos-install5" src="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install5-300x225.jpg" alt="" width="300" height="225" srcset="https://sophiedogg.com/wp-content/uploads/2011/04/centos-install5-300x225.jpg 300w, https://sophiedogg.com/wp-content/uploads/2011/04/centos-install5.jpg 628w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Continue through the remaining menus, and you should be ready to install!Â  After installation you will be prompted to remove your installation disc and reboot.Â  After doing this, you will now have a brand new, fresh &amp; clean, CentOS Linux server!  Next time, we&#8217;ll cover some initial server security setup, and take a look at what all we can do with our server.  But for now, I&#8217;m going for a walk!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sophiedogg.com/deploying-a-new-centos-server/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
