Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Friday, June 13, 2008

Membuat Gateway Flash Telkomsel di Ubuntu Linux

Dari pada pusing riset lagi dari awal, mendingan bikin dokumentasinya dan berbagi kemudahan ini ke orang banyak. Saya akan menjelaskan bagaimana membuat Ubuntu Linux kita menjadi server gateway internet dengan menggunakan Huawei modem dari Flash Telkomsel.

Cara ini berhasil di Ubuntu 8.04 karena paket wvdial yang dimilikinya mampu menkonfigurasi otomatis huawei modem. Untuk berbagi ke jaringan, pastikan koneksi komputer kita dengan komputer2 lainnya di LAN berjalan baik.

Deteksi Modem
  1. Pastikan pulsanya Telkomsel Flash ada
  2. Tancap kabel yang tengah (baca keterangan pada usb jack!). Karena ada 2 jack yang punya fungsi berbeda.
  3. Pastikan Ubuntu dapat mendeteksi modem pasca penancapan usb. Biasanya baru sempurna deteksinya setelah 1 menit. Cek dengan lsusb. Harusnya ada tulisan kira2 seperti ini:
Bus 005 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem


Konfigurasi dan dialing
  1. Lakukan konfigurasi otomatis "sudo wvdialconf". Perintah ini harusnya menghasilkan file /etc/wvdial.conf yang berisi kira2 seperti berikut ini. Pastikan bahwa hasil konfigurasi otomatis ini menghasilkan nilai "Username" dan "Password" seperti di bawah ini, yakni { }
    [Dialer Defaults]
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Modem Type = Analog Modem
    ISDN = 0
    New PPPD = yes
    Phone = *99#
    Modem = /dev/ttyUSB0
    Username = { }
    Password = { }
    Baud = 9600

  2. Lakukan dial dan biarkan jaringan Ubuntu dikonfigurasi oleh wvdial
    sudo wvdial

    Harusnya dalam waktu singkat wvdial akan mengeluarkan input akhir seperti ini:

    --> local IP address 221.132.252.149
    --> pppd: 3[7f]
    --> remote IP address 10.64.64.74
    --> pppd: 3[7f]
    --> primary DNS address 202.3.218.10
    --> pppd: 3[7f]
    --> secondary DNS address 202.3.240.10
    --> pppd: 3[7f]

    Selain itu akan tampak perubahan pada perintah "sudo route"

    10.64.64.74 * 255.255.255.255 UH 0 0 0 ppp0
    192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
    default * 0.0.0.0 U 0 0 0 ppp0

    dan bergantinya dns pada /etc/resolv.conf sebagai berikut

    nameserver 202.3.218.10
    nameserver 202.3.240.10


  3. Pastikan kita bisa browsing di Ubuntu kita.
    Buka browser kesayangan kita dan buka sebuah situs. Kita diharuskan mengisi login ke Flash Telkomsel. Buka halaman kedua yang digunakan untuk menjelajah internet. Jika kita berhasil membuka sebuah situs, berarti kita siap melangkah lebih jauh.


Menjadikan Ubuntu sebagai gateway untuk internet di LAN.
  1. Ganti gateway komputer2 satelit. Arahkan gateway komputer2 yang ada di LAN ke ip LAN milik Ubuntu. Jika Ubuntu kita memiliki ip jaringan lokal 192.168.1.45, maka pastikan gateway komputer2 yang akan ikutan pakai internet adalah 192.168.1.45 juga.
  2. Ganti DNS komputer2 satelit. Pastikan dns komputer2 tersebut diarahkan ke 2 dns yang dideteksi oleh wvdial di atas. Sehingga pada salah satu komputer2 satelit tersebut, perintah "sudo route" akan mengasilkan:

    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
    default 192.168.1.45 0.0.0.0 UG 100 0 0 eth0
  3. Izinkan akses langsung internet oleh komputer satelit
    Pada Ubuntu yang kini telah menjadi gateway, jalankan perintah berikut (sesuaikan nilai device output, apakah ppp0 atau ppp1 atau lainnya. Ini tergantung apa yang terlihat dari default gateway hasil perintah "sudo route")

    sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
    echo 1 > /proc/sys/net/ipv4/ip_forward


Semoga berhasil

Wednesday, April 23, 2008

Installing Clamav antivirus on Samba in Ubuntu

Many people use Samba in their file server to let Windows users share their files there. But some people just doesn't care if they have shared virus infected files. The other users merely become the victim.

So, lets arm our Samba to protect users from viruses hidden in the shared directories. In Ubuntu and other *nix distros, we can use free Clamav antivirus plugged in to Samba which is called clamav-scan. *nix distros usually provide ready-to-install binary of clamav-scan. But Ubuntu does not. So you must compile the plug in manually.

Enough for the intro, now we'll begin arming the Samba in Ubuntu (my Ubuntu version is 7.04 feisty fawn) . Don't be rush. You must follow test instruction before proceeding the next step.

1. Prepare package Clamav and supporting packages
apt-get install clamav arj unzoo lha clamav-freshclam clamav-daemon clamav-testfiles build-essential

You may also need build-essential package

Test: Please make sure that we can scan infected files.
clamscan -ir /usr/share/clamav-testfiles

We should see lines like the following:

----------- SCAN SUMMARY -----------
Known viruses: 266917
Engine version: 0.91.2
Scanned directories: 1
Scanned files: 7
Infected files: 6
Data scanned: 0.00 MB
Time: 3.762 sec (0 m 3 s)


2. Prepare packages to install clamav-scan into Samba
apt-get install dpkg-dev
apt-get source samba
apt-get build-dep samba
wget -c http://optusnet.dl.sourceforge.net/sourceforge/openantivirus/samba-vscan-0.3.6b.tar.bz2

3. Compiling
cd samba-3.0.24
./debian/rules configure-stamp
cd source
make proto
cd ../..

tar -jxvf samba-vscan-0.3.6b.tar.bz2 -C /usr/src
cd samba-vscan-0.3.6b
./configure --with-samba-source=/usr/src/samba-3.0.24/source
make && make install

Now the vscan-clamav module is ready to use

4. Configuring Samba to cooperate with vscan-clamav
mkdir /etc/samba/vfs-config
cp /usr/src/samba-vscan-0.3.6b/clamav/vscan-clamav.conf /etc/samba/vfs-config/

change some values in the /etc/../vfs-config/vscan-clamav.conf:
clamd socket name = /var/run/clamav/clamd.ctl
infected files action = quarantine
; By default, the quarantine directory is /tmp
; quarantine directory = /mnt/office-shared-files/.quarantine


Add some values in samba config file: /etc/samba/smb.conf. We may add this line under [global] configuration or specific directory configuration
vfs objects = vscan-clamav
vscan-clamav: config-file = /etc/samba/vfs-config/vscan-clamav.conf

5. We must recompile vscan-clamav if we upgrade our Samba. To lock Samba version from upgrading, we must do this:
echo samba hold | dpkg --set-selections
echo samba install | dpkg --set-selections

6. Now restart Samba
/etc/init.d/samba restart

7. See vscan-clamav in action
  • Just copy /usr/share/clamav-testfiles to shared writable directory of Samba so it can be accessed by Windows users. The files inside are harmless to Windows but make clamav assume them as infected files.
  • We can see that Samba has denied us from copying the file out. Instead we'll see the files has been moved to /tmp/var-*****.
  • Later, we can see that Samba users can not copy infected files into the shared directory of Samba.
I hope this tutorial useful to you!

References:
- http://www.howtoforge.com/forums/showthread.php?t=3706
- http://www.grape-info.com/doc/linux/config/samba-vscan-0.3.6b-84.html