Saturday, January 16, 2010

Mengamati Keamanan Jaringan Komputer

Mengetahui aman tidaknya suatu jaringan komputer, bisa dilihat dari pintu-pintu yang terbuka pada komputer gerbang atau Gateway. Dalam dunia IP, pintu diistilahkan sebagai port. Gangguan bisa masuk lewat pintu lupa ditutup, pintu yang terbuka atau pintu yang lupa ditutup. Kalau mau aman, tutup semua pintu. Namun konsekuensi adalah tidak bisa akses ke luar atau ke Internet. Jadi jalan tengahnya adalah membuka pintu-pintu tertentu saja. Biasanya port yang dibuka adalah
  1. Port 22, untuk SSH (semacam telnet yang secure)
  2. Port 80, untuk HTTP akses ke website
Selain port di atas, pembukaan port dilakukan sesuai permintaan. Untuk port dan fungsinya, silahkan tengok di http://www.iana.org/.

Dengan hanya membuka beberapa port dan menutup puluhan ribu port-port, diharapkan akan mengamankan komputer client dalam suatu LAN dari serangan luar. Cerita akan menjadi lain jika serangan berasal dari komputer client dalam satu LAN. Administrator LAN hanya mengamankan perimeter terluar dari LAN. Perimeter satker dan personil menjadi tanggung jawab masing-masing user, karena keterbatasan perangkat keras yang dimiliki oleh Administrator LAN.

Pengamanan akan berbeda untuk komputer server yang menggunakan IP Publik. Konvensinya, pengamanan dilakukan oleh si empunya server. Meskipun port pada komputer server sudah pada ditutup, namun bisa saja aplikasinya yang bolong. Sehingga serangan semacam SQL Injection bisa dilakukan. Atau jika aplikasi memiliki titik lemah yang tidak diketahui oleh si pemilik server. Ibaratnya, ada orang yang masuk ke kawasan perkantoran, berpakaian perlente, memakai badge dan segala atribut yang resmi, masuk lewat pintu penjagaan resmi, maka tak ada yang akan menaruh curiga. Sehingga orang tersebut bisa dengan mudah melewati petugas. Padahal sebenarnya ybs adalah intruder. Lain halnya kalau ada orang yang berpakaian aneh, lewat pagar yang bolong atau lewat pagar yang tak terjaga, pasti akan lebih mudah untuk dicurigai.

Untuk melihat port yang dibuka pada suatu server, cukup menggunakan perintah baris NMAP yang diikuti dengan IP Address server tersebut. Misal, kita akan dilihat port mana saja yang terbuka pada server Digilib. Hasilnya adalah sbb :

$ nmap 202.46.3.69
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 17:19 WIT

Interesting ports on 202.46.3.69:
Not shown: 1700 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
199/tcp open smux
445/tcp filtered microsoft-ds
593/tcp filtered http-rpc-epmap
623/tcp filtered unknown
664/tcp filtered unknown
1720/tcp filtered H.323/Q.931
3306/tcp open mysql
4444/tcp filtered krb524
4662/tcp filtered edonkey

Tampaknya port yang terbuka pada server Digilib adalah port 21, 22, 80, 199, dan 3306. Biasanya port 199 dan 3306 jarang dibuka. Mungkin saja si empunya server punya pertimbangan lain sehingga kedua port ini dibuka.

Open Port di Server NHC :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 17:47 WIT
Interesting ports on 202.46.3.75:
Not shown: 1702 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
593/tcp filtered http-rpc-epmap
1720/tcp filtered H.323/Q.931
3306/tcp open mysql
4444/tcp filtered krb524
4662/tcp filtered edonkey

Open Port di Proxy Serpong :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 17:25 WIT
Interesting ports on 202.46.3.66:
Not shown: 1705 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http
137/tcp closed netbios-ns
138/tcp closed netbios-dgm
161/tcp closed snmp
3128/tcp open squid-http
8080/tcp open http-proxy
8888/tcp closed sun-answerbook
9090/tcp open zeus-admin

Open Port di Proxy Kuningan :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 18:11 WIT
Interesting ports on 202.46.3.98:
Not shown: 1711 filtered ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp closed domain
80/tcp open http

Open Port di Proxy PsJumat :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 18:13 WIT
Interesting ports on 202.46.3.114:
Not shown: 1711 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
9090/tcp closed zeus-admin

Open Port di Server SIPL :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 18:26 WIT
Interesting ports on 202.46.3.78:
Not shown: 1678 closed ports, 29 filtered ports
PORT STATE SERVICE
21/tcp open ftp
80/tcp open http
443/tcp open https
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
3306/tcp open mysql
3389/tcp open ms-term-serv

Router Serpong :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 18:37 WIT
Interesting ports on 202.46.3.65:
Not shown: 1705 closed ports
PORT STATE SERVICE
23/tcp open telnet
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
593/tcp filtered http-rpc-epmap
1720/tcp open H.323/Q.931
4444/tcp filtered krb524
4662/tcp filtered edonkey
5060/tcp open sip

Router Kuningan :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 20:00 WIT
Interesting ports on 202.46.3.97:
Not shown: 1705 closed ports
PORT STATE SERVICE
23/tcp open telnet
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
593/tcp filtered http-rpc-epmap
1720/tcp open H.323/Q.931
4444/tcp filtered krb524
4662/tcp filtered edonkey
5060/tcp open sip

Router Pasar Jum'at :
Starting Nmap 4.53 ( http://insecure.org ) at 2010-01-16 18:38 WIT
Interesting ports on 202.46.3.113:
Not shown: 1705 closed ports
PORT STATE SERVICE
23/tcp open telnet
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
593/tcp filtered http-rpc-epmap
1720/tcp filtered H.323/Q.931
4444/tcp filtered krb524
4662/tcp filtered edonkey
9040/tcp filtered tor-transport

Tip dan Trik pada Mikrotik

Suatu kali saya bingung, kenapa tampilan Inteface List jadi berbeda. Biasanya per Interface ditampilkan cukup dalam sebaris informasi. Nah sekarang menjadi 4 baris informasi. Ternyata ini hanyalah masalah pilihan detail. Untuk itu : klik kanan interface lalu pilih Detail Mode. Selesai. Informasi per interface kembali dalam sebaris.

Cara setting Mikrotik RB450G dengan ISP Speedy yang masih menjadi pertanyaan :
  1. Kabel antara Modem DSL abbatec dengan Eth1 pada Miktorik RB450G : Straight atau Cross. Default dari Telkom : Straight. Ternyata Straight OK, tidak perlu Cross Cable
  2. Connection Type dari WAN modem DSL abbatec : PPPoA, PPPoE, MER, IPoA, atau Bridging. Default dari Telkom : PPPoE. Tipe yang diharapkan : Bridging.
  3. Encapsulation Mode dari WAN modem DSL abbatec : LLC/SNAP - BRIDGING atau VC/MUX. Default dari Telkom : LLC/SNAP - BRIDGING. Ternyata LLC tetap bisa digunakan.
  4. Mikrotik RB450 di-setting bagaimana. Ternyata perlu ditambah PPPoE Client dengan parameter Name : speedy, Interface : ether1-gateway, user/pass = gunakan user speedy.
Jika pertanyaan-pertanyaan di atas sudah terjawab, selanjutnya bisa dilakukan setting Modem DSL dan Mikrotik.

Untuk melakukan setting, Modem DSL, Mikrotik RB450 dan PC dihubungkan ke sebuah Switch. Modem DSL menggunakn IP 192.168.1.1 (default). Miktorik RB450 menggunakan IP 192.168.1.2 (ether1-gateway) dan IP 192.168.2.1 (ether1-local). PC menggunakan IP 192.168.1.5.

Setup Modem DSL sebagai Bridge.
  • Setting modem dilakukan melalui web browser dengan mengakses alamat http://192.168.1.1
  • Masukkan username dan password : admin/admin atau sesuai dengan kondisi
  • Masuk ke menu “Advanced Setup” kemudian pilih “WAN” dan klik tombol “Edit” pada protokol PPPoE. Masukkan nilai ATM PVC Configuration : (masukkan nilainya sesuai wilayah PT. TELKOM masing-masing daerah).
  • VPI = 0 (atau tanyakan ke PT. TELKOM setempat)
  • VCI = 35 (atau tanyakan ke PT. TELKOM setempat)
  • Connection type = Bridging
  • Encapsulation = LLC/SNAP-BRIDGING, kemudian klik tombol Next
  • Tandai atau kasih v untuk pilihan “Enable Bridge Service”, Service Name = br_0_35, kemudian klik Next dan klik tombol Save
  • Selanjutnya klik tombol Save/Reboot
Catatan :
  1. Modem akan reboot -/+1 menit dan tunggu sampai modem normal kembali.
  2. Untuk modem model lainnya silahkan baca manualnya
Setup Mikrotik RB450G menjadi PPPoE Client
  • Login WinBox. Winbox bisa dijalankan di Windows dan Wine-nya Fedora.
  • Kemudian pilih menu PPP yang mana nanti akan muncul box untuk setup PPPoE
  • Klik toolbar add (bergambar tanda +) di box PPP, kemudian pilih menu PPPoE Client
  • Maka akan muncul box New Interface, kemudian pada tab General di field Name kita beri nama koneksi PPPoE tersebut (dalam artikel ini menggunakan nama speedy)
  • Tetap di dalam box New Interface, pilih tab Dial Out. Di situ kita akan menemukan field untuk Username dan Password. Kita isikan username dan password account speedy kita, dan biarkan setting lainnya dalam keadaan default
  • Kemudian kita klik OK dan tunggu Mikrotik untuk Dial speedy. Jika benar maka di box PPP akan muncul hasil setup kita sebelumnya dengan di kolom uptime akan mulai menghitung Uptime koneksi ADSL.
  • Untuk mengoreksi apakah setup kita benar bisa kita lakukan dengan cara PING ke Internet.
Setelah setting berhasil dilakukan, LAN perlu direkonfigurasi ulang. Modem DSL yang tadinya dihubungkan ke Switch, sekarang dihubungkan ke Mikrotik RB450 ether1-gateway. Sementara Mikrotik RB450 ether2-local dihubungkan ke Switch. Sekarang Switch hanya menghubungkan antara Mikrotik dan PC. IP Address PC-pun perlu diubah dari 192.168.1.5 menjadi 192.168.2.5. Dan supaya Laptop bisa memanfaatkan akses Internet maka ditambahkan sebuah WAP Senao 2811CB3 dengan IP 192.168.2.2.

Namun sayangnya keberhasilan konfigurasi ini hanya bertahan beberapa jam. Kalau diperhatikan, ternyata parameter Default Gateway pada Modem DSL selalu kosong. Meskipun modem DSL sudah di-reboot dan power-nya dimatikan. Sebuah fenomena yang aneh. Untuk sementara, konfigurasi dikembalikan kepada posisi semula, tanpa Mikrotik.

Mengubah Nama Packet Mark Downstream dari IIX

Misal akan mengubah nama Packet Mark untuk downstream dari IIX. Akan diganti Packet Mark "local-net-32" menjadi "32-iix-down". Untuk itu, jalankan aplikasi winbox.exe, lalu masuk ke menu IP -> Firewall -> Mangle -> pilih mark packet yang forward ke Dst Address yang diinginkan, dalam hal ini Dst Address ke 192.168.32.0/24 (Ada 2 mark packet, yaitu untu upstreamn dan downstream. Pilih salah satu Packet Mark untuk downstream yaitu "local-net-32") -> ganti "local-net-32" menjadi "32-iix-down" -> Apply -> OK

Sebenarnya saat melakukan perubahan Mangle Rule untuk 192.168.32.0/24, ada jendela baru yang muncul. Kira-kira menu yang ada pada jendela adalah sbb :

Packet Mark : Downstream IIX
Tab General :
Chain : forward
Dst Address : 192.168.32.0/24
Connection Mark : users-con
Tab Advanced :
Src. Address List : nice
Tab Action :
Action : mark packet
New Packet Mark : 32-iix-down (sebelumnya local-net-32)
Passthrough : enable (atau contreng)

Packet Mark : Upstream IIX
Tab General :
Chain : forward
Dst Address : 192.168.32.0/24
Connection Mark : users-con-up
Tab Advanced :
Src. Address List : nice
Tab Action :
Action : mark packet
New Packet Mark : 32-iix-up (sebelumnya local-net-up-32)
Passthrough : enable (atau contreng)

Packet Mark : Downstream Internasional
Tab General :
Chain : forward
Src Address : 192.168.32.0/24
Connection Mark : users-con
Tab Advanced :
Src. Address List : !nice
Tab Action :
Action : mark packet
New Packet Mark : 32-intl-down (sebelumnya inter-net-32)
Passthrough : enable (atau contreng)

Packet Mark : Upstream Internasional
Tab General :
Chain : forward
Src Address : 192.168.32.0/24
Connection Mark : users-con-up
Tab Advanced :
Src. Address List : !nice
Tab Action :
Action : mark packet
New Packet Mark : 32-intl-up (sebelumnya inter-net-up-32)
Passthrough : enable (atau contreng)

Jangan lupa untuk klik Apply dan OK setelah perubahan dianggap benar. Untuk mengubah nama Packet Mark lainnya, caranya hampir sama. Packet Mark lainnya yang perlu sisesuaikan adalah :
  1. Upstream IIX
  2. Downstream Internasional
  3. Upstream Internasional
Perhatikan,
  1. Kalau koneksi IIX menggunakan Dst Address, namun kalau koneksi Internasional menggunakan Src Address
  2. Kalau koneksi IIX, Src. Address List = nice, tapi kalau koneksi Internasional, Src. Address List = !nice. Tanda seru berarti tidak.
  3. Kalau downstream, connection mark-nya users-con, tapi kalau upstream, connection marks-nya users-con-up. Tidak peduli koneksi IIX atau Internasional.
  4. Sebenarnya isian New Packet Mark bebas. Namun disini hanya ingin melakukan standarisasi. 32 adalah kode subnet, iix atau intl adalah jenis koneksinya, up atau down jenis stream-nya.

Setelah proses di atas selesai, masuk ke menu Queue -> Queue Tree -> pilih queue yang diinginkan -> Ganti Packet Mark dari "local-net-32" ke "32-iix-down" (gunakan pull down menu.

Setting Mikrotik Lanjutan :
  1. Setting IP untuk masing-masing ethernet card, eth1 dan eth2 (seharusnya dilakukan sebelum setting mikrotik sebagai PPPoE)
  2. Menambahkan Routing
  3. Setting DNS
  4. Source NAT (Network Address Translation) / Masquerading.
  5. DHCP (DynamicHost Configuration Protocol)
  6. Bandwidth Control
  7. Graphing

Cara setting ini bisa juga dilihat di :
http://wikanwiratmoko.blogspot.com/
http://lutfi.stickycom.net/

Friday, January 15, 2010

Upgrade My Fedora 10 ke Fedora 11

Diharapkan dengan melakukan upgrade Distro, berbagai kendala yang ada di distro saat ini bisa teratasi. Pernah suatu kali modem GSM Bandlux c120, mouse internal (touchpad), VGA Card tidak dikenal oleh distro. Namun setelah melakukan upgrade total (bukan hanya update paket), berbagai device mampu dikenali secara baik dan benar. Dalam kesempatan ini saya akan utarakan cara upgrade dari Fedora 10 ke Fedora 11, step by step. Sebenarnya bisa saja upgrade langsung ke Fedora 12, namun saya belum tahu dampak kalau upgrade lompat 2 tingkat.

Untuk melakukan upgrade distro, hanya dibutuhkan 2 (dua) perintah baris saja, yaitu :
# yum -y install preupgrade
# preupgrade

Lihat juga :
Upgrade Fedora 9 ke Fedora 10

Thursday, January 14, 2010

Menjalankan PHP dari perintah baris

Karena alasan-alasan tertentu, saya perlu menjalankan skrip PHP dari perintah baris pada Terminal Fedora 11. Nantinya skrip PHP ini akan dijalankan secara periodik, katakan setiap 5 menit. Tentunya melalui bantuan crontab. Skrip PHP pada dasarnya sudah bisa dijalankan dari web browser. Namun output web browser tidak bisa disimpan dalam sebuah file ASCII atau TXT. Sementara saya maunya, outputnya bisa langsung disimpan (redirect output) ke dalam sebuah file text. Dan kalau bisa secara APPEND.

Contoh file atau skrip PHP yang telah dicoba. Nama filenya adalah online.php.

<?php // ---- online.php ----

session_start();
include "online.inc.php";

$waktu=date("H:i:s d-m-Y");

$sqlLimit="select distinct ou_user from onlineusers order by ou_user asc";
$dbconnect=mysql_query($sqlLimit);
$rec_num=mysql_num_rows($dbconnect);

echo "$waktu";

for($RekRows=0;$RekRows<$rec_num;$RekRows++){
$getval=mysql_fetch_array($dbconnect);

$_ou_timestamp=$getval[ou_timestamp];
$_ou_user=$getval[ou_user];
$_ou_right_main=$getval[ou_right_main];
$id=$getval[id];

echo "
$_ou_user";


}

echo "Total user: ";
echo "$rec_num";
echo "";

?>

Ketika dijalankan di terminal, dihasilkan keluaran sbb :

[root@serpong4] ~ # php -f online.php

khairul
mantho
sugi@batan.go.id
Total user: 3
[root@serpong4] ~ #
Jika ingin agar hasil perintah ini disimpan di suatu file, misal file online.out. Sehingga perintahnya menjadi :

[root@serpong4] ~ # php -f online.php >>
online.out
Jika ingin dijalankan sebagai perintah shell, maka isi file shell online.sh adalah :

#/bin/sh
php -f /home/msmunir/public_html/webmail/online.php >> /home/msmunir/public_html/webmail/online.out

Jika sudah dibuat file shell-nya, tinggal diletakkan di crontab.

Edit crontab di /etc/crontab :

#minute hour mday month wday who command
#
*/5 * * * * root /home/msmunir/public_html/webmail/online.sh
#

Restart Crontab :
[root@serpong4] /etc/rc.d # ./cron restart
Stopping cron.
Waiting for PIDS: 757.
Starting cron.
[root@serpong4] /etc/rc.d #

Ubah Owner (user root, group wheel) dan attribute (777) file online.sh, online.php dan online.out

[root@serpong4] /etc # chown root:wheel /home/msmunir/public_html/webmail/online.sh
[root@serpong4] /etc # chown root:wheel /home/msmunir/public_html/webmail/online.php
[root@serpong4] /etc # chown root:wheel /home/msmunir/public_html/webmail/online.out


Sumber :
http://php.net/http://www.rumahweb.com/

Monday, January 11, 2010

Melihat online user webmail di FreeBSD dengan sintak MySQL

Untuk melihat online user webmail dapat juga dilakukan melalui MySQL. Adapun caranya adalah sbb :

[root@serpong4] ~ # mysql -S /tmp/mysql.sock2 -u userdt -p userdt
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 317031 to server version: 5.0.27
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

mysql> select * from onlineusers order by ou_user;
+--------------+----------+---------------------+
| ou_timestamp | ou_user | ou_right_main |
+--------------+----------+---------------------+
| 1263201975 | imank | /src/right_main.php |
| 1263201931 | imank | /src/right_main.php |
| 1263202006 | imank | /src/right_main.php |
| 1263202001 | imank | /src/right_main.php |
| 1263201912 | imank | /src/right_main.php |
| 1263201855 | khairul | /src/right_main.php |
| 1263201734 | khairul | /src/right_main.php |
| 1263201850 | khairul | /src/right_main.php |
| 1263201880 | khairul | /src/right_main.php |
| 1263201824 | msmunir | /src/right_main.php |
| 1263201739 | msmunir | /src/right_main.php |
| 1263201788 | msmunir | /src/right_main.php |
| 1263201727 | msmunir | /src/right_main.php |
| 1263201766 | msmunir | /src/right_main.php |
| 1263201756 | nu_rohma | /src/right_main.php |
| 1263202133 | setia | /src/right_main.php |
| 1263201611 | setia | /src/right_main.php |
| 1263201595 | setia | /src/right_main.php |
| 1263202130 | suprikeu | /src/right_main.php |
| 1263202074 | suprikeu | /src/right_main.php |
| 1263202090 | syahril | /src/right_main.php |
| 1263201591 | vendewi | /src/right_main.php |
| 1263201696 | vendewi | /src/right_main.php |
| 1263201634 | vendewi | /src/right_main.php |
| 1263201537 | vendewi | /src/right_main.php |
| 1263201556 | vendewi | /src/right_main.php |
| 1263201575 | vendewi | /src/right_main.php |
| 1263201607 | vendewi | /src/right_main.php |
| 1263201666 | vendewi | /src/right_main.php |
| 1263201650 | vendewi | /src/right_main.php |
| 1263202118 | yundi | /src/right_main.php |
| 1263202076 | yundi | /src/right_main.php |
| 1263201613 | zack | /src/right_main.php |
+--------------+----------+---------------------+
33 rows in set (0.00 sec)

mysql>

atau

mysql> select distinct ou_user from onlineusers order by ou_user;
+----------------------------+
| ou_user |
+----------------------------+
| agussy |
| agustin@batan.go.id |
| anis_rohanda |
| antie-p |
| baaseng |
| chevist |
| darbeny |
| darwis |
| frida |
| gunbki |
| hadi-susilo |
| hrdyanti |
| husenzam |
| ian |
| iis |
| imank |
| irawan |
| junaidis |
| june_mellawati@batan.go.id |
| makhsun |
| maruli |
| maskur |
| ppgn |
| rakhmats |
| ramon84 |
| tsalyo |
| wardojo |
| yesti |
| yulendya |
| yulianti |
+----------------------------+
30 rows in set (0.00 sec)

mysql>

Mencari pengguna :
mysql> select * from table1 where field1 like '%string%' order by field1 asc;
Misal mau mencari user yang ada kata 'sis' nya :
mysql> select * from mailbox where username like '%sis%' order by username asc;


Melihat struktur tabel
mysql> desc table;

Misal mau melihat struktur tabel mailbox :
mysql> desc mailbox;
+-----------+------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------------------+-------+
| username | varchar(255) | NO | PRI | | |
| password | varchar(255) | NO | | | |
| name | varchar(255) | NO | | | |
| nip | varchar(10) | YES | | NULL | |
| nip_baru | varchar(25) | YES | | NULL | |
| satker_id | int(10) unsigned | YES | | NULL | |
| maildir | varchar(255) | NO | | | |
| quota | bigint(10) | NO | | 0 | |
| domain | varchar(255) | NO | | | |
| created | datetime | NO | | 0000-00-00 00:00:00 | |
| modified | datetime | NO | | 0000-00-00 00:00:00 | |
| active | tinyint(1) | NO | | 1 | |
+-----------+------------------+------+-----+---------------------+-------+
12 rows in set (0.00 sec)

mysql>


Melihat user yang tidak aktif :
mysql> select * from mailbox where active = 0 order by username asc;

Keluar :

mysql>\quit


Saturday, January 09, 2010

Tambah host di Nagios Core 3.2.0 pada Fedora 11

Untuk menambah obyek pengamatan atau host yang akan diamati oleh Nagios, hanya ada 3 file yang perlu diperhatikan. File tersebut adalah :
  1. /usr/local/nagios/etc/objects/localhost.cfg
  2. /usr/local/nagios/etc/objects/host.cfg
  3. /usr/local/nagios/etc/nagios.cfg
File host.cfg adalah file generic. File ini hanyalah hasil penyalinan belaka dari file localhost.cfg, kemudian dimodifikasi isinya. Misal, jika yang mau diamati server mail, maka nama file menjadi mail.cfg. Jika yang mau diamati server www, maka nama file menjadi www.cfg. Isi file host.cfg, mail.cfg atau www.cfg disesuaikan dengan kondisi masing-masing.

Jika file konfigurasi host sudah dibuat dan dimodifikasi, informasi nama host ini ditambahkan ke dalam file localhost.cfg pada bagian "Host Group Definition", khususnya di "members". Sebagian isi file localhost.cfg yg perlu diperhatikan :

define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members localhost,mail,www ; Comma separated list of hosts that belong to this group
}

Disamping itu file konfigurasi nagios.cfg juga harus dimodifikasi. Bagian yang dimodifikasi adalah "#Definitions for monitoring the local (linux) host". Tambahkan sebaris script pada file nagios.cfg. Sebaris script tersebut adalah sbb :

cfg_file=/usr/local/nagios/etc/objects/host.cfg

Setelah ketiga file konfigurasi dibuat/modifikasi, selanjutnya me-restart :
  1. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  2. service nagios restart
Beberapa hal yang perlu diperhatikan saat meng-edit file host.cfg :
  1. host_name ditulis tidak pakai domain lengkap. Misal, cukup tulis mail, tidak perlu mail.domain.go.id.
  2. notifications_enabled = 1, jika mau ada peringatan ketika service gagal berfungsi. Nilai defaultnya adalah 0.
  3. Owner dari file CFG, negios:negios, dan attributenya 755. Jika tidak seperti ini, saat menjalankan nagios akan muncul pesan kesalahan
  4. Pada semua file CFG, pastikan tidak ada "Host Group Definition". Kecuali pada file localhost.cfg saja.
  5. Service yang bisa diperiksa antara lain : SNMP, POP, IMAP, HTTP, PING, FTP, SSH, DHCP. Selengkapnya lihat di file commands.cfg.
Cek service yang berjalan pada port tertentu. Misal HTTP yang berjalan pada port 1280 :

define service{
use local-service ; Name of service template to use
host_name 66-serpong5
service_description HTTP
check_command check_tcp! 1280
notifications_enabled 1
}


Tambah orang yang mau dikirimi Alert :
  1. Edit /usr/local/nagios/etc/objects/contacts.cfg
  2. Edit pada "define contact" di bagian email
  3. Jalankan : # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  4. Restart Nagios : # service nagios restart
Menghilangkan host localhost dari layar monitor
  1. Edit /usr/local/nagios/etc/nagios.cfg
  2. Remark "#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg" lalu simpan file nagios.cfg ini
  3. Jalankan : # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  4. Restart Nagios : # service nagios restart
Menghilangkan salah satu service pada suatu host dari layar monitor karena sering memberikan false alarm :
  1. Edit /usr/local/nagios/etc/objects/host-nya.cfg
  2. Remark bagian yang dimonitor lalu simpan file
  3. Jalankan : # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  4. Restart Nagios : # service nagios restart
Catatan : Ganti host dengan file yang sesuai

Selamat mencoba

Nagios Quickstart Installation Guides on Fedora 11

Introduction
This guide is intended to provide you with simple instructions on how to install Nagios from source (code) on Fedora and have it monitoring your local machine inside of 20 minutes. No advanced installation options are discussed here - just the basics that will work for 95% of users who want to get started.

These instructions were written based on a standard Fedora Core 6 Linux distribution.

What You'll End Up With
If you follow these instructions, here's what you'll end up with:
  • Nagios and the plugins will be installed underneath /usr/local/nagios
  • Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.)
  • The Nagios web interface will be accessible at http://localhost/nagios/
Prerequisites
During portions of the installation you'll need to have root access to your machine. Make sure you've installed the following packages on your Fedora installation before continuing.
  • Apache
  • PHP
  • GCC compiler
  • GD development libraries
You can use yum to install these packages by running the following commands (as root):
# yum install httpd php
# yum install gcc glibc glibc-common
# yum install gd gd-devel

1) Create Account Information
Become the root user.
# su -l
Create a new nagios user account and give it a password.
# /usr/sbin/useradd -m nagios
# passwd nagios
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
# /usr/sbin/groupadd nagcmd
# /usr/sbin/usermod -a -G nagcmd nagios
# /usr/sbin/usermod -a -G nagcmd apache

2) Download Nagios and the Plugins
Create a directory for storing the downloads.
# mkdir ~/downloads
# cd ~/downloads
Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions). These directions were tested with Nagios 3.1.1 and Nagios Plugins 1.4.11.
# wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
# wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
atau
# wget -dc ftp://dl1.batan.go.id/array1/VOL1/source_linux/nagios-3.2.0.tar.gz
# wget -dc ftp://dl1.batan.go.id/array1/VOL1/source_linux/nagios-plugins-1.4.14.tar.gz

3) Compile and Install Nagios
Extract the Nagios source code tarball.
# cd ~/downloads
# tar xzf nagios-3.2.0.tar.gz
# cd nagios-3.2.0
Run the Nagios configure script, passing the name of the group you created earlier like so:
# ./configure --with-command-group=nagcmd
Compile the Nagios source code.
# make all
Install binaries, init script, sample config files and set permissions on the external command directory.
# make install
# make install-init
# make install-config
# make install-commandmode
Don't start Nagios yet - there's still more that needs to be done...

4) Customize Configuration
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.
# vi /usr/local/nagios/etc/objects/contacts.cfg
5) Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
# make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
# service httpd restart
Note: Consider implementing the ehanced CGI security measures described /nagios/docs/cgisecurity.html to ensure that your web authentication credentials are not compromised.

6) Compile and Install the Nagios Plugins

Extract the Nagios plugins source code tarball.
# cd ~/downloads
# tar xzf nagios-plugins-1.4.11.tar.gz
# cd nagios-plugins-1.4.11
Compile and install the plugins.
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

7) Start Nagios
Add Nagios to the list of system services and have it automatically start when the system boots.
# chkconfig --add nagios
# chkconfig nagios on
Verify the sample Nagios configuration files.
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
# service nagios start

8) Modify SELinux Settings
Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.
See if SELinux is in Enforcing mode.
# getenforce
Put SELinux into Permissive mode.
# setenforce 0
To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.
Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:
# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
For information on running the Nagios CGIs under Enforcing mode with a targeted policy, visit the Nagios Support Portal or Nagios Community Wiki.

9) Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

http://localhost/nagios/

Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.

10) Other Modifications

Make sure your machine's firewall rules are configured to allow access to the web server if you want to access the Nagios interface remotely.

Configuring email notifications is out of the scope of this documentation. While Nagios is currently configured to send you email notifications, your system may not yet have a mail program properly installed or configured. Refer to your system documentation, search the web, or look to the Nagios Support Portal or Nagios Community Wiki for specific instructions on configuring your system to send email messages to external addresses. More information on notifications can be found here.

11) You're Done

Congratulations! You sucessfully installed Nagios. Your journey into monitoring is just beginning. You'll no doubt want to monitor more than just your local machine, so check out the following docs...


Thursday, January 07, 2010

Logitech QuickCam E2500 di Fedora 11

Salah satu sumber informasi yang dapat saya gunakan untuk mengaktifkan webcam saya, adalah blog ini. Kalau di Windows, webcam ini dah langsung bisa dipakai, bahkan untuk ber-YM. Namun kalau untuk Pidgin, belum bisa. Sempat terlihat sebentar bila menggunakan aplikasi Cheese Webcam Booth, aplikasi yang sudah bundle dengan Fedora 11 pada kelompok Sound & Video.

Dalam blog tersebut dijelaskan bahwa untuk mengaktifkan QuickCam E2500 dibutuhkan driver v4l-dvb. Langkah-langkah instalasinya adalah sbb :

# yum install mercurial
# yum install gcc kernel-devel
# hg clone http://linuxtv.org/hg/v4l-dvb
# cd v4l-dvb && make && make install
# make load

Saat meng-compile, tampaknya ada masalah :
[root@localhost ~]# cd v4l-dvb && make && make install
make -C /root/v4l-dvb/v4l
make[1]: Entering directory `/root/v4l-dvb/v4l'
No version yet, using 2.6.30.10-105.fc11.i686.PAE
make[1]: Leaving directory `/root/v4l-dvb/v4l'
make[1]: Entering directory `/root/v4l-dvb/v4l'
scripts/make_makefile.pl
Updating/Creating .config
Preparing to compile for kernel version 2.6.30
File not found: /lib/modules/2.6.30.10-105.fc11.i686.PAE/build/.config at ./scripts/make_kconfig.pl line 32, line 4.
make[1]: Leaving directory `/root/v4l-dvb/v4l'
make[1]: Entering directory `/root/v4l-dvb/v4l'
Updating/Creating .config
Preparing to compile for kernel version 2.6.30
File not found: /lib/modules/2.6.30.10-105.fc11.i686.PAE/build/.config at ./scripts/make_kconfig.pl line 32, line 4.
make[1]: *** No rule to make target `.myconfig', needed by `config-compat.h'. Stop.
make[1]: Leaving directory `/root/v4l-dvb/v4l'
make: *** [all] Error 2
[root@localhost v4l-dvb]#


Pada 26 Maret 2010 saya melakukan pengetesan fungsi webcam Logitech QuickCam E2500, ternyata bisa berfungsi di Cheese dan GYachE. Untuk pengetesan gunakan perintah baris :
# tail -f /var/log/messages
Mar 26 05:38:24 localhost kernel: usb 5-1: new full speed USB device using uhci_hcd and address 4
Mar 26 05:38:24 localhost kernel: usb 5-1: New USB device found, idVendor=046d, idProduct=089d
Mar 26 05:38:24 localhost kernel: usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Mar 26 05:38:24 localhost kernel: usb 5-1: configuration #1 chosen from 1 choice
Mar 26 05:38:24 localhost kernel: gspca: probing 046d:089d
Mar 26 05:38:24 localhost kernel: zc3xx: Sensor MC501CB
Mar 26 05:38:24 localhost kernel: gspca: probe ok
Mar 26 05:38:24 localhost kernel: gspca: probing 046d:089d

# lsmod | grep gspca
gspca_zc3xx 44508 0
gspca_m5602 37532 0
gspca_main 19176 2 gspca_zc3xx,gspca_m5602
videodev 29636 1 gspca_main

Saya belum tahu persisnya, kenapa akhirnya bisa berfungsi. Padahal kalau dicek, modul gspca tidak ada. Lihat hasil pengecekan di bawah ini.
# modprobe -v gspca
WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.
FATAL: Module gspca not found.

Informasi yang saya ikuti ada di :
http://forums.quickcamteam.net/showthread.php?tid=310
http://www.actionshrimp.com/2008/08/logitech-quickcam-e2500-on-ubuntu-skype/


Tuesday, January 05, 2010

Cara Mengetahui Spesifikasi Komputer di Fedora

Untuk mengetahui spesifikasi komputer seperti CPU, RAM, HDD, Ethernet Card, VGA Card, dll bisa menggunakan perintah baris "lshw". Namun sayangnya perintah baris ini belum tersedia secara default. Untuk itu perlu di-instal terlebih dahulu.
#yum install lshw

Setelah selesai instalasi, tinggal menjalankannya. Jalankan perintah baris :
# lshw

Kira-kira tampilan pada layar monitor adalah sbb :
# lshw
nms.batan.go.id
description: Tower Computer
product: HP d330 uT(DC579AV)
vendor: Hewlett-Packard
serial: SGH4080B4F
width: 32 bits
capabilities: smbios-2.3 dmi-2.3 smp-1.4 smp
configuration: boot=normal chassis=tower cpus=1 uuid=5BC5119E-F369-D811-BBD8-7FF4731C000E
*-core
description: Motherboard
product: 085Ch
vendor: Hewlett-Packard
physical id: 0
serial: SGH4080B4F


Perintah baris terkait cek memori :
$ free -m
$ free -t -m
$ vmstat
$ top
# dmesg | grep -i memory
# cat /proc/meminfo | grep -i memory
# lshw | grep *-memory

Lihat juga di sysdigg.blogspot.com
Keyword Google : "cek memory di linux"

Mengetahui informasi ukuran RAM di FreeBSD

Download perl script yang ditulis oleh Ralf S. Engelschall:
# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free


Yakinkan bahwa perl anda sudah terinstalasi. Untuk melihat keseluruhan sistem memory yang digunakan, ketiklah :
$ free

Sumber : www.cyberciti.com

Untuk men-download paket lshw for Fedora 11, klik disini. atau langsung download di sini.

[root@localhost ~]# rpm -ivh lshw-B.02.14-1.fc11.i586.rpm
Preparing... ########################################### [100%]
1:lshw ########################################### [100%]
[root@localhost ~]#



Monday, January 04, 2010

Instruksi Kerja Setting dan Konfigurasi Personal Website di Fedora

Pada dasarnya setiap user bisa punya website sendiri. Biasanya disebut sebagai personal website. Personal website diletakkan di folder userid, atau jika nama anda amir, maka foldernya adalah /home/amir/public_html/. Sebaiknya attribute /home/amir adalah 711 dan attribute /home/amir/public_html/ adalah 755. File-file personal website akan disimpan di folder /home/amir/public_html/. Sebaiknya attribute file-file HTML dan PHP adalah 755. Jika attribute tidak di-set seperti ini, maka akan muncul pesan kesalahan "403 Forbidden".

Sebelum melanjutkan, maka asumsinya adalah semua langkah ini dilakukan pada server Fedora yang sudah diinstalasi web server Apache. Jika sudah ada Apache-nya namun belum jalan, silahkan jalankan dengan perintah :
# /etc/rc.d/init.d/httpd restart

Secara default, folder public_html belum ada di setiap user. Untuk itu buatlah terlebih dahulu folder tersebut sebagai tempat tampungan file-file yang berhubungan dengan personal website anda. Setelah itu ubah attributenya sesuai rekomendasi di atas.
# mkdir /home/amir/public_html
# chmod 711 /home/amir
# chmod 755 /home/amir/public_html

Jika ingin membuat agar seluruh folder dan file di bawah folder public_html memiliki atribute yang sama semua, katakan 755, perintah barisnya adalah sbb :
# chmod -R 755 /home/amir/public_html

Selanjutnya buat sebuah file index.html dan letakkan di folder /home/amir/public_html. Sebeanrnya file ini dibuat sekedar untuk menguji apakah personal website sudah berfungsi atau belum. Kira-kira isi file index.html sbb :
<html>
<head>
<title>test</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>

Edit file konfigurasi Apache di /etc/httpd/conf/httpd.conf. Bagian yang di-edit antara lain :
#UserDir disabled
UserDir public_html

Sebelumnya adalah :
UserDir disabled
#UserDir public_html

Setelah di-edit file httpd.cond, restart-lah httpd dengan cara :
# /etc/rc.d/init.d/httpd restart

Lakukan uji fungsi personal website dengan menggunakan web browser, lalu akses personal website dengan alamat : http://localhost/~amir/

Jika alamat personal website tidak ingin menggunakan tanda tilde (~), sehingga menjadi http://localhost/amir/, maka edit-lah file /etc/httpd/conf/httpd.conf dengan cara menambahkan baris sbb :

Alias /msmunir/ "/home/amir/public_html/"
<Directory "/home/amir/public_html">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Jalan lupa restart kembali httpd setelah usai mengedit.
# /etc/rc.d/init.d/httpd restart

Sekarang akses personal website dengan alamat : http://localhost/amir/

Perhatikan bahwa owner folder /home/amir/, /home/amir/public_html/ dan file-file yang ada di folder /home/amir/public_html/ haruslah user amir dan group amir. Jika tidak lakukan perubahan seperlunya, misal
# chown -R amir:amir /home/nusa

-R artinya hingga seluruh sub folder dan file yang ada di bawahnya.

Untuk membuat web yang berisi file semacam ftp server personal, saya tidak bisa mengandalkan folder /home/amir/public_html. Saya akhirnya membuat folder di /homel/amir/download/. Folder ini saya ubah owner-nya ke amir agar amir bisa menambah file ke folder ini. Selanjutnya membuat simbolik link untuk folder /home/amir/download/ ke /var/www/html.
# mkdir /home/amir/download
# cd /var/www/html/
# ln -s /home/amir/download/ /var/www/html/amir
Sekarang silahkan upload file ke /home/amir/download/ dengan FTP Client atau apapun. Untuk melihat file hasil upload silahkan gunakan web browser dengan alamat http://localhost/amir/