Friday, January 29, 2010

SNMP & Cacti Configuration

Basically, i refer my SNMP and Cacti installation here. It works nicely. I would like to paste here everything i have done to make it works in my PC.

Below is how the architecture looks since I want Cacti to monitor many devices at a time. Firstly, assign one PC as manager (which Cacti will be installed) and all of devices to be monitored. They are connected using SNMP.

Below is the setting I had done to my manager:

1) Firstly, install SNMP
$sudo apt-get install snmpd

2) Then check
$sudo gedit /etc/default/snmpd

Make sure
# snmpd control (yes means start daemon).

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/'

3) Next,
$sudo gedit /etc/snmp/snmpd.conf

In the line of com2sec setting, I have adjusted as below (slightly different from How-To)
# source community
com2sec readonly localhost public

If you have your own community, you could use it for better security.

4) Check SNMP configuration
$snmpwalk -Os -c public -v 1 localhost system

(If you use your community, replace 'public' with your community name)

This command will return result something like this:

5) CACTI- Installation
I did exactly like here.

For all other devices, configure SNMP server same like above. That's all :)

Sunday, January 17, 2010

Mysql Cluster with Mysql 5.1 on Ubuntu Server 9.10

We're currently implementing memcached on mysql cluster using mysql 5.1. So, to make it quick, i followed a guide from howtoforge written by Peter Okupski in this site. It works for me.

There are several things need to be concerned before implementing this guide on ubuntu server 9.10.
  1. Don't install mysql-server5.1 from the repository using apt-get.
    For me, it's easier to install mysql cluster by using source code in ubuntu. Source code can be downloaded form mysql site. On 'select platform' option, choose 'source code' and download the tar file mysql-cluster-gpl-[version].tar.gz
    (Note: register, it is free!)

  2. Install build-essential package to allow compiling source file
    $ sudo apt-get install build-essential

  3. Install developer's library for ncurses
    $ sudo apt-get install libncurses5-dev

    This will avoid an error:
    configure error: No curses/termcap library found
Now, it's ready :-)


Sunday, January 10, 2010

Setting Up Gateway in Ubuntu

I just think how to set up simple gateway server for a LAN. After searched for a while, i found some useful guide (see references).
First, the server machine needs to have at least two interfaces, e.g. eth0 and eth1. In my case, I used eth0 for connecting to internet and eth1 for connecting LAN connection.
It is not necessarily use eth0 to be connected to Internet. It depends on your Internet connection. It could be wlan0, ppp0 etc. This also useful for connecting two different networks.

Assume that your machine will be used as a gateway. This guide will be based on the figure below:

IP address Configuration
In this guide, IP address for each host in LAN need to be configured manually, unless DHCP server is installed.

DNS Server and Gateway
All hosts in LANneed to have same DNS server as your machine has and add the IP address of your machine as a gateway in LAN hosts, so that the IP packets will be route to the Internet through your machine.

Configuration of 'Gateway' machine
Step 1: Find DNS server on your machine
$ cat /etc/resolv.conf

The output will be like this
# Generated by NetworkManager

Step 2: Enable IP forwarding
First, check the default value. There are two ways.
Note: 0 means it is disabled

1. using sysctl command.
$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

2. cat the file /proc/sys/net/ipv4/ip_forward.
$ cat /proc/sys/net/ipv4/ip_forward

Second, change the value temporarily, so that, it will reset to 0 when you have shutting down the machine.
$ sudo sysctl -w net.ipv4.ip_forward=1

Try to check again to see the changed value.

To permanently enable the IP forwarding, you need to edit sysctl configuration file. Use any familiar text editor such as nano, vi and gedit.
$ sudo gedit /etc/sysctl.conf

Find these two lines, and uncomment the second line (remove the # symbol)
# Uncomment the next line to enable packet forwarding for IPv4

# Uncomment the next line to enable packet forwarding for IPv4

or simply edit using this command:
$ sudo sed -i 's/#net.ipv4.ip_forward/net.ipv4.ip_forward/g' /etc/sysctl.conf

Then update the change made.
$ sudo sysctl -p /etc/sysctl.conf

Step 3: Configure NAT on IP tables
iptables is very useful for maintain tables of IPv4 packet filtering in linux kernel. It has lots of chain rule. For performing NAT we have the command above (see manual for details):
$ sudo iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

-t nat, an option of IP table to perform NAT at each packet matching.
-A POSTROUTING. The –A is used for append chain rule of –t and we use POSTROUTING for altering packets as they are about to go out.

-s indicates as source address from where the IP packet can route through the NAT. it should be followed by IP address along with the netmask. In this command it shows and IP address of with subnet mask, which need to be written as This IP will be used in LAN from - Your machine can use for eth0 interface. (Google IP and subnet mask tutorial)

-o is used for name of an interface via which a packet is going to be sent (POSTROUTING). In this example, we used eth0 since it is the only interface that can be connected to internet.

-j should be followed by target extension. In this option we choose MASQUERADE. This target is only valid in the NAT table, in the POSTROUTING chain. Masquerading is equivalent to specifying a mapping to the IP address of the interface the packet is going out.

Now, restart your network service (not necessary)
$ sudo /etc/init.d/networking restart

We are done configuring IP forwarding, NAT and gateway on your machines. The next step is configuring IP address on LAN hosts.

Configuration of Hosts in LAN
Enter IP address to the hosts in range -
in the gateway field, put the IP address of 'gateway' machine, which is

Then, restart the network for linux host. Note that the configuration will be the same for Windows hosts.

Check internet connection for the hosts in LAN
Hope this will help you. Enjoy!