How To Limit New Incoming Connections With Iptables (Slackware)

25 08 2008

Kali ini saya akan berbagi hasil temuan di om google mengenai limitasi koneksi pada linux BOX kita. Mungkin sudah banyak sekali yang mengetahuinya, namun tetep aja saya pengen nulis. Itung-itung supaya saya tidak lupa :D

Kalau ditanya kenapa harus di limit? Iseng aja kale ya “peace!”

Tested on Slackware 12.0, iptables v1.3.8 and work properly.

That is:

1. Ilustrasinya :
Kita akan membatasi bahwa hanya 2 koneksi baru yang diperbolehkan masuk ke Linux BOX dalam kurun waktu 60 detik terakhir.

2. Code :
# iptables -I INPUT -p tcp --dport 23 -i eth1 -m state --state NEW -m recent --set
# iptables -I INPUT -p tcp --dport 23 -i eth1 -m state --state NEW -m recent --update \
--seconds 60 --hitcount 2 -j DROP

3. Sekilas penjelasan :
- Baris pertama itu fungsinya untuk menge-set daftar ip yang melakukan “new connection” ke port 23
- Baris kedua merupakan triger untuk menutup koneksi terhadap suatu ip apabila ada lebih 2 koneksi baru yang masuk ke port 23 pada 60 detik terakhir.

note :
Rule iptables ini efectif digunakan pada protokol TCP. Kalau selain TCP saya belum pernah coba karena belum menemukan cara yang tepat untuk ngetestnya :D .
Kalau teman-teman ada ayang pernah coba, tolong dong di bagi-bagi.

Good Luck, Selamat mencoba





Script Auto SCP/SFTP On Linux

25 08 2008

Terkadang kita ingin mengambil file / data dari remote server dengan menggunakan scp / sftp. Tulisan ini saya buat disaat diriku ingin melakukan hal tersebut dengan menggunakan script. Makssudnya mau saya pasang di crontab :D

Begini caranya :

Requirement
1. OpenSSH
2. Expect

Ilustrasinya adalah :

Server-B 192.168.1.2 ingin mengambil file dari Server-A 192.168.1.1.
File Yang akan diambil dan disimpan adalah “passwd” dan di simpan pada direktori /home/dianseh pada server-B dengan nama file “passwd-Server-A”

Script nya adalah:

—- Script Start —–

#!/usr/bin/expect --
#spawn sftp dianseh@192.168.1.1:/etc/passwd /home/dianseh/passwd-Server-A
spawn scp dianseh@
192.168.1.1
:/etc/passwd /home/dianseh/passwd-Server-A
expect "dianseh@
192.168.1.1
's password:"
send "passwordnya\r"
expect "%$"

—- Script End —–

Note :
Script ini sudah saya pakai pada Linux Slackware 12. Untuk O/S lainnya harap diperhatikan prompt yang muncul pada saat login.

Silahkan mencoba, kalo ada yang kesulitan, bisa ditanyakan deh. Siapa tahu dirikuw bisa kasih arahan.

peace!





How To Install Cacti on Slackware

25 08 2008

This sections about mini how to install cacti on Slackware (12.0). Isone mung iki, Peace!

All done with simple step :

Packages was installed on my system:
1. Apache/2.2.4 (Unix)
2.PHP 5.2.5 (cli) enables : with-snmp, with-zlib, with-gd, enable-ucd-snmp-hack
3.Mysql-5.0.27
4.rrdtool-1.2.23-i486-1gds
5.Net-snmp-5.4

1. Extract the cacti distribution tarball on web directory
root@dianseh:# cd /var/www/htdocs/
root@dianseh:# tar zxvf cacti-version.tar.gz
root@dianseh:# mv cacti-version cacti
root@dianseh:# cd cacti

2. Created the user and group
root@dianseh:# groupadd cacti
root@dianseh:# useradd -g cacti cacti

3. Create the MySQL database, import the default database, create username and password for cacti:
root@dianseh:# mysqladmin --user=root -p create cacti
root@dianseh:# mysql cacti GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'yourpassword';
mysql> flush privileges;

4. Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "yourpassword";

5. Change directory permissions
root@dianseh# chown -R cacti:cacti rra/ log/

6. Add a line to your crontab
root@dianseh# su - cacti
cacti@dianseh# crontab -e
*/5 * * * * php /var/www/htdocs/cacti/poller.php > /dev/null 2>&1

cacti@dianseh# exit

7. Try to open full path url http://cactiserver/cacti/

All done with following those step carefully.

Begitu ceritanya, cacti saya sudah dapat berjalan dengan mengikuti langkah-langkah tersebut di atas.

Selamat mencoba, Good Luck

Reference :
1. http://www.cacti.net/downloads/docs/html/unix_configure_cacti.html





How to remove ip address on Windows XP via "cmd"

25 08 2008

Saya akan berbagi cara mengenai penghapusan ip address pada windows XP melalui “cmd”, bukan melalui control pannel seting ethernet.

Mengapa repot tidak menggunakan control panelnya saja? Karena saya ingin coba “different way”.

The story is:

1.Check your ip configuration
c:\>ipconfig /all
Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom NetLink (TM) Fast Ethernet
Physical Address. . . . . . . . . : 00-1C-23-FA-A2-87
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 121.121.121.1
Subnet Mask . . . . . . . . . . . : 255.0.0.0
IP Address. . . . . . . . . . . . : 222.222.222.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0

2. Starting remove your ip (ex : 121.121.121.1)

c:\>netsh interface ip delete address “Local Area Connection” addr=121.121.121.1
c:\>ipconfig /all
Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom NetLink (TM) Fast Ethernet
Physical Address. . . . . . . . . : 00-1C-23-FA-A2-87
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 222.222.222.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0

3. Ip address 121.121.121.1 have been removed from system, Done.

Note : “Local Area Connection” is your interface name.

Siapa yang mau coba di persilahkan loh, Hasilnya kasih tau yah :D

Related link at my blogspot





How to remove ip address on Windows XP via “cmd”

25 08 2008

Saya akan berbagi cara mengenai penghapusan ip address pada windows XP melalui “cmd”, bukan melalui control pannel seting ethernet.

Mengapa repot tidak menggunakan control panelnya saja? Karena saya ingin coba “different way”.

The story is:

1.Check your ip configuration
c:\>ipconfig /all
Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom NetLink (TM) Fast Ethernet
Physical Address. . . . . . . . . : 00-1C-23-FA-A2-87
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 121.121.121.1
Subnet Mask . . . . . . . . . . . : 255.0.0.0
IP Address. . . . . . . . . . . . : 222.222.222.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0

2. Starting remove your ip (ex : 121.121.121.1)

c:\>netsh interface ip delete address “Local Area Connection” addr=121.121.121.1
c:\>ipconfig /all
Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom NetLink (TM) Fast Ethernet
Physical Address. . . . . . . . . : 00-1C-23-FA-A2-87
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 222.222.222.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0

3. Ip address 121.121.121.1 have been removed from system, Done.

Note : “Local Area Connection” is your interface name.

Siapa yang mau coba di persilahkan loh, Hasilnya kasih tau yah :D

Related link at my blogspot