<?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>Kijush Maharjan :: System Administrator</title>
	<atom:link href="http://kijush.com.np/feed/" rel="self" type="application/rss+xml" />
	<link>http://kijush.com.np</link>
	<description>:: Blog for system administrator::</description>
	<lastBuildDate>Fri, 04 Nov 2011 15:52:25 +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>NTH load balancing with masquerade</title>
		<link>http://kijush.com.np/2011/11/01/nth-load-balancing-with-masquerade/</link>
		<comments>http://kijush.com.np/2011/11/01/nth-load-balancing-with-masquerade/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 11:07:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mikrotik]]></category>
		<category><![CDATA[dual-link]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mikrotik]]></category>
		<category><![CDATA[nth]]></category>

		<guid isPermaLink="false">http://kijush.com.np/?p=69</guid>
		<description><![CDATA[Load balancing using Nth can be done in several different ways. This approach focuses on performance, meaning, less rules packet takes, less attributes rule have to check. At current state... <span class="meta-more"><a href="http://kijush.com.np/2011/11/01/nth-load-balancing-with-masquerade/">Read more &#187;</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://kijush.com.np/wp-content/uploads/2011/11/LoadBalancing.jpg"><img class="aligncenter size-full wp-image-70" title="LoadBalancing" src="http://kijush.com.np/wp-content/uploads/2011/11/LoadBalancing.jpg" alt="" width="668" height="800" /></a>Load balancing using Nth can be done in several different ways. This approach focuses on performance, meaning, less rules packet takes, less attributes rule have to check. At current state majority of packets will take N rules, where N is number of internet connections you try to load balance using this example. This example is easy to expand from 2 connections to any number you wish, but consequences are: more connections, more rules packets have to pass, greater load on router, bigger latency.</p>
<p>In this example N=2</p>
<p>NOTE: this example assumes you have empty mangle. after rules have been processed, packets are accepted with routing-mark rules.</p>
<ul>
<li><strong id="variableB0">Adding ip addresses to interfaces<a name="Adding ip addresses to interfaces"></a></strong></li>
</ul>
<p>I am assuming i have 2 outgoing WAN and 1 Local LAN. I assume that addresses on WAN are public.</p>
<p>/ip address add address=10.111.0.2/24 interface=first_link<br />
/ip address add address=10.112.0.2/24 interface=second_link<br />
/ip address add address=192.168.1.1/24 interface=Local</p>
<ul>
<li><strong id="variableB1">Creating address list of possible local addresses <a name="Creating address list of possible local addresses "></a></strong></li>
</ul>
<p>We will need this list in our configuration, so only traffic from local interfaces are marked with routing marks. You can also use in interface for one incoming LAN interface on the router.</p>
<p>/ip firewall address-list add address=192.168.1.0/24 list=local</p>
<ul>
<li><strong id="variableB2">Adding routes<a name="Adding routes"></a></strong></li>
</ul>
<p>We should add two types of route: Default route for unmarked traffic, and 2 routes for marked routes.</p>
<p>/ip route add gateway=10.111.0.1<br />
/ip route add gateway=10.111.0.1 routing-mark=first<br />
/ip route add gateway=10.112.0.1 routing-mark=second</p>
<ul>
<li><strong id="variableB3">Masquerade rules <a name="Masquerade rules "></a></strong></li>
</ul>
<p>So that our local addresses can access internet addresses.</p>
<p>/ip firewall nat add chain=srcnat out-interface=first_link action=masquerade<br />
/ip firewall nat add chain=srcnat out-interface=second_link action=masquerade</p>
<ul>
<li><strong id="variableB4">Mangle rules <a name="Mangle rules "></a></strong></li>
</ul>
<p>Where the whole marking is made. I am dividing mangle in 5 sections (A-E) to make it more clear.</p>
<ul>
<li>Section A</li>
</ul>
<p>These 4 rules adds address to address list, as result, we are dividing all internal addresses currently active to dynamic address lists <em>first</em> and <em>second</em> these will be correspondingly routed through corresponding gateways. When that is done, address for simplicity is added to one more address list &#8211; <em>seen</em> so we know that we have seen this address and do not have to check more than once. When everything is done we jump to mark connection and set routing-mark for packet we are working with. Here we are working just with new packets that we have not seen yet.</p>
<p>After this section finishes, these packets are not different from those that are matched in Section D, so they are passed to Section B for further processing.</p>
<p>/ip firewall mangle add action=add-src-to-address-list address-list=first address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no nth=2,1<br />
/ip firewall mangle add action=add-src-to-address-list address-list=second address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no nth=2,2<br />
/ip firewall mangle add action=add-src-to-address-list address-list=seen address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no<br />
/ip firewall mangle add action=jump chain=&#8221;mark new unseen&#8221; disabled=no jump-target=&#8221;mark connection&#8221;</p>
<ul>
<li>Section B</li>
</ul>
<p>Next 4 rules are marking connection of both, new packets from hosts we have not seen yet and with new packets from seen hosts. First, mark connection, then add routing-mark.</p>
<p>/ip firewall mangle add action=mark-connection chain=&#8221;mark connection&#8221; disabled=no new-connection-mark=first_conn passthrough=yes src-address-list=first<br />
/ip firewall mangle add action=mark-connection chain=&#8221;mark connection&#8221; disabled=no new-connection-mark=second_conn passthrough=yes src-address-list=second<br />
/ip firewall mangle add action=mark-routing chain=&#8221;mark connection&#8221; connection-mark=first_conn disabled=no new-routing-mark=first passthrough=no<br />
/ip firewall mangle add action=mark-routing chain=&#8221;mark connection&#8221; connection-mark=second_conn disabled=no new-routing-mark=second passthrough=no</p>
<ul>
<li>Section C</li>
</ul>
<p>Next 2 rules are setting up routing-mark on packets that have connection-mark set. As result majority of packets are passing though just these 2 rules.</p>
<p>/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=first_conn disabled=no new-routing-mark=first passthrough=no src-address-list=first<br />
/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=second_conn disabled=no new-routing-mark=second passthrough=no src-address-list=second</p>
<ul>
<li>Section D</li>
</ul>
<p>This rule caches new connection packets that come from our &#8220;seen&#8221; clients, eg, client initiated new http download session (opening web page). Packets are passed to Section B where they are marked.</p>
<p>/ip firewall mangle add action=jump chain=prerouting connection-state=new disabled=no jump-target=&#8221;mark connection&#8221; src-address-list=local</p>
<ul>
<li>Section E</li>
</ul>
<p>If client ip address is not in our seen list, then address is passed to Section A where it is added to address list and after that is ready to be processed.</p>
<p>/ip firewall mangle add action=jump chain=prerouting connection-state=new disabled=no jump-target=&#8221;mark new unseen&#8221; src-address-list=local</p>
<h2>Packet route logic</h2>
<ul>
<li><strong id="variableB5">New packet from unseen addressee <a name="New packet from unseen addressee "></a></strong></li>
</ul>
<p>When router is booting up it have no seen list, and no clients are assigned to gateways. Or packet is received from previously unseen client. When first packet arrives it is checked in Section C, as it does not match there, it is passed over to Section D and then to Section E where it is finally matched and passed for processing on Section A. In Section A packet is matched and assigned to either of 2 address lists (first and second) and then added to seen address-list. After that is done, packed is passed to Section B where its connection is marked and then packet receives its routing mark and is accepted.</p>
<ul>
<li><strong id="variableB6">New packet from seen addressee <a name="New packet from seen addressee "></a></strong></li>
</ul>
<p>Packet is passed through Section C to Section D where it is matched and passed to Section C where connection is marked and accepted</p>
<ul>
<li><strong id="variableB7">Packet from seen addressee <a name="Packet from seen addressee "></a></strong></li>
</ul>
<p>Packet arrives in Section C and is matched there and accepted.</p>
<p>Similarly, For more WANs, an additional IP address is added and additional route with routing-mark respectively as third, forth etc.</p>
<p>Then you have have to edit Sections A-C</p>
<ul>
<li><strong id="variableB8">Changes in Section A<a name="Changes in Section A"></a></strong></li>
</ul>
<p>here we have to adjust nth field value first value is what number of packed we are looking for, usually it is equal to your WAN count. And add additional rule as in example below.</p>
<p>/ip firewall mangle add action=add-src-to-address-list address-list=first address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no nth=3,1<br />
/ip firewall mangle add action=add-src-to-address-list address-list=second address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no nth=3,2<br />
/ip firewall mangle add action=add-src-to-address-list address-list=third address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no nth=3,3<br />
/ip firewall mangle add action=add-src-to-address-list address-list=seen address-list-timeout=0s chain=&#8221;mark new unseen&#8221; disabled=no<br />
/ip firewall mangle add action=jump chain=&#8221;mark new unseen&#8221; disabled=no jump-target=&#8221;mark connection&#8221;</p>
<ul>
<li><strong id="variableB9">Changes in Section B<a name="Changes in Section B"></a></strong></li>
</ul>
<p>here we will have to add 2 new rules, to mark connections that source address is in <em>third</em> address-list, and after that mark routing corresponding to connection mark.</p>
<p>/ip firewall mangle add action=mark-connection chain=&#8221;mark connection&#8221; disabled=no new-connection-mark=first_conn passthrough=yes src-address-list=first<br />
/ip firewall mangle add action=mark-connection chain=&#8221;mark connection&#8221; disabled=no new-connection-mark=second_conn passthrough=yes src-address-list=second<br />
/ip firewall mangle add action=mark-connection chain=&#8221;mark connection&#8221; disabled=no new-connection-mark=third_conn passthrough=yes src-address-list=third<br />
/ip firewall mangle add action=mark-routing chain=&#8221;mark connection&#8221; connection-mark=first_conn disabled=no new-routing-mark=first passthrough=no<br />
/ip firewall mangle add action=mark-routing chain=&#8221;mark connection&#8221; connection-mark=second_conn disabled=no new-routing-mark=second passthrough=no<br />
/ip firewall mangle add action=mark-routing chain=&#8221;mark connection&#8221; connection-mark=third_conn disabled=no new-routing-mark=third passthrough=no</p>
<ul>
<li><strong id="variableB10">Changes in Section C<a name="Changes in Section C"></a></strong></li>
</ul>
<p>Here have to add rule just like in section B just change chain to prerouting as all other rules in this section.</p>
<p>/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=first_conn disabled=no new-routing-mark=first passthrough=no src-address-list=first<br />
/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=second_conn disabled=no new-routing-mark=second passthrough=no src-address-list=second<br />
/ip firewall mangle add action=mark-routing chain=&#8221;prerouting&#8221; connection-mark=third_conn disabled=no new-routing-mark=third passthrough=no</p>
<p>&nbsp;</p>
<p>&#8230;&#8230;&#8230;&#8230;&#8230;.:)</p>
]]></content:encoded>
			<wfw:commentRss>http://kijush.com.np/2011/11/01/nth-load-balancing-with-masquerade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparent Web Proxy in Mikrotik</title>
		<link>http://kijush.com.np/2011/10/12/transparent-web-proxy-in-mikrotik/</link>
		<comments>http://kijush.com.np/2011/10/12/transparent-web-proxy-in-mikrotik/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 14:00:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mikrotik]]></category>
		<category><![CDATA[ACL]]></category>
		<category><![CDATA[http redirection]]></category>
		<category><![CDATA[mikrotik]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[web proxy]]></category>

		<guid isPermaLink="false">http://kijush.com.np/?p=60</guid>
		<description><![CDATA[Introduction Web proxy, a service provided by mikrotik is placed between a client and the internet, specifically for HTTP web surfing. Only HTTP traffic is cached because HTTPS and FTP... <span class="meta-more"><a href="http://kijush.com.np/2011/10/12/transparent-web-proxy-in-mikrotik/">Read more &#187;</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Web proxy, a service provided by mikrotik is placed between a client and the internet, specifically for HTTP web surfing. Only HTTP traffic is cached because HTTPS and FTP are not easy to cache. There are two main benefits to using a web-proxy.<br />
<strong>1. Raising Security for client and network</strong><br />
Security is raised as the client is not directly connected to the website they are requesting data from. The client makes a connection request to the web-proxy and the web-proxy fetches the data on the client&#8217;s behalf. Therefore the internet is connected to the web-proxy interface, not directly to the client. Using a web-proxy also allows the possibility of providing other services, such as anti-virus scanning, content filtering and monitoring or reports on the websites being requested.</p>
<p><strong>2. Enhanced Performance and possibly lowering costs for client and network</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&#8230;&#8230;&#8230;more to come&#8230;&#8230;&#8230;&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://kijush.com.np/2011/10/12/transparent-web-proxy-in-mikrotik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuration of MRTG on Linux</title>
		<link>http://kijush.com.np/2011/09/23/configuration-of-mrtg-on-linux/</link>
		<comments>http://kijush.com.np/2011/09/23/configuration-of-mrtg-on-linux/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 13:53:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[monitoring tool]]></category>
		<category><![CDATA[mrtg]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://kijush.com.np/?p=7</guid>
		<description><![CDATA[The Multi Router Traffic Grapher of MRTG is an open source tool for monitoring the traffic load on Networks. It allows the users to see traffic load on a network... <span class="meta-more"><a href="http://kijush.com.np/2011/09/23/configuration-of-mrtg-on-linux/">Read more &#187;</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://kijush.com.np/wp-content/uploads/2011/09/mrtg-client-daily-300x200.png"><img class="size-medium wp-image-18 alignleft" style="padding-right: 10px;" title="mrtg-client-daily" src="http://kijush.com.np/wp-content/uploads/2011/09/mrtg-client-daily-300x200-300x150.png" alt="mrtg configuration on linux" width="300" height="150" /></a>The Multi Router Traffic Grapher of MRTG is an open source tool for monitoring the traffic load on Networks. It allows the users to see traffic load on a network over time in graphical form. It generates HTML pages containing PNG images which provide a live graphical representation of the traffic.</p>
<p>MRTG works on most UNIX platforms and Windows, but i have described here for UNIX platform specified on Centos 5.x version. MRTG is written in perl and some code in c language.</p>
<p>MRTG uses the Simple Network Management Protocl (SNMP) to send requests with two object identifiers (OIDs) to a device. The device. which must be SNMP-enabled, will have a management information base (MIB) to look up the OIDs specified.  SNMP is use to manage IP network devices such as servers, routers, switches etc. Administrators can find or manage network performance, solve problem or even optimize it further.</p>
<p>This document includes MRTG and snmp binary installation using rpm. Please visit the author&#8217;s website <a href="http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg-unix-guide.html" target="_blank">here</a> for source installation. Required RPMs are mrtg, snmp and snmp-utils.</p>
<p>The first step for mrtg to work is to make sure snmp is up and running. without proper working snmp server, mrtg will not work. Lets follow the following steps for fully working mrtg server.</p>
<p>1: Make sure snmp server is installed<br />
<strong># rpm -qa | grep snmp</strong><br />
Run rpm commands query option to find out snmp server installed or not:</p>
<p>If snmp is installed then please follow the next step or else it should be installed.<br />
<strong># yum install net-snmp-utils net-snmp</strong><br />
yum command can be used to install snmp package in centos or fedora. For other distros, you can find rpms in <a href="http://rpmfind.net/linux/RPM/">rpmfind.net</a></p>
<p>2: Determine if SNMP server is running or not<br />
<strong># ps -aux | grep snmp</strong><br />
This command will list the process if snmp server is running.</p>
<p><strong>Output:</strong><br />
root      1442  0.0  0.6  27432  6564 ?        Sl   Aug04   2:29 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a<br />
root     17653  0.0  0.0   3924   696 pts/0    S+   09:18   0:00 grep snmp<strong></strong></p>
<p>Alternatively, following two commands can be run as well:<br />
<strong># /usr/sbin/lsof -i :199</strong> <strong></strong></p>
<p><strong>Output:</strong><br />
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME<br />
snmpd   1442 root   10u  IPv4   4101       TCP mrtgtestserver:smux (LISTEN)</p>
<p>OR # <strong>netstat -natv | grep &#8216;:199&#8242;</strong> <strong><br />
</strong></p>
<p><strong>Output:</strong><br />
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN</p>
<p>If  you get the above outputs, the you can move on to next step or you have to start the service using following command: <strong><br />
# service snmpd start </strong></p>
<p>snmpd service should start automatically as linux boots: <strong><br />
# chkconfig &#8211;add snmpd</strong></p>
<p>3: Make sure snmp server is configured properly<br />
snmpwalk utility is used to request for tree of information about network entity. i.e. query snmp server for server&#8217;s ipaddress assigned to it&#8217;s interface.<br />
<strong># snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex</strong><br />
<strong></strong></p>
<p><strong>Output:</strong><br />
IP-MIB::ipAdEntIfIndex.192.168.1.100 = INTEGER: 2<br />
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1</p>
<p>If the result is as given to output, then follow the next step, else you need to configure snmp server as follows:</p>
<p><strong>Configure SNMP<br />
</strong>1. Edit the file /etc/snmp/snmpd.conf using vi text editor:<br />
<strong># vi /etc/snmp/snmpd.conf<br />
</strong>Modify the lines as follows:</p>
<p>Find lines:<br />
com2sec notConfigUser  default          public</p>
<p>Replace with:<br />
com2sec   local                localhost                 public<br />
com2sec   mynetwork  192.168.1.0/24    public<br />
<strong></strong></p>
<p><strong>Note:</strong> My local network is 192.168.1.0/24. What about yours? replace it with your network.</p>
<p>Find lines:<br />
group        notConfigGroup    v1             notConfigUser<br />
group        notConfigGroup    v2c          notConfigUser</p>
<p>Replace with:<br />
group     MyRWGroup    v1                local<br />
group     MyRWGroup    v2c             local<br />
group     MyRWGroup    usm            local<br />
group     MyROGroup     v1               mynetwork<br />
group     MyROGroup     v2c            mynetwork<br />
group     MyROGroup     usm           mynetwork</p>
<p>Find lines:<br />
view       systemview         included           system</p>
<p>Replace with:<br />
view   all           included         .1                                                  80</p>
<p>Find lines:<br />
access       notConfigGroup   &#8221; &#8220;          any          noauth          exact           systemview   none    none</p>
<p>Replace with:<br />
access   MyROGroup  &#8221; &#8220;         any          noauth         exact       all       none     none<br />
access   MyRWGroup &#8221; &#8220;         any          noauth         exact       all       all          none</p>
<p>Find lines:<br />
syslocation Unknown (edit /etc/snmp/snmpd.conf)<br />
syscontact Root (configure /etc/snmp/snmp.local.conf)</p>
<p>Replace with:<br />
syslocation Linux (CentOS), MRTG Server.<br />
syscontact Kijush Maharjan &lt;kijush.maharjan@gmail.com&gt;</p>
<p>Start the snmp server and test it:<br />
a. snmpd should always start as linux boots.<br />
<strong># chkconfig  snmpd on</strong><br />
b. make sure service start whenever linux comes up after reboot.<br />
<strong># sevice snmpd on</strong><br />
c. Finally test the snmp server:<br />
<strong># snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex</strong></p>
<p>4: Install mrtg if not installed<br />
MRTG package may install during initial installation. It can be verified if MRTG has been installed or not by following command:<br />
<strong># rpm -qa | grep mrtg</strong></p>
<p><strong></strong>If MRTG is already installed, lets move on to next step else It can be found on rmpfind.net or it is also bundled with centos installation cd.</p>
<p>Yum command can be used on fedora linux as well as centos to install MRTG.<br />
<strong># yum install mrtg</strong></p>
<p><strong></strong>5: Configuration of MRTG<br />
a. Create document root to store mrtg graphs and html pages:<br />
<strong># mkdir -p /var/www/html/mymrtg/</strong><br />
b. Run following commands to create mrtg configuration file:<br />
<strong># cfgmaker &#8211;global &#8216;WorkDir: /var/www/html/mymrtg&#8217; &#8211;output /etc/mrtg/mrtg1.cfg public@localhost</strong>            (For localhost)<br />
<strong># cfgmaker &#8211;global &#8216;WorkDir: /var/www/html/mymrtg&#8217; &#8211;output /etc/mrtg/router.cfg public@192.168.1.1</strong>      (For router)<br />
<strong># cfgmaker &#8211;global &#8216;WorkDir: /var/www/html/mymrtg&#8217; &#8211;output /etc/mrtg/server.cfg public@192.168.1.2</strong>      (For linux/windows server)<br />
c. Generate default index page for MRTG configuration:<br />
#<strong> indexmaker &#8211;output=/var/www/html/mymrtg/index.html /etc/mrtg/router.cfg /etc/mrtg/server.cfg /etc/mrtg/localhost.cfg</strong>        (index.html file for all generated cfg file. It can also be separeted as necessary)<br />
d. copy all tiny png files to the mrtg path:<br />
<strong># cp -av /var/www/html/mrtg/*.png /var/www/html/mymrtg/</strong></p>
<p>6: First test run of MRTG<br />
a. Run mrtg command from command line with the configuration file:<br />
<strong># mrtg /etc/mrtg/router.cfg</strong><br />
<strong>Note:</strong> This command will generate error regarding enviroment. so following command is used:<br />
<strong># env LANG=C /usr/bin/mrtg /etc/mrtg/router.cfg</strong><br />
<strong>Note:</strong> Few warning messages may be displayed, but above command should run until it stop to display warning messages.<br />
b. Now from the web browser type url: <strong>http://&lt;ipaddress of mrtg server&gt;/mymrtg</strong></p>
<p>7: Create crontab entry so that mrtg graphs and images get generated every 5 minutes<br />
a. Login as root and type the following command:<br />
<strong># crontab -e</strong><br />
b. Add mrtg cron job entry to configuration file:<br />
<strong>*/5 * * * * /usr/bin/mrtg /etc/mrtg/mymrtg.cfg &#8211;logging /var/log/mrtg.log</strong><br />
<strong>*/5 * * * * /usr/bin/mrtg /etc/mrtg/router.cfg &#8211;logging /var/log/mrtg.log</strong><br />
<strong>*/5 * * * * /usr/bin/mrtg /etc/mrtg/server.cfg &#8211;logging /var/log/mrtg.log</strong><br />
save file and it&#8217;s done with MRTG configuration.</p>
<p>8: I don&#8217;t think anyone wanna give access to their snmp server for security reasons. SNMP server users UDP 161, 162 ports for communications. Linux IPTABLES firewall can be used to restrict access to SNMP Server.<br />
a. Allow outgoing SNMP server request from linux computer. This is useful when you query remote host/router.<br />
<strong>SERVER=&#8221;xxx.xxx.xxx.xxx&#8221;</strong><br />
<strong>iptables -A OUTPUT -p udp -s $SERVER &#8211;sport 1024:65535 -d 0/0 &#8211;dport 161:162 -m state &#8211;state NEW,ESTABLISHED -j ACCEPT </strong><br />
<strong>iptables -A INPUT -p udp -s 0/0 &#8211;sport 161:162 -d $SERVER &#8211;dport 1024:65535 -m state &#8211;state ESTABLISHED -j ACCEPT</strong></p>
<p>b. Allow incoming SNMP client request via iptables. This is useful when you wish to accept queries for rest of the world.<br />
<strong>SERVER=&#8221;xxx.xxx.xxx.xxx&#8221;</strong><br />
<strong>iptables -A INPUT -p udp -s 0/0 &#8211;sport 1024:65535 -d $SERVER &#8211;dport 161:162 -m state &#8211;state NEW,ESTABLISHED -j ACCEPT</strong><br />
<strong>iptables -A OUTPUT -p udp -s $SERVER &#8211;sport 161:162 -d 0/0 &#8211;dport 124:65535 -m state &#8211;state ESTABLISHED -j ACCEPT</strong><br />
<strong>Note:</strong> The above two rules just SNMP specific iptables rules. Please refer iptables documents for complete information about iptables.</p>
<p>9: Protect MRTG graphs/html pages with password protected directory<br />
Restricting access to MRTG reports can be accomplished with Apache webserver&#8217;s .htaccess file. Follow the process outlined to protect graphs using apache&#8217;s .htaccess file and htpasswd command:<br />
a. Create .htaccess file in /var/www/html/mymrtg/ directory<br />
<strong>vi /var/www/html/mymrtg/.htaccess</strong><br />
Add following text to file:<br />
<strong>AuthName &#8220;MRTG Graphs/Html restricted access&#8221;</strong><br />
<strong>AuthType Basic</strong><br />
<strong>AuthUserFile /var/www/html/mymrtg/.htpasswd</strong><br />
<strong>require user mrtgadmin</strong></p>
<p>b. Create a user and password name (-c assumes first time you are using .htpasswd file, -m for modifying):<br />
<strong># htpasswd -c /var/www/html/mymrtg/.htpasswd mrtgadmin</strong><br />
For more information about apache web server and it&#8217;s authentication method, please refer to apache web server documentation.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://kijush.com.np/2011/09/23/configuration-of-mrtg-on-linux/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

