Minggu, 27 April 2008

VNET2: TUN/TAP

TUN/TAP adalah salah satu sarana virtual network point to point antara Linux host dan UML.

Di sini kita akan coba sambung host Jawa dengan IP=10.0.1.254 dan UML merapi IP=10.0.1.1. Untuk melakukan hal ini login sebagai user biasa di host, jalankan GUI, dan luncurkan terminal.


* LUNCURKAN UML DENGAN TUN/TAP
Luncurkan UML merapi (COW) sebagai berikut

tux@jawa:$ linux ubd0=merapi.cow eth0=tuntap,,,10.0.1.254 &

## Lihat syntax-nya
## eth0 = nama device di dalam UML
## tuntap = jenis koneksi
## 10.0.1.254 = alamat IP host

* ATUR NETWORK UML
Setelah UML jalan, silahkan login sebagai root. Lalu kita bisa atur networking-nya pakai netconfig

## Cara Manual
root@uml:$ ifconfig eth0 10.0.1.1 netmask 255.255.255.0 up

## Cara permanen di Vector Linux/Slackware
root@uml:$ netconfig

## Ikuti saja menunya, isikan
## Name = merapi
## domain = vnet
## Tipe IP = static
## IP = 10.0.1.1
## Netmask = 255.255.255.0
## Gateway = 10.0.1.254
## DNS = 10.0.1.254 (host Jawa, kalau ada DNS-nya)

## Kalau sudah reboot, atau jalankan
root@uml:# /etc/rc.d/rc.inet1

## Periksa network
root@uml# ifconfig
eth0 Link encap:Ethernet HWaddr FE:FD:0A:00:01:01
inet addr:10.0.1.1 Bcast:10.0.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:5

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:252 (252.0 b) TX bytes:252 (252.0 b)

Nah terlihat kalau network eth0 sudah UP.

* PERIKSA NETWORK HOST
Setelah UML jalan, luncurkan terminal lain untuk periksa apakah network host sudah siap sbb.

## jadi superuser
tux@jawa:$ su
password: ******

root@jawa:# ifconfig
eth0 Link encap:Ethernet HWaddr 00:20:ED:77:A5:B1
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:23515 (22.9 Kb)
Interrupt:11 Base address:0xc000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

tap0 Link encap:Ethernet HWaddr 00:FF:5E:F3:51:5B
inet addr:10.0.1.254 Bcast:10.255.255.255 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Terlihat bahwa host punya device tap0 yang sudah UP dengan IP 10.0.1.254. Semantara itu terlihat juga bahwa host punya eth0. Itu device betulan yang terhubung ke network betulan (kantor). Abaikan saja eth0 ini.

* TESTING DARI UML
Coba ...

## Test ping
root@merapi:# ping -c 3 10.0.1.1
PING 10.0.1.254 (10.0.1.254): 56 octets data
64 octets from 10.0.1.254: icmp_seq=0 ttl=64 time=0.3 ms
64 octets from 10.0.1.254: icmp_seq=1 ttl=64 time=0.3 ms
64 octets from 10.0.1.254: icmp_seq=2 ttl=64 time=0.3 ms

--- 10.0.1.254 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.3/0.3/0.3 ms

## Nah, ping OK, berarti network sudah terhubung
## Test remote login dari UML ke host
root@merapi:# ssh tux@10.0.1.254
The authenticity of host '10.0.1.254 (10.0.1.254)' can't be established.
RSA key fingerprint is ec:80:09:da:90:da:a9:08:14:33:b6:d6:54:10:3d:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.1.254' (RSA) to the list of known hosts.
tux@10.0.1.254's password:
Linux 2.4.24-win4lin. Type vasm to enter setup menu.
tux@jawa:$

## Yohoo ... kita sudah di host Jawa
## Respond SSH tadi normal jika ini koneksi pertama
## Nanti koneksi selanjutnya tidak akan ditanya soal RSA lagi

Buat yang belum tahu, ssh itu client untuk login remote ke host unix (Linux, FreeBSD, MacOS, dll). Ini gantinya telnet yang lebih secure.

* SEBALIKNYA DARI HOST
Coba ...

tux@jawa:$ ping -c 3 10.0.1.1
PING 10.0.1.1 (10.0.1.1): 56 octets data
64 octets from 10.0.1.1: icmp_seq=0 ttl=64 time=0.2 ms
64 octets from 10.0.1.1: icmp_seq=1 ttl=64 time=0.2 ms
64 octets from 10.0.1.1: icmp_seq=2 ttl=64 time=0.2 ms

--- 10.0.1.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.2/0.2/0.2 ms

## Koneksi OK
## sekarang coba remote login
tux@jawa:$ ssh root@10.0.1.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
ec:80:09:da:90:da:a9:08:14:33:b6:d6:54:10:3d:03.
Please contact your system administrator.
Add correct host key in /home/tux/.ssh/known_hosts to get rid of this message.
Offending key in /home/tux/.ssh/known_hosts:5
RSA host key for 10.0.1.1 has changed and you have requested strict checking.
Host key verification failed.

Lhadalah ... ada apa itu ? Tenang, itu respond yang normal dari SSH kalau 10.0.1.1 ganti mesin. Kalau kita main-main UML, itu kejadian lumrah. Mari kita betulkan ...

## Periksa isi $HOME/.ssh/known_hosts
tux@jawa:$ cat ~/.ssh/known_hosts
localhost ssh-rsa AAAAB3NzaC1yc2EAAAABIw... (dipotong)
papua.vnet,10.0.0.5 ssh-rsa AAAAB3NzaC1y... (dipotong)
10.0.1.1 ssh-rsa AAAAB3NzaC1yc2EAAAABIwA... (dipotong)

## Nah terlihat kalau 10.0.1.1 ini sudah punya entry lama.
## Hapus saja baris 10.0.1.1 itu pakai editor
## atau cara hacker ...
tux@jawa:$ grep -v 10.0.1.1 ~/.ssh/known_hosts | cat > ~/.ssh/known_host

## atau cara kasar :)
tux@jawa:$ rm ~/.ssh/known_hosts

## Coba SSH lagi
tux@jawa:$ ssh root@10.0.1.1
The authenticity of host '10.0.1.1 (10.0.1.1)' can't be established.
RSA key fingerprint is ec:80:09:da:90:da:a9:08:14:33:b6:d6:54:10:3d:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.1.1' (RSA) to the list of known hosts.
root@10.0.1.1's password: *****
Linux 2.4.22. Type vasm to enter setup menu.
root@merapi:#

## Silahkan main-main di konsole
## Kalau sudah puas, logout
root@merapi:# exit
logout
Connection to 10.0.1.1 closed.
tux@jawa#

Selesai sudah. Network TUN/TAP kita sudah beres. Anda bisa coba sendiri berbagai client dari Merapi untuk akses server di Jawa (kalau jalan), misalnya:

1. dig atau nslookup, kalau di host Jawa ada DNS (bind).
2. lynx untuk akses HTTP (apache)
3. ftp untuk akses FTP server (ProFTP).
4. smbclient untuk akses SAMBA (smnd, nmbd).

Selengkapnya..

Linux for Windows

Bisa bayangin nggak main Linux di Windows ? Jadi anda bisa pakai aplikasi-aplikasi for Windows yang katanya user friendly, sementara ada virtual Linux buat test server.
Kalau tertarik, saya perkenalkan ... CoLinux !!!.


CoLinux adalah paket yang memungkinkan anda menjalankan Linux kernel di ataw Windows. Pendekatannya berbeda dengan VmWare. Lebih mirip seperti User Mode Linux menjalankan Linux di atas Linux, atau sebaliknya Win4Lin menjalankan Windows di atas Linux. Buat menjalankan CoLinux, anda perlu:

1. Windows 2000 atau Windows XP
2. Paket CoLinux (EXE file), download dari sourceforge http://sourceforge.net/project/showfiles.php?group_id=98788
3. Rootfs, download dari tempat yang sama. Silahkan pilih salah satu antara gentoo, debian dan Fedora. Kalau mau Slackware atau Vector Linux harus oprek sendiri. http://sourceforge.net/mailarchive/forum.php?thread_id=3808305&forum_id=37489

Terus buat petunjuk pasang dan pakainya anda bisa mulai dari colinux FAQ. Selamat mencoba dan kalau bisa bagi-bagi pengalamannya ya. Saya sendiri belum coba soalnya tidak punya Windows XP/2000.

Selengkapnya..

DHCP Server Pakai DNSMasq

DHCP server adalah layanan yang memberikan alamat IP otomatis kepada komputer-komputer client pada suatu LAN. Layanan DHCP ini kini makin penting dengan makin maraknya jaringan wireless. Untungnya, hal ini mudah disetup pakai dnsmasq.

Bayangkan kita punya sebuah LAN dengan banyak komputer. Setiap komputer tentunya perlu alamat IP yang unik. Dengan cara manual, kita harus berikan alamat IP ini secara statik ke masing-masing komputer. kalau komputernya ada 100 atau lebih, pegel juga kan ;-)

Nah di sinilah perlunya DHCP (Dynamic Host Control Protocol). Secara umum, konfigurasi DHCP adalah sebagai berikut:


[dhcp server]--------{LAN}--------[client (banyak sekali)]


Cara kerja sistem ini adalah:

1. pada suatu LAN, cukup ada SATU DHCP server. DHCP server ini diset untuk membagikan alamat IP dengan rentang tertentu, misal 192.168.0.100 - 192.168.0.199.
2. Ada banyak komputer client. Setiap komputer diset agar TCP/IP nya memakai mode AUTO.
3. Saat komputer client dihidupkan, dia akan menyebarkan permintaan alamat IP.
4. Si DHCP server akan menangkap permintaan ini, lalu memberikan nomor IP unik dalam rentang yang telah ditentukan. Bersamaan dengan itu, juga dapat diberikan informasi lain seperti netmask, alamat dns server, maupun gateway.
5. Si client bisa men-set TCP/IP-nya sesuai informasi yang diberikan dan mulai bekerja.
6. Alamat IP ini hanya pinjaman. Setelah selang waktu yang ditentukan, DHCP server akan menagihnya kembali agar dapat dipinjamkan ke client lain. Jadi si client harus memperbaharui pinjamannya (leasing) secara berkala.

Sementara itu ada hal tak kalah penting yang harus dilakukan. Saat DHCP server meminjamkan nomor IP, nama domain yang bersangkutan harus disinkronkan agar akses ke nama domain tak salah alamat. Jelas bahwa hal ini erat kaitannya dengan DNS server. Karena DNSMASQ adalah sekaligus dns server, hal ini akan otomatis terjadi. Tidak demikian halnya jika kita memakai paket terpisah, misalnya bind + dhcpd.

DHCP SERVER SEDERHANA

Kini mari kita coba setup dnsmasq untuk konfigurasi sebagai berikut

[client]---{LAN}---[gateway (dnsmasq)]---{INTERNET}----[provider (dns server)]


Dalam hal ini, dnsmasq bertindak sebagai dhcp server sekaligus dns server. Misalkan saja LAN ini memiliki data sebagai berikut:

* Nomor IP : 192.168.0.1 - 192.168.0.254
* Netmask : 255.255.255.0
* Gateway : 192.168.0.254
* DNS server : 192.168.0.254

Kemudian alamat IP yang tersedia kita alokasikan sebagai berikut:

* Untuk client dengan IP statik : 192.168.0.1 - 192.168.0.127
* Untuk client dengan IP dinamik : 192.168.0.128 - 192.168.0.191
* Untuk server eksternal : 192.168.0.192 - 192.168.0.223
* Untuk server internal : 192.168.0.224 - 192.168.0.254

Oh ya, sekedar tips. Pembagian tersebut diatur demikian rupa menurut rentang kepangkatan angka binari (128 + 64 + 64) sehingga nantinya enak kalau kita pasang firewall.

Nah, kini kita bisa mulai mengkonfigurasi dnsmasq:

1. Konfigurasi dnsmasq sebagai dnsserver (lihat artikel sebelumnya).
2. Untuk mengaktifkannya sebagai dhcp server, astaga, ternyata mudah sekali. Cukup edit /etc/dnsmasq.conf pada bagian-bagian berikut:

# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
# as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
# domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
domain=kampus.lan

# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
dhcp-range=192.168.0.128,192.168.0.191,12h

# Send options to hosts which ask for a DHCP lease.
# See RFC 2132 for details of available options.
# Note that all the common settings, such as netmask and
# broadcast address, DNS server and default route, are given
# sane defaults by dnsmasq. You very likely will not need any
# any dhcp-options. If you use Windows clients and Samba, there
# are some options which are recommended, they are detailed at the
# end of this section.
# For reference, the common options are:
# subnet mask - 1
# default router - 3
# DNS server - 6
# broadcast address - 28
dhcp-option=1,255.255.255.0
dhcp-option=3,192.168.0.254
dhcp-option=6,192.168.0.254
dhcp-option=28,192.168.0.255

# The DHCP server needs somewhere on disk to keep its lease database.
# This defaults to a sane location, but if you want to change it, use
# the line below.
dhcp-leasefile=/var/run/dnsmasq/dnsmasq.leases


3. Jangan lupa menyediakan tempat untuk lease file

# mkdir -p /var/run/dnsmasq
# touch /var/run/dnsmasq/dnsmasq.leases

Silahkan start atau restart dnsmasq. Kini tinggal set client (Linux maupun Windows) agar memakai IP dinamik (auto). Jika semuanya berjalan benar, maka saat diaktifkan client akan mendapat salah satu alamat IP antara 192.168.0.128 s/d 192.168.0.191, demikian pula setting netmask, gateway dan dns server yang sesuai.

DHCP SERVER LEBIH JAUH

Ada beberapa setting di dnsmasq.conf untuk fitur-fitur lebih kompleks, misalkan saja:

* Atur agar client dengan nama domain tertentu selalu mendapat IP khusus

# Give the machine which says it's name is "dosen01" IP address
# 192.168.0.130 and an infinite lease
dhcp-host=dosen01,192.168.0.130,infinite

Agar hal ini bisa bekerja, pastikan tiap client memiliki nama yang benar. Di Linux, set /etc/HOSTNAME. Sementara itu di Windows, isikan nama domain pada setting TCP/IP.
* Atur agar client tertentu mendapat IP yang sesuai dengan nama domain di /etc/hosts

# Enable the address given for "lab01" in /etc/hosts
# to be given to a machine presenting the name "lab01" when
# it asks for a DHCP lease.
dhcp-host=lab01

Hal ini memungkinkan sinkronisasi otomatis dengan dns server.
* Atur agar client dengan MAC address tertentu selalu mendapat IP khusus

# Always allocate the host with ethernet address 11:22:33:44:55:66
# The IP address 192.168.0.129
dhcp-host=11:22:33:44:55:66,192.168.0.129

Untuk yang satu ini, anda perlu mendata semua MAC address client. Untuk mengetahui MAC address sebuah Linux client, panggil saja ifconfig. Sementara di Windows client gunakan ipconfig.
* Blok komputer yang anda tahu suka nakal

# Never offer DHCP service to a machine whose ethernet
# address is 11:22:33:44:55:66
dhcp-host=11:22:33:44:55:66,ignore

Sekian dulu soal dnsmasq. Silahkan coba, ditanggung beres dalam 30 menit tanpa pusing teori DNS+DHCP yang biasanya harus dibaca dulu kalau mau setting BIND atau DHCPD :)

Selengkapnya..

Bandwith Manajemen Queue Tree Vs Simple Queue di Mikrotik

Bagi anda yang akan menjadikan mikrotik sebagai bandwith management mungkin merasa sedikit bimbang, karna mikrotik menyediakan dua buah fitur limiter bandwith di dalamnya, yaitu Simple Queue dan Queue Tree.

Mikrotik yang memang mempunyai keunggulan sebagai bandwith management ini tentu telah merancang keduanya dengan baik sehingga kita tidak kecolongan oleh user yang rakus bandwith atau saya menyebutnya dengan Pardon ( Partai Download), karna berapa bandwith maximal yang kita setting ke user maka memang hanya itulah bandwith yang mereka dapatkan so bandwith yang ada dapat kita bagi dengan dengan adil ke semua user, hanya saja memang keduanya mempunyai kelebihan dan kekurangan masing-masing. Simple Queue sesuai dengan namanya juga cukup simple dalam meng-configurasinya, namun di Simple Queue kita tidak bisa meng alokasikan bandwith kusus buat icmp sehingga apabila pemakaian bandwith di client sudah full ping time nya akan naik dan bahkan rto ( request time out), Berbeda halnya dengan di Que tree, untuk men-seting nya kita membutuhkan sedikit konsentrasi karna lumayan rumit bagi pemula atau kita yang baru belajar mikrotik, Namun di Que tree kita bisa meng alokasikan bandwit icmp , sehingga walaupun bandwith di client full ping time nya pun masih stabil, Saya akan memberikan contoh konfigurasi Simple queues dan Que tree mudah mudahan bisa menjadi referensi untuk anda yang akan menggunakan limiter bandwith with mikrotik.

Configurasi Simple Queue:

Anda bisa membuat kelompok (parent) untuk client-kusus dengan bandwith 256kbps yang didalamnya terdiri dari 3 user sehingga bandwith 256 tadi akan di share untuk 3 user tesebut, dan parent2 yang lainpun bisa anda buat sesuai keinginan anda.

[nanang@Mikrotik] queue> simple
[nanang@Mikrotik] queue simple

add name=”WARNET” target-addresses=192.168.0.0/24 dst-address=0.0.0.0/0 interface=all parent=none direction=both \
priority=8 queue=default-small/default-small limit-at=0/0 max-limit=1000000/1000000 total-queue=default-small \
disabled=no
add name=”USER” target-addresses=192.168.0.2/32,192.168.0.3/32,192.168.0.4/32,192.168.0.5/32,192.168.0.6/32,192.168.0.7/32\
,192.168.0.8/32,192.168.0.9/32,192.168.0.10/32 dst-address=0.0.0.0/0 interface=all parent=WARNET direction=both \
priority=8 queue=default-small/default-small limit-at=0/0 max-limit=384000/384000 total-queue=default-small \
disabled=no
add name=”Client-1″ target-addresses=192.168.0.2/32 dst-address=0.0.0.0/0 interface=Lan parent=USER direction=both \
priority=8 queue=default-small/default-small limit-at=16000/16000 max-limit=32000/64000 total-queue=default-small \
disabled=no

Contoh configurasi Queue Tree:

Mangle

Sebelum kita Meng konfigure Queue Tree kita buat dulu Connection-mark di table mangle.

[nanang@Mikrotik] > ip firewall mangle
[nanang@Mikrotik] ip firewall mangle>

add chain=forward src-address=192.168.10.0/24 action=mark-connection new-connection-mark=lokal passthrough=yes comment=”" \
disabled=no
add chain=forward dst-address=192.168.10.0/24 action=mark-connection new-connection-mark=lokal passthrough=yes comment=”" \
disabled=no
add chain=forward protocol=icmp connection-mark=lokal action=mark-packet new-packet-mark=lokal-icmp passthrough=no \
comment=”" disabled=no
add chain=forward src-address=192.168.10.1 protocol=!icmp connection-mark=lokal action=mark-packet \
new-packet-mark=lokal-1 passthrough=no comment=”" disabled=no
add chain=forward dst-address=192.168.10.1 protocol=!icmp connection-mark=lokal action=mark-packet \
new-packet-mark=lokal-1 passthrough=no comment=”" disabled=no
add chain=forward src-address=192.168.10.2 protocol=!icmp connection-mark=lokal action=mark-packet \
new-packet-mark=lokal-2 passthrough=no comment=”" disabled=no
add chain=forward dst-address=192.168.10.2 protocol=!icmp connection-mark=lokal action=mark-packet \
new-packet-mark=lokal-2 passthrough=no comment=”" disabled=no

Queue-tree:

[nanang@LimiTer] queue> tree

[nanang@LimiTer] queue tree>
add name=”upload” parent=ether1 packet-mark=”" limit-at=0 queue=default priority=1 max-limit=256000 burst-limit=0 \
burst-threshold=0 burst-time=0s disabled=no
add name=”icmd-upload” parent=upload packet-mark=lokal-icmp limit-at=0 queue=default priority=3 max-limit=32000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
add name=”lokal-1-upload” parent=upload packet-mark=lokal-1 limit-at=0 queue=default priority=5 max-limit=64000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
add name=”lokal-2-upload” parent=upload packet-mark=lokal-2 limit-at=0 queue=default priority=5 max-limit=64000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
add name=”download” parent=global-out packet-mark=”" limit-at=0 queue=default priority=1 max-limit=512000 burst-limit=0 \
burst-threshold=0 burst-time=0s disabled=no
add name=”icmp-download” parent=download packet-mark=lokal-icmp limit-at=0 queue=default priority=3 max-limit=64000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
add name=”lokal-1-download” parent=download packet-mark=lokal-1 limit-at=0 queue=default priority=5 max-limit=128000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
add name=”lokal-2-download” parent=download packet-mark=lokal-2 limit-at=0 queue=default priority=5 max-limit=128000 \
burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

Note : Disini anda bisa membuat alokasi bandwith kusus buat icmp download dan upload.

Selengkapnya..

Minggu, 20 April 2008

Setting Modem 3G di Linux

Langkah-langkah konfigurasi 3G modem Huawei E220 pada Linux

Cek keberadaan modem menggunakan perintah dmesg

3daya@3daya:~> dmesg | grep usb

usb 1-2: new full speed USB device using uhci_hcd and address 2
usb 1-2: new device found, idVendor=12d1, idProduct=1003
usb 1-2: new device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-2: Product: HUAWEI Mobile
usb 1-2: Manufacturer: HUAWEI Technologies

usb 1-2: configuration #1 chosen from 1 choice
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usbcore: registered new driver usb-storage
usb-storage: device scan complete
tabel 1. dmesg

Ketika kita grep, modem kita dikenali sebagai :
HUAWEI Mobile
idVendor=12d1
idProduct=1003

pada opensuse10.2, menggunakan kernel 2.6.18, dimana pada kernel ini, modem juga dianggap sebagai usb-storage. Karenanya, perlu sedikit modifikasi pada bagian kernel (hacking kernel ….) ^_^

Dengan menggunakan root, edit file /etc/modprobe.conf.local Pada informasi di atas kita telah mendapatkan informasi vendor dan product. Kedua informasi ini kita butuhkan untuk konfigurasi lebih lanjut.

3daya@3daya:~> su -
Password:
3daya:~ #

3daya:~ # vi /etc/modprobe.conf.local

#
# please add local extensions to this file
#
#add by 3daya
options usbserial vendor=0×12d1 product=0×1003
options usb_storage delay_use=0
tabel 2. /etc/modprobe.conf.local

Langkah selanjutnya menambahkan parameter usbserial pada kernel

3daya:~ # vi /etc/sysconfig/kernel

#add by 3daya
MODULES_LOADED_ON_BOOT=”usbserial”
tabel 3. Kernel akan meload modul ubserial

Agar tidak perlu restart, langkah selanjutnya adalah memanggil modul usbserial

3daya:~ # modprobe usbserial
3daya:~ #

Selanjutnya, download file huaweiAktBbo-i386.out di
http://www.kanoistika.sk/bobovsky/archiv/umts/


Kemudian, ubah menjadi executable files, lalu copikan file tersebut ke dalam direktory /bin

3daya:~ # chmod +x /media/e/tools/linux\ util/modem3g/huaweiAktBbo-i386.out
3daya:~ # cp /media/e/tools/linux\ util/modem3g/huaweiAktBbo-i386.out /bin

Jalankan huaweiAktBbo-i386.out

3daya:~ # huaweiAktBbo-i386.out
Hladam HUAWEI E220 a prepnem na modem - bbo 06
4 set feature request returned 0
Prepnute-OK, Mas ttyUSB0 ttyUSB1 (cez usbserial vendor=0×12d1 product=0×1003)
pozri /proc/bus/usb/devices

Langkah selanjutnya adalah menggunakan tool wvial,namun sebelumnya, ada 2 paket yang perlu kita install terlebih dulu, yaitu huawei, dan huawei stat.
Download paketnya di :
http://oozie.fm.interia.pl/src/huawei.tar.bz2
http://oozie.fm.interia.pl/src/he220stat.tar.bz2

setelah di download lakukan kompilasi, berikut langkah-langkahnya:

3daya:~ # tar -xvjf /media/e/tools/linux\ util/modem3g/huawei.tar.bz2
huawei/
huawei/conf/
huawei/conf/huawei-e220
huawei/conf/wvdial-huawei.conf
huawei/conf/huawei-e220.chat
huawei/Makefile
huawei/files/
huawei/files/huawei-mobile.sh
huawei/files/99-huawei.rules
huawei/PROVIDERS
huawei/README
huawei/VERSION
3daya:~ #
3daya:~ # cd huawei/
3daya:~/huawei #
3daya:~/huawei # make install_suse
Installing sample configuration for Linux

cp conf/wvdial-huawei.conf /etc/
mkdir -p /etc/chatscripts/
cp conf/huawei-e220.chat /etc/chatscripts/
cp conf/huawei-e220 /etc/ppp/peers/
cp files/99-huawei.rules /etc/udev/rules.d/
cp files/huawei-mobile.sh /lib/udev/
udevcontrol reload_rules

Go ahead and replug your HUAWEI modem.

3daya:~/huawei #

Setelah huawei terinstall, kita akan menginstall paket statistik huawei,

3daya:~ # tar -xvjf /media/e/tools/linux\ util/modem3g/he220stat.tar.bz2
he220stat-0×02/
he220stat-0×02/flowreport.c
he220stat-0×02/init_ncurses.c
he220stat-0×02/modechange.c
he220stat-0×02/LICENSE
he220stat-0×02/rssi.c
he220stat-0×02/he220ui.h
he220stat-0×02/xhe220stat
he220stat-0×02/Makefile.in
he220stat-0×02/CHANGELOG
he220stat-0×02/configure
he220stat-0×02/README
he220stat-0×02/main.c
3daya:~ #
3daya:~ # cd he220stat-0×02/
3daya:~/he220stat-0×02 #
Lakukan kompilasi, pastikan C Compiler, serta ncurse-developer telah ada di opensuse10.2 kita

3daya:~/he220stat-0×02 # rpm -qa | grep gcc
gcc41-gij-4.1.2_20061115-7
gcc41-c++-4.1.2_20061115-5
gcc-c++-4.1.3-29
libgcc41-4.1.2_20061115-5
gcc-gij-4.1.3-29
gcc-info-4.1.3-29
gcc41-4.1.2_20061115-5
gcc41-info-4.1.2_20061115-5
gcc-4.1.3-29
gcc41-java-4.1.2_20061115-5
gcc-java-4.1.3-29

3daya:~/he220stat-0×02 # rpm -qa | grep ncurse
ncurses-5.5-42
ncurses-devel-5.5-42
yast2-ncurses-2.14.4-3
3daya:~/he220stat-0×02 #

3daya:~/he220stat-0×02 #
3daya:~/he220stat-0×02 # ./configure
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking how to run the C preprocessor… gcc -E
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking fcntl.h usability… yes
checking fcntl.h presence… yes
checking for fcntl.h… yes
checking for stdlib.h… (cached) yes
checking for string.h… (cached) yes
checking termios.h usability… yes
checking termios.h presence… yes
checking for termios.h… yes
checking for unistd.h… (cached) yes
checking for stdlib.h… (cached) yes
checking for GNU libc compatible malloc… yes
configure: creating ./config.status
config.status: creating Makefile
3daya:~/he220stat-0×02 #

3daya:~/he220stat-0×02 # make
gcc -Wall -lncurses init_ncurses.c main.c flowreport.c rssi.c modechange.c -o he220stat
3daya:~/he220stat-0×02 #

3daya:~/he220stat-0×02 # make install
chmod +x ./xhe220stat
cp *he220stat /usr/local/bin
3daya:~/he220stat-0×02 #

Done, sampai di sini, ritual instalasi sudah selesai. tahap selanjutnya adalah mengkonfigurasi wvdial. edit file sesuai dengan kebutuhan kita

3daya:~/he220stat-0×02 # vi /etc/wvdial-huawei.conf

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 3600000
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Init3 =
Area Code =
Phone = *99#
Username = 3daya
Password = ***
Ask Password = 0
Dial Command = ATDT
Stupid Mode = 1
Compuserve = 0
Force Address =
Idle Seconds = 0
DialMessage1 =
DialMessage2 =
ISDN = 0
Auto DNS = 1

l Sekarang, tiba saat yang ditunggu-tunggu, yaitu menjalankan modem 3G kita, jika semuanya berjalan normal, maka muncul baris berikut :

3daya:~/he220stat-0×02 # wvdial –config /etc/wvdial-huawei.conf
–> WvDial: Internet dialer version 1.54.0
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
ATZ
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
–> Modem initialized.
–> Sending: ATDT*99#
–> Waiting for carrier.
ATDT*99#
CONNECT
–> Carrier detected. Starting PPP immediately.
–> Starting pppd at Thu Jul 12 23:04:14 2007
–> pid of pppd: 12531
–> Using interface ppp0
–> local IP address 124.81.146.153
–> remote IP address 10.64.64.64
–> primary DNS address 202.155.0.10
–> secondary DNS address 202.155.0.15
–> Script /etc/ppp/ip-up run successful
–> Default route Ok.
–> Nameserver (DNS) Ok.
–> Connected… Press Ctrl-C to disconnect

Cek, apakah kita sudah mendapatkan ip

3daya@3daya:~> /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:F5:54:23:CC
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:169 Base address:0×2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2608 (2.5 Kb) TX bytes:2608 (2.5 Kb)

ppp0 Link encap:Point-to-Point Protocol
inet addr:124.81.146.153 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:11 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:540 (540.0 b) TX bytes:272 (272.0 b)

3daya@3daya:~>

tampak, kita telah mendapatkan ip dari provider Indosatm2, melalui protokol PPP, yaitu 124.81.146.153

Selanjutnya, kita coba menggunakan browser
Keterangan:
pada saat melakukan tes, lampu 3g Modem berwarna seperti ini :

tempat melakukan tes kamar kos, di daerah kebagusan 1 Jaksel (^_^)
OS yang digunakan adalah :

3daya:~/he220stat-0×02 # uname -a
Linux 3daya 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 i686 i386 GNU/Linux
3daya:~/he220stat-0×02 #
OPENSUSE10.2

Kesimpulan
3G modem huawei dapat dijalankan dengan linux opensuse10.2

Untuk melihat statistik 3g modem kita, jalankan perintah
#he220stato

Tutorial ini juga dapat digunakan pada distro linux yang lain. Saya telah mencoba menginstallnya di fedora.
Karena koneksi menggunakan provider indosatm2, maka sebaiknya dns servernya di set ke
202.155.0.10 dan 202.155.0.15, serta parameter Auto DNS = 1 pada /etc/wvdial-huawei.conf di set menjadi
Auto DNS = 0

Selengkapnya..