24 Januari 2014

Network Traffic Monitoring with IPTraf

There are number of monitoring tools available. Moreover, I came across a IPTraf monitoring tool which I find very useful and it’s a simple tool to monitor Inbound and Outbound network traffic passing through interface.

Iptraf is an ncurses-based IP LAN monitor that generates various net- work statistics including TCP info, UDP counts, ICMP and OSPF informa- tion, Ethernet load info, node stats, IP checksum errors, and others.

1. Make sure the iptraf has installed, if not just install it with the following command.
#apt-get install iptraf

2. Once IPTraf installed, run the following command from the terminal to launch an ascii based menu interface that will allow you to view current IP traffic monitoring, General interface statistics, Detailed interface statistics, Statistical breakdowns, Filters and also provide some configure options where you can configure as per your need.
3.  IP Trafic Monitoring:

4. General Interface Statistics:

5. Detailed Interface Statistics:

6. Statistical Breakdowns:

7. LAN Station Monitor:

21 Januari 2014

Linux kernel 3.13 Released

This release includes nftables (the successor of iptables); a revamp of the block layer designed for high-performance SSDs; a framework to cap power consumption in Intel RAPL devices; improved squashfs performance; AMD Radeon power management enabled by default and automatic AMD Radeon GPU switching; improved NUMA and hugepage performance; TCP Fast Open enabled by default; support for NFC payments; support for the High-Availability Seamless Redundancy protocol; new drivers; and many other small improvements.

Here's the full list of changes.

14 Januari 2014

How to eliminate Index.php in CodeIgniter

It's easy to eliminate index.php from url in CodeIgniter. For example before we eliminate the index.php we need to access a home with the url form http://localhost/CI/index.php/home. However after we create a .htaccess file the url will be changed to be http://localhost/CI/home.

The .htaccess file created to be parallel with the Application and System directory. Open .htaccess file then write the following script into the file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

FTP Server

I will share how to install and configure FTP server in Debian.

1. Install proftpd.
#apt-get install proftpd

When the process installation running, display a window prompted to select "from inetd" and standalone. The advisable to chose standalone.

2.Create new user for FTP server.
# adduser ftpserver

3.Create permission for FTP server user.
#chmod 777 /home/ftpserver/

4. Restart proftpd
#/etc/init.d/proftpd restart
5.Check the server with the IP/domain FTP server and we will be asked to enter the password and username:

6. Create a directory or file.
ftp> mkdir documents

7. Try to login from client:

8. Login successful into the FTP server:

Download and upload data via FileZilla:

Filtering Mac Address in Debian

 We can use iptables to perform the filtering on certain Mac address

1. Block Mac Address:
iptables -A INPUT -m mac –mac-source 0a:00:27:00:00:00 -j DROP
iptables -A INPUT -m mac –mac-source 52:54:00:12:35:02 -j DROP

2. Allow Mac Address:
iptables -A INPUT -m mac –mac-source 0a:00:27:00:00:00 -j ACCEPT
iptables -A INPUT -m mac –mac-source 52:54:00:12:35:02 -j ACCEPT

3.Adding IP, the IP which will be added ascertained in accordance with the Mac address, If not It will be denied:
iptables -A INPUT -s -m mac –mac-source 0a:00:27:00:00:00 -j ACCEPT
iptables -A INPUT -s -m mac –mac-source 52:54:00:12:35:02 -j ACCEPT

Ping Block in Linux

Ping block is a way to avoid from ping flood. For blocking the ping flood just follow the steps bellow:

1. Try to ping the IP of the computer which will be blocked its ICMP protocol.

2. Edit /etc/rc.local
Add the following script into the file rc.local, locate it before exit 0.
iptables -A INPUT -p icmp –icmp-type echo-request -j DROP

3.Make sure that after the computer rebooted, the output of ping will be like the following screenshot. 

Password Protect a Directory with .htaccess

The Apache web server can read the .htaccess file that is located anywhere in the root documents to perform different tasks and control settings without changing the files configuration. It is very useful when we do not have permission to modify the configuration files. In this post I want to share how to password protect a directory on a website with .htaccess.

To protect a directory we need to follow the steps bellow:

1. First of all, we create a file contains the Username and Password. We can create that file anywhere, however in this post I will create the file inside the /etc/apache2. Therefore, the file together with the apache configuration files in a directory.
#htpasswd -c /etc/apache2/.htpasswd abrao 
#htpasswd /etc/apache2/.htpasswd abrao1

 2. Create a .htaccess file in the web project directory which we want to protect with the password. In this tutorial, the directory which will be protected is download.
#touch /var/www/download/.htaccess 

 3. Edit the .htaccess file:

#vim /var/www/download/.htaccess 
Then write the following scripts into the file:

AuthType Basic 
AuthUserFile /etc/apache2/.htpasswd 
AuthName “Enter password” 
Require valid-user 

 In this post, the .htaccess file was created inside the /etc/apache2. Therefore, on the line AuthUserFile we have to change it with /etc/apache2/.htpasswd. However, If the .htaccess file create inside another directory the AuthUserFile has to tailored with the path of the file.

 4. Make sure that the apache has allowed the .htaccess override settings. If the apache didn't allow yet, we need to edit the 000-default file.

# vim etc/apache2/sites-enabled/000-default 

Change the AllowOverride deny to be AllowOverride all 

 5. Restart Apache
#/etc/init.d/apache2 restart 

6. Open your browser then enter your IP with the protect directory.


If the directory successful protected, we will be asked to enter the Username and Password:
However, if the server has an error then make sure the user is allowed to read the Apache file .htaccess and another .htaccess file in the download directory.

#chmod 755 /var/www/download/.htaccess 
#chmod 755 /etc/apache2/.htpasswd 

 If we successful login the protected directory, then we can see all the content of the download directory.