Jumat, 18 April 2008

Setting Hotspot Menggunakan Mikrotik

/ radius
add service=hotspot called-id="" domain="Radius" address=192.168.1.3 \
secret="123456" authentication-port=1812 accounting-port=1813 \
timeout=900ms accounting-backup=no realm="" comment="" disabled=no
/ radius incoming
set accept=yes port=1700

/ ip hotspot
add name="Hotspot2" interface=Lokal address-pool=hs-pool-1 profile=hsprof2 idle-timeout=none keepalive-timeout=none disabled=no

/ ip hotspot profile
add name="hsprof2" hotspot-address=192.168.1.3 dns-name="hotlink.net" \
html-directory=hotspot rate-limit="" http-proxy=192.168.1.3:3128 \
smtp-server=0.0.0.0 login-by=http-chap split-user-domain=no use-radius=yes \
radius-accounting=yes radius-interim-update=5s nas-port-type=0 \
radius-default-domain="Radius" radius-location-id="" \
radius-location-name=""

/ tool user-manager router
add subscriber=admin name="Hotlink.net" ip-address=192.168.1.3 \
shared-secret="123456" comment="" disabled=no

/ ip dns static
add name="hotlink.net" address=192.168.1.3 ttl=1d

kmudian setelah itu bikin user dan di http://hotlink.net/userman

eh jgn lupa bikin dulu customernya ... biar bisa masuk ke userman

/ tool user-manager customer
add subscriber=admin login="admin" password="admin" company="HOTlink" \
city="Bandung" country="Indonesia" date-format="%m/%d/%y" \
email="admin@hotlink-id.net" time-zone=+00:00 permissions=owner \
parent=admin comment="" disabled=no

Kamis, 10 April 2008

Setting PC Router pakai FC 4

Dari pada beli modem lagi Rp. 400-500k baik bikin router sendiri .. ya ndak ? Model Pentium II juga udah ampuh banged ! Saya lakukan sejak 2 tahun lalu di Net tongkrongan saya Ngetopnet.

Keterangan : Saya menggunakan Fedora Core 2 dengan Kompi Server specs : P III 866 Mhz, 10 GB HDD, 128 MB SDRAM, 2 MB VGA, 2 x 10/100 Ethernet (Auto detect by distro).

Langkah 1 : Pastikan network card dalam system Arahan lsmod untuk menyenaraikan semua modul/perkakasan dalam system, pastikan eth0 dan eth1 atau e100 dan e1000 ada dalam list.
#/sbin/lsmod
Module used
Eth 0(10/100) 0
Eth1 (gigabyte) 0


Langkah 2: Pastikan eth0 dan eth1 ada dalam modules.conf ("Pada langkah kedua ini saya tidak melakukannya karena tidak ada settingan seperti ini.")

#vi /etc/modules.conf
alias eth0 e100
alias eth1 e1000


Langkah 3: set IP untuk eth0 (eth0 merupakan IP public atau IP Private dari ISP) dan eth1 (eth1 merupakan IP Local dari kita Sebagai Server untuk Client ! Harus berbeda dengan eth0 walalu hanya class c nya.)

#cat /etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corp.|82801BA/BAM/CA/CAM Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:02:A5:76:C1:26
IPADDR=192.168.1.88
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
ONBOOT=yes
TYPE=Ethernet

*masukkan semua nilai sama seperti nilai di atas.
Untuk menukar nilai (edit), tekan Insert (INS)
Bila selesai mengedit, untuk menyimpan (save) dan keluar, tekan Escape (ESC), kemudian masukan ":wq". (SHIFT-Doubledot, w, q) ENTER.


# cat /etc/sysconfig/network-scripts/ifcfg-eth1

# Intel Corp.|82557/8/9 [Ethernet Pro 100]
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
NETMASK=255.255.255.0
HWADDR=00:D0:B7:55:01:E0


Langkah 4. Mengubah nilai dari "no" kepada "yes" NOZERO configuration (thanks n0x)

#vi /etc/sysconfig/network

masukkan pernyataan seperti di bawah

NOZEROCONF=yes


Langkah 5. Routing IP untuk Internet


#/sbin/iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
# /sbin/iptables -t nat -nL (checking aja)
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination


Langkah 6. Mengubah ip forwarding value to 1
Check the value for ip forwarding

#echo 1 > /proc/sys/net/ipv4/ip_forward


Langkah 7. Mengubah nilai pada sysctl.conf

#vi /etc/sysctl.conf
# cat /etc/sysctl.conf

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1


Langkah 8. Save the iptables configuration

#/sbin/service iptables save (nah itu yang terlupakan olh om praban dan om ogeb)


Langkah 9. Up all services

#/sbin/service network restart

Langkah 10. trace route output.

#route


Lihat default gateway. Itu harus sama dengan gateway yang diberikan oleh ISP kamu (ADSL kami)

Selesai.


Greetz to om praban (telah maksakan mau untuk membantu ihihihihhi), om ogeb (yang betah banged ngeladeni pertanyaanku dan menjelaskan how to), n0x (selayang baris yang membuat sempurna), dan rekan-rekan semua yang telah membantu sangat banyak.

Mikrotik dan Web Proxynya

MikroTik RouterOS™, merupakan system operasi Linux base yang diperuntuk
kan sebagai network router. Didesain untuk memberikan kemudahan bagi
penggunanya. Administrasinya bisa dilakukan melalui Windows application
(WinBox). Webbrowser serta via Remote Shell (telnet dan SSH). Selain
itu instalasi dapat dilakukan pada Standard computer PC. PC yang akan
dijadi kan router mikrotikpun tidak memerlukan resource yang cukup besar
untuk penggunaan standard, misalnya hanya sebagai gateway. Untuk keperluan
beban yang besar ( network yang kompleks, routing yang rumit dll)
disarankan untuk mempertimbangkan pemilihan resource PC yang memadai.

Fasilitas pada mikrotik antara lain sebagai berikut :
- Protokoll routing RIP, OSPF, BGP.
- Statefull firewall
- HotSpot for Plug-and-Play access
- remote winbox GUI admin

Lebih lengkap bisa dilihat di www.mikrotik.com.

Meskipun demikian Mikrotik bukanlah free software, artinya kita harus
membeli licensi terhadap segala fasiltas yang disediakan. Free trial
hanya untuk 24 jam saja. Kita bisa membeli software mikrotik dalam
bentuk CD yang diinstall pada Hard disk atau disk on module (DOM).
Jika kita membeli DOM tidak perlu install tetapi tinggal menancapkan
DOM pada slot IDE PC kita.

Instalasi Mikrotik ada beberapa cara :
1. Instalasi melalui NetInstall via jaringan
2. Instalasi melalui Floppy disk
3. Instalasi melalui CD-ROM.

Kali ini kita akan membahasnya instalasi melalui CD-ROM. Untuk percobaan
ini silahkan download ISOnya di http://adminpreman.web.id/download

Langkah-langkah berikut adalah dasar-dasar setup mikrotik yang
dikonfigurasikan untuk jaringan sederhana sebagai PC Router/Gateway,
Web Proxy, DNS Server, DHCP, Firewall serta Bandwidth Management.
Konfigurasi ini dapat dimanfaatkan untuk membangun jaringan pada
Internet Cafe atau untuk Testing pada Laboratorium Pribadi.

--[2.1]-- Topologi Jaringan

Topologi jaringan ini di anggap koneksi Internetnya melalui MODEM
xDSL (ADSL atau SDSL). Dengan catatan konfigurasi IP Publiknya
ditanam didalam MODEM, artinya perlu pula dipilih MODEM yang memiliki
fasilitas seperti Routing, Firewall, dan lain-lain. Semakin lengkap
semakin bagus, namun biasanya harga semakin mahal, yang patut
dipertimbangkan pilihlah MODEM yang memiliki fasilitas Firewall yang
bagus.

Untuk MODEM SDSL, biasanya, IP dibawah NAT, artinya IP nya bukan IP
Publik langsung. Dan umumnya untuk MODEM ADSL, IP Publiknya langsung
ditanam di MODEM itu sendiri.

Saat ini kita anggap IP Publiknya di tanam di MODEM, dimana Interface
PPPoE nya sudah di konfigurasikan dan sudah bisa DIAL ke server RASnya.

Agar memudahkan konfigurasi, perlu dirancang topologi jaringan yang
dikonfigurasi. Sebagai contoh, skema dibawah ini:


(a) Skema Jaringan

_(
o--+ ____|
| / | Telpon
| _/ -(
+--[_] Splitter
|
| +----+
+---| | Modem xDSL
+--*-+
(1)| +---+
| | | (3)
| | +|---------+
| +-----+ | |. . . . . |
| a| | | +--|-|-|-|-+
+---|=====| | | | | |
| | | | | | |
| |---+ +-|-|-|--[client 1]
| |b +-|-|------------[client 2]
| | +-|----------------------[client 3]
L-----J +--------[client n]
(2)


Keterangan skema
(1) = Modem xDSL (Ip Address : 192.168.1.1/24)
(2) = Mikrotik Box dengan 2 ethernet card yaitu a (publik) dan b (local)
(3) = Switch
Untuk sambungan ke Client. Asumsi Client Jumlahnya 20 Client
Range Ip Address : 192.168.0.0/27
Alokasi Ip Client = 192.168.0.1-192.168.0.30
Ip Net ID : 192.168.0.0/27
Ip Broadcast : 192.168.0.31/27


(b) Alokasi IP Address

[*] Mikrotik Box

Keterangan Skema
a = ethernet card 1 (Publik) -> Ip Address : 192.168.1.2/24
b = ethernet card 2 (Local) -> Ip Address : 192.168.0.30/27

Gateway : 192.168.1.1 (ke Modem)

[*] Client
Client 1 - Client n, Ip Address : 192.168.0.n .... n (1-30)

Contoh:
Client 6
Ip Address : 192.168.0.6/27
Gateway : 192.168.0.30 (ke Mikrotik Box)


CATATAN :
Angka dibelakang Ip address ( /27) sama dengan nilai netmasknya
untuk angka (/27) nilainya sama dengan 255.255.255.224.

Untuk Sub Netmask blok ip address Local kelas C, dapat diuraikan
sebagai berikut :

Subnetmask kelas C
-------------------
255.255.255.0 = 24 -> 254 mesin
.. .128 = 25 -> 128 mesin
.. .192 = 26 -> 64 mesin
.. .224 = 27 -> 32 mesin
.. .240 = 28 -> 16 mesin
.. .248 = 29 -> 8 mesin
.. .252 = 30 -> 4 mesin
.. .254 = 31 -> 2 mesin
.. .255 = 32 -> 1 mesin

--[2.2]-- Persiapan

- Untuk PC Router Siapkan PC, minimal Pentium I, RAM 64, HD 500M
atau pake flash memory 64 - Sebagai Web proxy, Siapkan PC, minimal
Pentium III 450Mhz, RAM 256 Mb, HD 20 Gb. Melihat berapa minimum
RAM dan HD yang dibutuhkan untuk Cache Silahkan lihat
http://adminpreman.web.id/download/Rumus Web Proxy Mikrotik.xls

- Siapkan minimal 2 ethernet card, 1 ke arah luar/Internet dan 1
lagi ke Network local
– Burn Source CD Mikrotik OS masukan ke CDROM.
- Versi mikrotik yang digunakan adalah Mikrotik RouterOS versi 2.9.27


--[3]-- Installasi Mikrotik Router
Setelah desain skema jaringan serta perangkat yang dibutuhkan telah
disiapkan, sekarang saatnya kita mulai proses instalasi ini.

--[3.1]-- Booting melalui CD-ROM

Atur di BIOS agar, supaya boot lewat CD-ROM, kemudian tunggu beberapa
saat di monitor akan muncul proses Instalasi.

-------------------------------------------------------------------------

ISOLINUX 2.08 2003-12-12 Copyrigth (C) 1994-2003 H. Peter Anvin
Loading linux..................
Loading initrd.rgz.............
Ready
Uncompressing Linux... Ok, booting the kernel

------------------------------------------------------------------------

--[3.2]-- Memilih paket software

Setelah proses booting akan muncul menu pilihan software yang
mau di install, pilih sesuai kebutuhan yang akan direncanakan.

Paket yang tersedia di Mikrotik

advanced-tools-2.9.27.npk
arlan-2.9.27.npk
dhcp-2.9.27.npk
gps-2.9.27.npk
hotspot-2.9.27.npk
hotspot-fix-2.9.27.npk
isdn-2.9.27.npk
lcd-2.9.27.npk
ntp-2.9.27.npk
ppp-2.9.27.npk
radiolan-2.9.27.npk
routerboard-2.9.27.npk
routing-2.9.27.npk
routing-test-2.9.27.npk
rstp-bridge-test-2.9.27.npk
security-2.9.27.npk
synchronous-2.9.27.npk
system-2.9.27.npk
telephony-2.9.27.npk
ups-2.9.27.npk
user-manager-2.9.27.npk
web-proxy-2.9.27.npk
webproxy-test-2.9.27.npk
wireless-2.9.27.npk
wireless-legacy-2.9.27.npk


--------------------------------------------------------------------------

Welcome to Mikrotik Router Software Installation

Move around menu using 'p' and 'n' or arrow keys, select with 'spacebar'.
Select all with 'a', minimum with 'm'. Press 'i' to install locally or 'r' to
install remote router or 'q' to cancel and reboot.

[X] system [ ] lcd [ ] telephony
[ ] ppp [ ] ntp [ ] ups
[ ] dhcp [ ] radiolan [ ] user-manager
[X] andvanced-tools [ ] routerboard [X] web-proxy
[ ] arlan [ ] routing [ ] webproxy-test
[ ] gps [ ] routing-test [ ] wireless
[ ] hotspot [ ] rstp-bridge-test [ ] wireless-legacy
[ ] hotspot [X] security
[ ] isdn [ ] synchronous

--------------------------------------------------------------------------

Umumnya Paket Mikrotik untuk Warnet, Kantor atau SOHO adalah :

a. SYSTEM : Paket ini merupakan paket dasar, berisi Kernel dari
Mikrotik

b. DHCP : Paket yang berisi fasilitas sebagai DHCP Server, DHCP
client, pastikan memilih paket ini jika Anda menginginkan
agar Client diberikan IP address otomatis dari DHCP Server

c. SECURITY : Paket ini berisikan fasilitas yang mengutamakan Keamanan
jaringan, seperti Remote Mesin dengan SSH, Remote via MAC
Address

d. WEB-PROXY : Jika Anda memilih paket ini, maka Mikrotik Box anda telah
dapat menjalan service sebagai Web proxy yang akan menyimpan
cache agar traffik ke Internet dapat di reduksi serta browsing
untuk Web dapat dipercepat.

e. ADVANCED TOOLS : Paket yang berisi Tool didalam melakukan Admnistrasi jaringan,
seperti Bandwidth meter, Scanning, Nslookup, dan lain sebagainya.


--[3.3]-- Instalasi Paket

ketik "i" setelah selesai memilih software, lalu akan muncul menu
pilihan seperti ini :

- Do you want to keep old configuration ? [y/n] ketik Y
- continue ? [y/n] ketik Y

Setelah itu proses installasi system dimulai, disini kita tidak
perlu membuat partisi hardsik karena secara otomatis mikrotik akan
membuat partisi sendiri.

----------------------------------------------------------------------------

wireless-legacy (depens on system):
Provides support for Cisco Aironet cards and for PrismlI and Atheros wireless
station and AP.

Do you want to keep old configuraion? [y/n]:y

Warning: all data on the disk will be erased!

Continue? [y/n]:y

Creating partition..........
Formatting disk.......................................

Installing system-2.9.27 [################## ]

---------------------------------------------------------------------------


Proses installasi

---------------------------------------------------------------------------

Continue? [y/n]:y

Creating partition.......................
Formatting disk............................

Installed system-2.9.27
Installed advanced-tools-2.9.27
Installed dhcp-2.9.27
Installed security-2.9.27
installed web-proxy-2.9.27

Software installed.
Press ENTER to reboot

------------------------------------------------------------------------------

CATATAN :
Proses Installasi normalnya tidak sampai 15 menit, jika lebih berarti gagal,ulangi
ke step awal. Setelah proses installasi selesai maka kita akan diminta untuk
merestart system, tekan enter untuk merestart system.

--[3.5]-- Proses Check system disk

Setelah komputer booting kembali ke system mikrotik, akan ada pilihan untuk
melakukan check system disk, tekan "y".

----------------------------------------------------------------------------
Loading system with initrd
Uncompressing Linux... Ok, booting the kernel.
Starting.

It is recomended to check your disk drive for error,
but it may take while (~1min for 1Gb).
It can be done later with "/system check-disk".
Do you want to do it now? [y/n]
-----------------------------------------------------------------------------

--[3.6]-- Proses Instalasi Selesai

Setelah proses instalasi selesai, maka akan muncul menu login dalam modus
terminal, kondisi sistem saat ini dalam keadaan default.

Mikrotik login = admin
Password = (kosong, enter saja)

---------------------------------------------------------------------------
Mikrotik 2.9.27
Mikrotik Login:




MMM MMM KKK TTTTTTTTTTT KKK
MMMM MMMM KKK TTTTTTTTTTT KKK
MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK
MMM MM MMM III KKKKK RRR RRR OOO OOO TTT III KKKKK
MMM MMM III KKK KKK RRRRRR OOO OOO TTT III KKK KKK
MMM MMM III KKK KKK RRR RRR OOOOOO TTT III KKK KKK

MikroTik RouterOS 2.9.27 (c) 1999-2005 http://www.mikrotik.com/









Terminal vt102 detected, using multiline input mode
[admin@Mikrotikl] >

----------------------------------------------------------------------------

CATATAN :
Konfigurasi Standar untuk mikrotik ada 2 modus, yaitu modus teks dan
modus GUI. Modus Gui ada 2 juga, yaitu Via Browser serta Via Winbox.
Untuk sekarang saya akan bahas via Teks. Karena cepat serta lebih memahami
terhadap sistem operasi ini.


--[4]-- Perintah Dasar

Perintah mikrotik sebenarnya hampir sama dengan perintah yang ada dilinux,
sebab pada dasarnya mikrotik ini merupakan kernel Linux, hasil pengolahan
kembali Linux dari Distribusi Debian. Pemakaian perintah shellnya sama,
seperti penghematan perintah, cukup menggunakan tombol TAB di keyboard
maka perintah yang panjang, tidak perlu lagi diketikkan, hanya ketikkan
awal nama perintahnya, nanti secara otomatis Shell akan menampilkan sendiri
perintah yang berkenaan. Misalnya perintah IP ADDRESS di mikrotik. Cukup
hanya mengetikkan IP ADD spasi tekan tombol TAB, maka otomatis shell
akan mengenali dan menterjemahkan sebagai perintah IP ADDRESS.

Baiklah kita lanjutkan pengenalan perintah ini.

Setelah login, cek kondisi interface atau ethernet card.

--[4.1]-- Melihat kondisi interface pada Mikrotik Router

[admin@Mikrotik] > interface print
Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R ether1 ether 0 0 1500
1 R ether2 ether 0 0 1500

[admin@Mikrotik]>

Jika interfacenya ada tanda X (disabled) setelah nomor (0,1), maka periksa lagi
etherned cardnya, seharusnya R (running).

a. Mengganti nama interface
[admin@Mikrotik] > interface(enter)

b. Untuk mengganti nama Interface ether1 menjadi Public (atau terserah namanya), maka
[admin@Mikrotik] interface> set 0 name=Public

c. Begitu juga untuk ether2, misalkan namanya diganti menjadi Local, maka
[admin@Mikrotik] interface> set 1 name=Local

d. atau langsung saja dari posisi root direktori, memakai tanda "/", tanpa tanda kutip
[admin@Mikrotik] > /interface set 0 name=Public

e. Cek lagi apakah nama interface sudah diganti.
[admin@Mikrotik] > /interface print

Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R Local ether 0 0 1500
1 R Public ether 0 0 1500



--[4.2]-- Mengganti password default
Untuk keamanan ganti password default
[admin@Mikrotik] > password
old password: *****
new password: *****
retype new password: *****
[admin@ Mikrotik]]>

--[4.3]-- Mengganti nama hostname
Mengganti nama Mikrotik Router untuk memudahkan konfigurasi, pada langkah ini
nama server akan diganti menjadi “routerku"

[admin@Mikrotik] > system identity set name=routerku
[admin@routerku]>


--[5]-- Setting IP Address, Gateway, Masqureade dan Name Server

--[5.1]-- IP Address

Bentuk Perintah konfigurasi

ip address add address ={ip address/netmask} interface={nama interface}

a. Memberikan IP address pada interface Mikrotik. Misalkan Public akan kita gunakan untuk
koneksi ke Internet dengan IP 192.168.1.2 dan Local akan kita gunakan untuk network LAN
kita dengan IP 192.168.0.30 (Lihat topologi)

[admin@routerku] > ip address add address=192.168.1.2
netmask=255.255.255.0 interface=Public comment="IP ke Internet"

[admin@routerku] > ip address add address=192.168.0.30
netmask=255.255.255.224 interface=Local comment = "IP ke LAN"

b. Melihat konfigurasi IP address yang sudah kita berikan

[admin@routerku] >ip address print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 ;;; IP Address ke Internet
192.168.0.30/27 192.168.0.0 192.168.0.31 Local
1 ;;; IP Address ke LAN
192.168.1.2/24 192.168.0.0 192.168.1.255 Public
[admin@routerku]>


--[5.2]-- Gateway

Bentuk Perintah Konfigurasi

ip route add gateway={ip gateway}

a. Memberikan default Gateway, diasumsikan gateway untuk koneksi internet adalah
192.168.1.1

[admin@routerku] > /ip route add gateway=192.168.1.1

b. Melihat Tabel routing pada Mikrotik Routers

[admin@routerku] > ip route print

Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf
# DST-ADDRESS PREFSRC G GATEWAY DISTANCE INTERFACE
0 ADC 192.168.0.0/24 192.168.0.30 Local
1 ADC 192.168.0.0/27 192.168.1.2 Public
2 A S 0.0.0.0/0 r 192.168.1.1 Public
[admin@routerku]>

c. Tes Ping ke Gateway untuk memastikan konfigurasi sudah benar

[admin@routerku] > ping 192.168.1.1
192.168.1.1 64 byte ping: ttl=64 time<1 ms
192.168.1.1 64 byte ping: ttl=64 time<1 ms
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0/0.0/0 ms
[admin@routerku]>

--[5.3]-- NAT (Network Address Translation)

Bentuk Perintah Konfigurasi

ip firewall nat add chain=srcnat action=masquerade out-inteface={ethernet
yang langsung terhubung ke Internet atau Public}

a. Setup Masquerading, Jika Mikrotik akan kita pergunakan sebagai gateway server maka agar
client computer pada network dapat terkoneksi ke internet perlu kita masquerading.

[admin@routerku] > ip firewall nat add chain=scrnat out-interface=Public action=masquerade
[admin@routerku]>

b. Melihat konfigurasi Masquerading

[admin@routerku] ip firewall nat print
Flags: X - disabled, I - invalid, D - dynamic
0 chain=srcnat out-interface=Public action=masquerade
[admin@routerku]>

--[5.4] Name server

Bentuk Perintah Konfigurasi

ip dns set primary-dns={dns utama} secondary-dns={dns ke dua}


a. Setup DNS pada Mikrotik Routers, misalkan DNS dengan Ip Addressnya
Primary = 202.134.0.155, Secondary = 202.134.2.5


[admin@routerku] > ip dns set primary-dns=202.134.0.155 allow-remoterequests=yes
[admin@routerku] > ip dns set secondary-dns=202.134.2.5 allow-remoterequests=yes

b. Melihat konfigurasi DNS

[admin@routerku] > ip dns print
primary-dns: 202.134.0.155
secondary-dns: 202.134.2.5
allow-remote-requests: no
cache-size: 2048KiB
cache-max-ttl: 1w
cache-used: 16KiB

[admin@routerku]>

c. Tes untuk akses domain, misalnya dengan ping nama domain

[admin@routerku] > ping yahoo.com
216.109.112.135 64 byte ping: ttl=48 time=250 ms
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 571/571.0/571 ms
[admin@routerku]>

Jika sudah berhasil reply berarti seting DNS sudah benar.

Setelah langkah ini bisa dilakukan pemeriksaan untuk koneksi dari jaringan local. Dan jika
berhasil berarti kita sudah berhasil melakukan instalasi Mikrotik Router sebagai Gateway
server. Setelah terkoneksi dengan jaringan Mikrotik dapat dimanage menggunakan WinBox yang
bisa di download dari Mikrotik.com atau dari server mikrotik kita. Misal Ip address server
mikrotik kita 192.168.0.30, via browser buka http://192.168.0.30. Di Browser akan ditampilkan
dalam bentuk web dengan beberapa menu, cari tulisan Download dan download WinBox dari situ.
Simpan di local harddisk. Jalankan Winbox, masukkan Ip address, username dan password.


--[7]-- DHCP Server

DHCP merupakan singkatan dari Dynamic Host Configuration Protocol, yaitu suatu program yang
memungkinkan pengaturan IP Address di dalam sebuah jaringan dilakukan terpusat di server,
sehingga PC Client tidak perlu melakukan konfigurasi IP Addres. DHCP memudahkan administrator
untuk melakukan pengalamatan ip address untuk client.

Bentuk perintah konfigurasi

ip dhcp-server setup
dhcp server interface = { interface yang digunakan }
dhcp server space = { network yang akan di dhcp }
gateway for dhcp network = { ip gateway }
address to give out = { range ip address }
dns servers = { name server }
lease time = { waktu sewa yang diberikan }


Jika kita menginginkan client mendapatkan IP address secara otomatis maka perlu kita setup
dhcp server pada Mikrotik. Berikut langkah-langkahnya :

a. Tambahkan IP address pool

/ip pool add name=dhcp-pool ranges=192.168.0.1-192.168.0.30

b. Tambahkan DHCP Network dan gatewaynya yang akan didistribusikan ke client.
Pada contoh ini networknya adalah 192.168.0.0/27 dan gatewaynya 122.168.0.30

/ip dhcp-server network add address=192.168.0.0/27 gateway=192.168.0.30 dns-server=192.168.0.30
comment=""

c. Tambahkan DHCP Server ( pada contoh ini dhcp diterapkan pada interface Local )

/ip dhcp-server add interface=local address-pool=dhcp-pool

d. Lihat status DHCP server

[admin@routerku] > ip dhcp-server print

Flags: X - disabled, I - invalid

# NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP

0dhcp1 Local

Tanda X menyatakan bahwa DHCP server belum enable maka perlu dienablekan terlebih
dahulu pada langkah e.

e. Jangan Lupa dibuat enable dulu dhcp servernya

/ip dhcp-server enable 0

kemudian cek kembali dhcp-server seperti langkah 4, jika tanda X sudah tidak ada berarti
sudah aktif

f. Tes Dari client

Misalnya :
D:>ping www.yahoo.com

--[8]-- Transparent Proxy Server

Proxy server merupakan program yang dapat mempercepat akses ke suatu web
yang sudah diakses oleh komputer lain, karena sudah di simpan didalam
caching server.Transparent proxy menguntungkan dalam management client,
karena system administrator tidak perlu lagi melakukan setup proxy di
setiap browser komputer client karena redirection dilakukan otomatis di sisi
server.

Bentuk perintah konfigurasi :
a. Setting web proxy :

- ip proxy set enable=yes
port={ port yang mau digunakan }
maximal-client-connections=1000
maximal-server-connections=1000

- ip proxy direct add src-address={ network yang akan di
NAT} action=allow

- ip web-proxy set parent-proxy={proxy parent/optional}
hostname={ nama host untuk proxy/optional}
port={port yang mau digunakan}
src-address={ address yang akan digunakan untuk koneksi
ke parent proxy/default 0.0.0.0}
transparent-proxy=yes
max-object-size={ ukuran maximal file yang akan disimpan
sebagai cache/default 4096 in Kilobytes}
max-cache-size= { ukuran maximal hardisk yang akan
dipakai sebagai penyimpan file cache/unlimited
| none | 12 in megabytes}
cache-administrator={ email administrator yang akan digunakan
apabila proxy error, status akan dikirim
ke email tersebut}
enable==yes


Contoh konfigurasi
-------------------

a. Web proxy setting

/ ip web-proxy
set enabled=yes src-address=0.0.0.0 port=8080
hostname="proxy.routerku.co.id" transparent-proxy=yes
parent-proxy=0.0.0.0:0 cache-administrator="support@routerku.co.id"
max-object-size=131072KiB cache-drive=system max-cache-size=unlimited
max-ram-cache-size=unlimited

Nat Redirect, perlu ditambahkan yaitu rule REDIRECTING untuk membelokkan
traffic HTTP menuju ke WEB-PROXY.

b. Setting firewall untuk Transparant Proxy

Bentuk perintah konfigurasi :

ip firewall nat add chain=dstnat
protocol=tcp
dst-port=80
action=redirect
to-ports={ port proxy }

Perintahnya:

--------------------------------------------------------------------------------
/ ip firewall nat
add chain=dstnat protocol=tcp dst-port=80 action=redirect to-ports=8080
comment="" disabled=no
add chain=dstnat protocol=tcp dst-port=3128 action=redirect to-ports=8080
comment="" disabled=no
add chain=dstnat protocol=tcp dst-port=8000 action=redirect to-ports=8080
--------------------------------------------------------------------------------

perintah diatas dimaksudkan, agar semua trafik yang menuju Port 80,3128,8000
dibelokkan menuju port 8080 yaitu portnya Web-Proxy.

CATATAN:
Perintah

/ip web-proxy print { untuk melihat hasil konfigurasi web-proxy}
/ip web-proxy monitor { untuk monitoring kerja web-proxy}


--[9]-- Bandwidth Management

QoS memegang peranan sangat penting dalam hal memberikan pelayanan
yang baik pada client. Untuk itu kita memerlukan bandwidth management
untuk mengatur tiap data yang lewat, sehingga pembagian bandwidth menjadi
adil. Dalam hal ini Mikrotik RouterOs juga menyertakan packet software
untuk memanagement bandwidth.

Bentuk perintah konfigurasi:

queue simple add name={ nama }
target-addresses={ ip address yang dituju }
interface={ interface yang digunakan untuk melewati data }
max-limit={ out/in }

Dibawah ini terdapat konfigurasi Trafik shaping atau bandwidth management
dengan metode Simple Queue, sesuai namanya, Jenis Queue ini memang
sederhana, namun memiliki kelemahan, kadangkala terjadi kebocoran bandwidth
atau bandwidthnya tidak secara real di monitor. Pemakaian untuk 10 Client,
Queue jenis ini tidak masalah.

Diasumsikan Client ada sebanyak 15 client, dan masing-masing client diberi
jatah bandwidth minimum sebanyak 8kbps, dan maksimum 48kbps. Sedangkan
Bandwidth totalnya sebanyak 192kbps. Untuk upstream tidak diberi rule,
berarti masing-masing client dapat menggunakan bandwidth uptream secara
maksimum. Perhatikan perintah priority, range priority di Mikrotik sebanyak
delapan. Berarti dari 1 sampai 8, priority 1 adalah priority tertinggi,
sedangkan priority 8 merupakan priority terendah.

Berikut Contoh kongirufasinya.
--------------------------------------------------------------------------------
/ queue simple
add name="trafikshaping" target-addresses=192.168.0.0/27 dst-address=0.0.0.0/0
interface=all parent=none priority=1 queue=default/default
limit-at=0/64000 max-limit=0/192000 total-queue=default disabled=no
add name="01" target-addresses=192.168.0.1/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="02" target-addresses=192.168.0.2/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="03" target-addresses=192.168.0.3/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="04" target-addresses=192.168.0.4/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="10" target-addresses=192.168.0.25/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="05" target-addresses=192.168.0.5/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="06" target-addresses=192.168.0.6/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="07" target-addresses=192.168.0.7/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="08" target-addresses=192.168.0.8/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="09" target-addresses=192.168.0.9/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="10" target-addresses=192.168.0.10/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="11" target-addresses=192.168.0.11/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="12" target-addresses=192.168.0.12/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="13" target-addresses=192.168.0.13/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="14" target-addresses=192.168.0.14/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no
add name="15" target-addresses=192.168.0.15/32 dst-address=0.0.0.0/0
interface=all parent=trafikshaping priority=1 queue=default/default
limit-at=0/8000 max-limit=0/48000 total-queue=default disabled=no

Perintah diatas karena dalam bentuk command line, bisa juga di copy
paste, selanjutnya di paste saja ke consol mikrotiknya. ingat lihat
dulu path atau direktory aktif. Silahkan dipaste saja, kalau posisi
direktorynya di Root.

-------------------------------------------------------------------
Terminal vt102 detected, using multiline input mode
[admin@mikrotik] >
------------------------------------------------------------------

Pilihan lain metode bandwidth manajemen ini, kalau seandainya ingin
bandwidth tersebut dibagi sama rata oleh Mikrotik, seperti bandwidth
256kbps downstream dan 256kbps upstream. Sedangkan client yang akan
mengakses sebanyak 10 client, maka otomatis masing-masing client
mendapat jatah bandwidth upstream dan downstream sebanyak 256kbps
dibagi 10. Jadi masing-masing dapat 25,6kbps. Andaikata hanya 2 Client
yang mengakses maka masing-masing dapat 128kbps.

Untuk itu dipakai type PCQ (Per Connection Queue), yang bisa secara
otomatis membagi trafik per client. Tentang jenis queue di mikrotik
ini dapat dibaca pada manualnya di http://www.mikrotik.com/testdocs/
ros/2.9/root/queue.php.

Sebelumnya perlu dibuat aturan di bagian MANGLE. Seperti :

--------------------------------------------------------------------
/ip firewall mangle add chain=forward src-address=192.168.0.0/27
action=mark-connection new-connection-mark=users-con
/ip firewall mangle add connection-mark=users-con action=mark-packet
new-packet-mark=users chain=forward
----------------------------------------------------------------------

Karena type PCQ belum ada, maka perlu ditambah, ada 2 type PCQ ini.
Pertama diberi nama pcq-download, yang akan mengatur semua trafik
melalui alamat tujuan/destination address. Trafik ini melewati
interface Local. Sehingga semua traffik download/downstream yang
datang dari jaringan 192.168.0.0/27 akan dibagi secara otomatis.

Tipe PCQ kedua, dinamakan pcq-upload, untuk mengatur semua trafik upstream
yang berasal dari alamat asal/source address. Trafik ini melewati
interface public. Sehingga semua traffik upload/upstream yang berasal
dari jaringan 192.168.0.0/27 akan dibagi secara otomatis.

Perintah:
-------------------------------------------------------------------------
/queue type add name=pcq-download kind=pcq pcq-classifier=dst-address
/queue type add name=pcq-upload kind=pcq pcq-classifier=src-address
-------------------------------------------------------------------------

Setelah aturan untuk PCQ dan Mangle ditambahkan, sekarang untuk aturan
pembagian trafiknya. Queue yang dipakai adalah Queue Tree, Yaitu:

-------------------------------------------------------------------------
/queue tree add parent=Local queue=pcq-download packet-mark=users
/queue tree add parent=Public queue=pcq-upload packet-mark=users
-------------------------------------------------------------------------

Perintah diatas mengasumsikan, kalau bandwidth yang diterima dari provider
Internet berflukstuasi atau berubah-rubah. Jika kita yakin bahwa bandwidth
yang diterima, misalkan dapat 256kbs downstream, dan 256kbps upstream, maka
ada lagi aturannya, seperti :

Untuk trafik downstreamnya :
------------------------------------------------------------------------
/queue tree add name=Download parent=Local max-limit=256k
/queue tree add parent=Download queue=pcq-download packet-mark=users
-------------------------------------------------------------------------

Dan trafik upstreamnya :
---------------------------------------------------------------------------
/queue tree add name=Upload parent=Public max-limit=256k
/queue tree add parent=Upload queue=pcq-upload packet-mark=users
---------------------------------------------------------------------------

--[10]-- Monitor MRTG via Web

Fasilitas ini diperlukan untuk monitoring trafik dalam bentuk grafik, dapat
dilihat dengan menggunakan browser. MRTG (The Multi Router Traffic Grapher)
telah dibuild sedemikian rupa, sehingga memudahkan kita memakainya. Telah
tersedia dipaket dasarnya.

Contoh konfigurasinya

-------------------------------------------------------------------------
/ tool graphing
set store-every=5min
/ tool graphing interface
add interface=all allow-address=0.0.0.0/0 store-on-disk=yes disabled=no
---------------------------------------------------------------------------

Perintah diatas akan menampilkan grafik dari trafik yang melewati interface
jaringan baik berupa Interface Public dan Interface Local, yang dirender
setiap 5 menit sekali. Juga dapat diatur Alamat apa saja yang dapat mengakses
MRTG ini, pada parameter allow-address.

--[11]-- Keamanan di Mikrotik

Setelah beberapa Konfigurasi diatas telah disiapkan, tentu tidak lupa kita
perhatikan keamanan dari Mesin gateway Mikrotik ini, ada beberapa fasilitas
yang dipergunakan. Dalam hal ini akan dibahas tentang Firewallnya. Fasilitas
Firewall ini secara pringsip serupa dengan IP TABLES di Gnu/Linux hanya saja
beberapa perintah telah di sederhanakan namun berdaya guna.

Di Mikrotik perintah firewall ini terdapat dalam modus IP, yaitu

[admin@routerku] > /ip firewall

Terdapat beberapa packet filter seperti mangle, nat, dan filter.

-------------------------------------------------------------------------
[admin@routerku] ip firewall> ?

Firewall allows IP packet filtering on per packet basis.

.. -- go up to ip
mangle/ -- The packet marking management
nat/ -- Network Address Translation
connection/ -- Active connections
filter/ -- Firewall filters
address-list/ --
service-port/ -- Service port management
export --
--------------------------------------------------------------------------

Untuk kali ini kita akan lihat konfigurasi pada ip firewall filternya.

Karena Luasnya parameter dari firewall filter ini untuk pembahasan Firewall
Filter selengkapnya dapat dilihat pada manual mikrotik, di
http://www.mikrotik.com/testdocs/ros/2.9/ip/filter.php

Konfigurasi dibawah ini dapat memblokir beberapa Trojan, Virus, Backdoor
yang telah dikenali sebelumnya baik Nomor Port yang dipakai serta Protokolnya.
Juga telah di konfigurasikan untuk menahan Flooding dari Jaringan Publik dan
jaringan Lokal. Serta pemberian rule untuk Access control agar, Rentang
jaringan tertentu saja yang bisa melakukan Remote atau mengakses service
tertentu terhadap Mesin Mikrotik kita.

Contoh Aplikasi Filternya
-----------------------------------------------------------------------------
/ ip firewall filter
add chain=input connection-state=invalid action=drop comment="Drop Invalid
connections" disabled=no
add chain=input src-address=!192.168.0.0/27 protocol=tcp src-port=1024-65535
dst-port=8080 action=drop comment="Block to Proxy" disabled=no
add chain=input protocol=udp dst-port=12667 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=udp dst-port=27665 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=udp dst-port=31335 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=udp dst-port=27444 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=udp dst-port=34555 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=udp dst-port=35555 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=27444 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=27665 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=31335 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=31846 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=34555 action=drop comment="Trinoo"
disabled=no
add chain=input protocol=tcp dst-port=35555 action=drop comment="Trinoo"
disabled=no
add chain=input connection-state=established action=accept comment="Allow
Established connections" disabled=no
add chain=input protocol=udp action=accept comment="Allow UDP" disabled=no
add chain=input protocol=icmp action=accept comment="Allow ICMP" disabled=no
add chain=input src-address=192.168.0.0/27 action=accept comment="Allow access
to router from known network" disabled=no
add chain=input action=drop comment="Drop anything else" disabled=no
add chain=forward protocol=tcp connection-state=invalid action=drop
comment="drop invalid connections" disabled=no
add chain=forward connection-state=established action=accept comment="allow
already established connections" disabled=no
add chain=forward connection-state=related action=accept comment="allow
related connections" disabled=no
add chain=forward src-address=0.0.0.0/8 action=drop comment="" disabled=no
add chain=forward dst-address=0.0.0.0/8 action=drop comment="" disabled=no
add chain=forward src-address=127.0.0.0/8 action=drop comment="" disabled=no
add chain=forward dst-address=127.0.0.0/8 action=drop comment="" disabled=no
add chain=forward src-address=224.0.0.0/3 action=drop comment="" disabled=no
add chain=forward dst-address=224.0.0.0/3 action=drop comment="" disabled=no
add chain=forward protocol=tcp action=jump jump-target=tcp comment=""
disabled=no
add chain=forward protocol=udp action=jump jump-target=udp comment=""
disabled=no
add chain=forward protocol=icmp action=jump jump-target=icmp comment=""
disabled=no
add chain=tcp protocol=tcp dst-port=69 action=drop comment="deny TFTP"
disabled=no
add chain=tcp protocol=tcp dst-port=111 action=drop comment="deny RPC
portmapper" disabled=no
add chain=tcp protocol=tcp dst-port=135 action=drop comment="deny RPC
portmapper" disabled=no
add chain=tcp protocol=tcp dst-port=137-139 action=drop comment="deny NBT"
disabled=no
add chain=tcp protocol=tcp dst-port=445 action=drop comment="deny cifs"
disabled=no
add chain=tcp protocol=tcp dst-port=2049 action=drop comment="deny NFS"
disabled=no
add chain=tcp protocol=tcp dst-port=12345-12346 action=drop comment="deny
NetBus" disabled=no
add chain=tcp protocol=tcp dst-port=20034 action=drop comment="deny NetBus"
disabled=no
add chain=tcp protocol=tcp dst-port=3133 action=drop comment="deny
BackOriffice" disabled=no
add chain=tcp protocol=tcp dst-port=67-68 action=drop comment="deny DHCP"
disabled=no
add chain=udp protocol=udp dst-port=69 action=drop comment="deny TFTP"
disabled=no
add chain=udp protocol=udp dst-port=111 action=drop comment="deny PRC
portmapper" disabled=no
add chain=udp protocol=udp dst-port=135 action=drop comment="deny PRC
portmapper" disabled=no
add chain=udp protocol=udp dst-port=137-139 action=drop comment="deny NBT"
disabled=no
add chain=udp protocol=udp dst-port=2049 action=drop comment="deny NFS"
disabled=no
add chain=udp protocol=udp dst-port=3133 action=drop comment="deny
BackOriffice" disabled=no
add chain=input protocol=tcp psd=21,3s,3,1 action=add-src-to-address-list
address-list="port scanners" address-list-timeout=2w comment="Port
scanners to list " disabled=no
add chain=input protocol=tcp tcp-flags=fin,!syn,!rst,!psh,!ack,!urg
action=add-src-to-address-list address-list="port scanners"
address-list-timeout=2w comment="NMAP FIN Stealth scan" disabled=no
add chain=input protocol=tcp tcp-flags=fin,syn action=add-src-to-address-list
address-list="port scanners" address-list-timeout=2w comment="SYN/FIN
scan" disabled=no
add chain=input protocol=tcp tcp-flags=syn,rst action=add-src-to-address-list
address-list="port scanners" address-list-timeout=2w comment="SYN/RST
scan" disabled=no
add chain=input protocol=tcp tcp-flags=fin,psh,urg,!syn,!rst,!ack
action=add-src-to-address-list address-list="port scanners"
address-list-timeout=2w comment="FIN/PSH/URG scan" disabled=no
add chain=input protocol=tcp tcp-flags=fin,syn,rst,psh,ack,urg
action=add-src-to-address-list address-list="port scanners"
address-list-timeout=2w comment="ALL/ALL scan" disabled=no
add chain=input protocol=tcp tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg
action=add-src-to-address-list address-list="port scanners"
address-list-timeout=2w comment="NMAP NULL scan" disabled=no
add chain=input src-address-list="port scanners" action=drop comment="dropping
port scanners" disabled=no
add chain=icmp protocol=icmp icmp-options=0:0 action=accept comment="drop
invalid connections" disabled=no
add chain=icmp protocol=icmp icmp-options=3:0 action=accept comment="allow
established connections" disabled=no
add chain=icmp protocol=icmp icmp-options=3:1 action=accept comment="allow
already established connections" disabled=no
add chain=icmp protocol=icmp icmp-options=4:0 action=accept comment="allow
source quench" disabled=no
add chain=icmp protocol=icmp icmp-options=8:0 action=accept comment="allow
echo request" disabled=no
add chain=icmp protocol=icmp icmp-options=11:0 action=accept comment="allow
time exceed" disabled=no
add chain=icmp protocol=icmp icmp-options=12:0 action=accept comment="allow
parameter bad" disabled=no
add chain=icmp action=drop comment="deny all other types" disabled=no
add chain=tcp protocol=tcp dst-port=25 action=reject
reject-with=icmp-network-unreachable comment="Smtp" disabled=no
add chain=tcp protocol=udp dst-port=25 action=reject
reject-with=icmp-network-unreachable comment="Smtp" disabled=no
add chain=tcp protocol=tcp dst-port=110 action=reject
reject-with=icmp-network-unreachable comment="Smtp" disabled=no
add chain=tcp protocol=udp dst-port=110 action=reject
reject-with=icmp-network-unreachable comment="Smtp" disabled=no
add chain=tcp protocol=udp dst-port=110 action=reject
reject-with=icmp-network-unreachable comment="Smtp" disabled=no
-----------------------------------------------------------------------------

--[11.1]-- Service dan Melihat Service yang Aktif dengan PortScanner

Untuk memastikan Service apa saja yang aktif di Mesin mikrotik, perlu kita
pindai terhadap port tertentu, seandainya ada service yang tidak dibutuhkan,
sebaiknya dimatikan saja.

Untuk menonaktifkan dan mengaktifkan servise, perintah adalah :

Kita periksa dahulu service apa saja yang aktif

----------------------------------------------------------------------------------
[admin@routerku] > ip service
[admin@routerku] ip service> print
Flags: X - disabled, I - invalid
# NAME PORT ADDRESS CERTIFICATE
0 X telnet 23 0.0.0.0/0
1 ftp 21 0.0.0.0/0
2 www 80 0.0.0.0/0
3 ssh 22 0.0.0.0/0
4 www-ssl 443 0.0.0.0/0 none
[admin@routerku] ip service>
----------------------------------------------------------------------------------

Misalkan service FTP akan dinonaktifkan, yaitu di daftar diatas terletak pada
nomor 1 (lihat bagian Flags) maka :

---------------------------------------------------------------------------------
[admin@routerku] ip service> set 1 disabled=yes
---------------------------------------------------------------------------------

Perlu kita periksa lagi,

---------------------------------------------------------------------------------
[admin@routerku] ip service> print
Flags: X - disabled, I - invalid
# NAME PORT ADDRESS CERTIFICATE
0 X telnet 23 0.0.0.0/0
1 X ftp 21 0.0.0.0/0
2 www 80 0.0.0.0/0
3 ssh 22 0.0.0.0/0
4 www-ssl 443 0.0.0.0/0 none
[admin@router.dprd.provinsi] ip service>
---------------------------------------------------------------------------------

Sekarang service FTP telah dinonaktifkan.

Dengan memakai tool nmap kita dapat mencek port apa saja yang aktif pada mesin
gateway yang telah dikonfigurasikan.

Perintah : nmap -vv -sS -sV -P0 192.168.0.30

Hasil :

-------------------------------------------------------------------------------------
Starting Nmap 4.20 ( http://insecure.org ) at 2007-04-04 19:55 SE Asia Standard Time
Initiating ARP Ping Scan at 19:55
Scanning 192.168.0.30 [1 port]
Completed ARP Ping Scan at 19:55, 0.31s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 19:55
Completed Parallel DNS resolution of 1 host. at 19:55, 0.05s elapsed
Initiating SYN Stealth Scan at 19:55
Scanning 192.168.0.30 [1697 ports]
Discovered open port 22/tcp on 192.168.0.30
Discovered open port 53/tcp on 192.168.0.30
Discovered open port 80/tcp on 192.168.0.30
Discovered open port 21/tcp on 192.168.0.30
Discovered open port 3986/tcp on 192.168.0.30
Discovered open port 2000/tcp on 192.168.0.30
Discovered open port 8080/tcp on 192.168.0.30
Discovered open port 3128/tcp on 192.168.0.30
Completed SYN Stealth Scan at 19:55, 7.42s elapsed (1697 total ports)
Initiating Service scan at 19:55
Scanning 8 services on 192.168.0.30
Completed Service scan at 19:57, 113.80s elapsed (8 services on 1 host)
Host 192.168.0.30 appears to be up ... good.
Interesting ports on 192.168.0.30:
Not shown: 1689 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp MikroTik router ftpd 2.9.27
22/tcp open ssh OpenSSH 2.3.0 mikrotik 2.9.27 (protocol 1.99)
53/tcp open domain?
80/tcp open http MikroTik router http config
2000/tcp open callbook?
3128/tcp open http-proxy Squid webproxy 2.5.STABLE11
3986/tcp open mapper-ws_ethd?
8080/tcp open http-proxy Squid webproxy 2.5.STABLE11
2 services unrecognized despite returning data. If you know the service/version,
please submit the following fingerprints at
http://www.insecure.org/cgi-bin/servicefp-submit.cgi :

==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port53-TCP:V=4.20%I=7%D=4/4%Time=4613A03C%P=i686-pc-windows-windows%r(D
SF:NSVersionBindReq,E,"�x0c�x06x81x84��������")%r(DNSStatusR
SF:equest,E,"�x0c��x90x84��������");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port2000-TCP:V=4.20%I=7%D=4/4%Time=4613A037%P=i686-pc-windows-windows%r
SF:(NULL,4,"x01���")%r(GenericLines,4,"x01���")%r(GetRequest,18,"
SF:x01���x02���d?xe4{x9dx02x1axccx8bxd1Vxb2Fxff9xb0")%r(
SF:HTTPOptions,18,"x01���x02���d?xe4{x9dx02x1axccx8bxd1Vx
SF:b2Fxff9xb0")%r(RTSPRequest,18,"x01���x02���d?xe4{x9dx02x
SF:1axccx8bxd1Vxb2Fxff9xb0")%r(RPCCheck,18,"x01���x02���d?
SF:xe4{x9dx02x1axccx8bxd1Vxb2Fxff9xb0")%r(DNSVersionBindReq,18,"
SF:x01���x02���d?xe4{x9dx02x1axccx8bxd1Vxb2Fxff9xb0")%r(
SF:DNSStatusRequest,4,"x01���")%r(Help,4,"x01���")%r(X11Probe,4,"
SF:x01���")%r(FourOhFourRequest,18,"x01���x02���xb9x15&xf1A
SF:]+x11nxf6x9bxa0,xb0xe1xa5")%r(LPDString,4,"x01���")%r(LDAP
SF:BindReq,4,"x01���")%r(LANDesk-RC,18,"x01���x02���xb9x15&
SF:xf1A]+x11nxf6x9bxa0,xb0xe1xa5")%r(TerminalServer,4,"x01��
SF:0")%r(NCP,18,"x01���x02���xb9x15&xf1A]+x11nxf6x9bxa0,
SF:xb0xe1xa5")%r(NotesRPC,18,"x01���x02���xb9x15&xf1A]+x1
SF:1nxf6x9bxa0,xb0xe1xa5")%r(NessusTPv10,4,"x01���");
MAC Address: 00:90:4C:91:77:02 (Epigram)
Service Info: Host: routerku; Device: router

Service detection performed. Please report any incorrect results at
http://insecure.org/nmap/submit/ .

Nmap finished: 1 IP address (1 host up) scanned in 123.031 seconds
Raw packets sent: 1706 (75.062KB) | Rcvd: 1722 (79.450KB)

---------------------------------------------------------------------------

Dari hasil scanning tersebut dapat kita ambil kesimpulan, bahwa service dan
port yang aktif adalah FTP dalam versi MikroTik router ftpd 2.9.27. Untuk
SSH dengan versi OpenSSH 2.3.0 mikrotik 2.9.27 (protocol 1.99). Serta Web
proxy memakai Squid dalam versi Squid webproxy 2.5.STABLE11.

Tentu saja pihak vendor mikrotik telah melakukan patch terhadap Hole atau
Vulnerabilities dari Versi Protocol diatas.

--[11.2]-- Tool administrasi Jaringan

Secara praktis terdapat beberapa tool yang dapat dimanfaatkan dalam mela
kukan troubleshooting jaringan, seperti tool ping, traceroute, SSH, dll.
Beberapa tool yang sering digunakan nantinya dalam administrasi sehari-hari
adalah :

o Telnet
o SSH
o Traceroute
o Sniffer

a. Telnet
Perintah remote mesin ini hampir sama penggunaan dengan telnet yang ada
di Linux atau Windows.

[admin@routerku] > system telnet ?

Perintah diatas untuk melihat sekilias paramater apa saja yang ada. Misalnya
mesin remote dengan ip address 192.168.0.21 dan port 23. Maka

[admin@routerku] > system telnet 192.168.0.21

Penggunaan telnet sebaiknya dibatasi untuk kondisi tertentu dengan alasan
keamanan, seperti kita ketahui, packet data yang dikirim melalui telnet
belum di enskripsi. Agar lebih amannya kita pergunakan SSH.

b. SSH
Sama dengan telnet perintah ini juga diperlukan dalam remote mesin, serta
pringsipnya sama juga parameternya dengan perintah di Linux dan Windows.

[admin@routerku] > system ssh 192.168.0.21

Parameter SSH diatas, sedikit perbedaan dengan telnet. Jika lihat helpnya
memiliki parameter tambahan yaitu user.

------------------------------------------------------------------------------
[admin@routerku] > system ssh ?
The SSH feature can be used with various SSH Telnet clients to securely connect
to and administrate the router

--
user -- User name
port -- Port number

[admin@routerku] >
------------------------------------------------------------------------------

Misalkan kita akan melakukan remote pada suatu mesin dengan sistem
operasinya Linux, yang memiliki Account, username Root dan Password
123456 pada Address 66.213.7.30. Maka perintahnya,

-----------------------------------------------------------------------------
[admin@routerku] > system ssh 66.213.7.30 user=root
root@66.213.7.30's password:
----------------------------------------------------------------------------

c. Traceroute

Mengetahui hops atau router apa saja yang dilewati suatu packet sampai packet
itu terkirim ke tujuan, lazimnya kita menggunakan traceroute. Dengan tool ini
dapat di analisa kemana saja route dari jalannya packet.

Misalkan ingin mengetahui jalannya packet yang menuju server yahoo, maka:

----------------------------------------------------------------------------
[admin@routerku] > tool traceroute yahoo.com ADDRESS STATUS
1 63.219.6.nnn 00:00:00 00:00:00 00:00:00
2 222.124.4.nnn 00:00:00 00:00:00 00:00:00
3 192.168.34.41 00:00:00 00:00:00 00:00:00
4 61.94.1.253 00:00:00 00:00:00 00:00:00
5 203.208.143.173 00:00:00 00:00:00 00:00:00
6 203.208.182.5 00:00:00 00:00:00 00:00:00
7 203.208.182.114 00:00:00 00:00:00 00:00:00
8 203.208.168.118 00:00:00 00:00:00 00:00:00
9 203.208.168.134 timeout 00:00:00 00:00:00
10 216.115.101.34 00:00:00 timeout timeout
11 216.115.101.129 timeout timeout 00:00:00
12 216.115.108.1 timeout timeout 00:00:00
13 216.109.120.249 00:00:00 00:00:00 00:00:00
14 216.109.112.135 00:00:00 timeout timeout
------------------------------------------------------------------------------

d. Sniffer

Kita dapat menangkap dan menyadap packet-packet yang berjalan
di jaringan kita, tool ini telah disediakan oleh Mikrotik yang berguna
dalam menganalisa trafik.

----------------------------------------------------------------------------
[admin@routerku] > tool sniffer
Packet sniffering

.. -- go up to tool
start -- Start/reset sniffering
stop -- Stop sniffering
save -- Save currently sniffed packets
packet/ -- Sniffed packets management
protocol/ -- Protocol management
host/ -- Host management
connection/ -- Connection management
print --
get -- get value of property
set --
edit -- edit value of property
export --
----------------------------------------------------------------------------

Untuk memulai proses sniffing dapat menggunakan perintah Start, sedangkan
menghentikannya dapat menggunaka perintah Stop.

[admin@routerku] > tool sniffer start


Proses sniffing sedang dikerjakan, tunggu saja beberapa lama, kemudian
ketikkan perintah stop jika ingin menghentikannya. Melihat hasil packet
yang ditangkap dapat menggunakan perintah print, untuk mengeksportnya
dalam bentuk file dapat digunakan perintah export.


--[12]-- Kesimpulan

Untuk pemakaian jaringan berskala Kecil-menengah produk dari Latvia ini,
dapat menjadi pilihan, saya disini bukan untuk mempromosikan Produk ini.
Namun sebagai gambaran, bagaimana memanfaatkan produk ini untuk berbagai
keperluan, lagipula sebagai alternatif dari produk sejenis yang harganya
cenderung mahal.

Dengan Mikrotik yang saat ini sedang populernya diterapkan pada berbagai
ISP Wireless, Warnet-warnet serta beberapa Perusahaan. Maka Administrasi
Sistem Jaringan dapat lebih mudah dan sederhana. Yang jelas untuk sekedar
memanfaatkan fasilitas Routing saja, PC TUA anda dapat digunakan.

Mudah-mudahan paparan diatas dapat membantu pembaca dalam memahami, apa
dan bagaimana mikrotik ini.


--[13]-- Referensi

Artikel ini merupakan kompilasi dari berbagai sumber

1. Web Blog
- http://dhanis.web.id
- http://okawardhana.web.id
- http://harrychanputra.web.id

2. Website
- http://www.cgd.co.id
- http://www.ilmukomputer.org
- http://www.mikrotik.com
- http://www.mikrotik.co.id
- http://forum.mikrotik.com


oO Using no way as a way, Using no limitations as a limitation Oo

Salam dan terimakasih,
r0t0r
-----------------------------------------------------------------------
Copyleft Unreserved by Law 1995 - 2007 Kecoak Elektronik Indonesia
http://www.kecoak-elektronik.net

.L.A.M.P.I.R.A.N.

Daftar Port dan Protocol berbagai jenis Trojan, Backdoor, Virus.
daftar ini dapat saja tidak berlaku, atau dapat pula perlu ditambah
seiring perkembangan Malware tersebut. Update terus Filter Rule
mesin mikrotik anda.
########## Pembatasan Brute Force #################################
/ ip firewall filter
add chain=input protocol=tcp dst-port=22 connection-limit=1,32
action=add-src-to-address-list address-list=ssh_logins
address-list-timeout=2m comment="" disabled=no
add chain=input protocol=tcp dst-port=22 src-address-list=!ssh_logins
action=accept comment="" disabled=no
add chain=forward src-address=192.168.1.10 protocol=tcp src-port=21
content="password incorrect" action=add-dst-to-address-list
address-list=ftp_logins address-list-timeout=1m comment="" disabled=no
add chain=forward src-address-list=ftp_logins action=drop comment="" disabled=no
########################################################################

Pemblokiran beberapa URL tertentu dapat dilakukan pada mikrotik.
Jika paket web-proxy telah terinstall dan web-proxynya juga telah
dikonfigurasi, maka perintah dibawah ini dapat disertakan.

Rabu, 09 April 2008

Tutorial Step By Step Seting MikroTik

MikroTik RouterOS™ adalah sistem operasi linux yang dapat digunakan untuk menjadikan komputer menjadi router network yang handal, mencakup berbagai fitur yang dibuat untuk ip network dan jaringan wireless, cocok digunakan oleh ISP dan provider hostspot.

Ada pun fitur2 nya sbb:

* Firewall and NAT - stateful packet filtering; Peer-to-Peer protocol filtering; source and destination NAT; classification by source MAC, IP addresses (networks or a list of networks) and address types, port range, IP protocols, protocol options (ICMP type, TCP flags and MSS), interfaces, internal packet and connection marks, ToS (DSCP) byte, content, matching sequence/frequency, packet size, time and more…

* Routing - Static routing; Equal cost multi-path routing; Policy based routing (classification done in firewall); RIP v1 / v2, OSPF v2, BGP v4

* Data Rate Management - Hierarchical HTB QoS system with bursts; per IP / protocol / subnet / port / firewall mark; PCQ, RED, SFQ, FIFO queue; CIR, MIR, contention ratios, dynamic client rate equalizing (PCQ), bursts, Peer-to-Peer protocol limitation

* HotSpot - HotSpot Gateway with RADIUS authentication and accounting; true Plug-and-Play access for network users; data rate limitation; differentiated firewall; traffic quota; real-time status information; walled-garden; customized HTML login pages; iPass support; SSL secure authentication; advertisement support

* Point-to-Point tunneling protocols - PPTP, PPPoE and L2TP Access Concentrators and clients; PAP, CHAP, MSCHAPv1 and MSCHAPv2 authentication protocols; RADIUS authentication and accounting; MPPE encryption; compression for PPPoE; data rate limitation; differentiated firewall; PPPoE dial on demand

* Simple tunnels - IPIP tunnels, EoIP (Ethernet over IP)

* IPsec - IP security AH and ESP protocols; MODP Diffie-Hellman groups 1,2,5; MD5 and SHA1 hashing algorithms; DES, 3DES, AES-128, AES-192, AES-256 encryption algorithms; Perfect Forwarding Secrecy (PFS) MODP groups 1,2,5

* Proxy - FTP and HTTP caching proxy server; HTTPS proxy; transparent DNS and HTTP proxying; SOCKS protocol support; DNS static entries; support for caching on a separate drive; access control lists; caching lists; parent proxy support

* DHCP - DHCP server per interface; DHCP relay; DHCP client; multiple DHCP networks; static and dynamic DHCP leases; RADIUS support

* VRRP - VRRP protocol for high availability

* UPnP - Universal Plug-and-Play support

* NTP - Network Time Protocol server and client; synchronization with
GPS system

* Monitoring/Accounting - IP traffic accounting, firewall actions logging, statistics graphs accessible via HTTP

* SNMP - read-only access

* M3P - MikroTik Packet Packer Protocol for Wireless links and Ethernet

* MNDP - MikroTik Neighbor Discovery Protocol; also supports Cisco Discovery Protocol (CDP)

* Tools - ping; traceroute; bandwidth test; ping flood; telnet; SSH; packet sniffer; Dynamic DNS update tool

Layer 2 connectivity:

* Wireless - IEEE802.11a/b/g wireless client and access point (AP) modes; Nstreme and Nstreme2 proprietary protocols; Wireless Distribution System (WDS) support; virtual AP; 40 and 104 bit WEP; WPA pre-shared key authentication; access control list; authentication with RADIUS server; roaming (for wireless client); AP bridging

* Bridge - spanning tree protocol; multiple bridge interfaces; bridge firewalling, MAC

* VLAN - IEEE802.1q Virtual LAN support on Ethernet and wireless links; multiple VLANs; VLAN bridging

* Synchronous - V.35, V.24, E1/T1, X.21, DS3 (T3) media types; sync-PPP, Cisco HDLC, Frame Relay line protocols; ANSI-617d (ANDI or annex D) and Q933a (CCITT or annex A) Frame Relay LMI types

* Asynchronous - s*r*al PPP dial-in / dial-out; PAP, CHAP, MSCHAPv1 and MSCHAPv2 authentication protocols; RADIUS authentication and accounting; onboard s*r*al ports; modem pool with up to 128 ports; dial on demand

* ISDN - ISDN dial-in / dial-out; PAP, CHAP, MSCHAPv1 and MSCHAPv2 authentication protocols; RADIUS authentication and accounting; 128K bundle support; Cisco HDLC, x75i, x75ui, x75bui line protocols; dial on demand

* SDSL - Single-line DSL support; line termination and network termination modes

Instalasi dapat dilakukan pada Standard computer PC yang akan dijadikan router dan tidak memerlukan resource yang cukup besar untuk penggunaan standard, misalnya hanya sebagai gateway.

Berikut spec_minimal nya :

* CPU dan motherboard - bisa dgn P1 ~ P4, AMD, cyrix asal yang bukan multi-prosesor

* RAM - minimum 32 MiB, maximum 1 GiB; 64 MiB atau lebih sangat dianjurkan, kalau mau sekalian dibuat proxy , dianjurkan 1GB… perbandingannya, 15MB di memori ada 1GB di proxy..

* HDD minimal 128MB parallel ATA atau Compact Flash, tidak dianjurkan menggunakan UFD, SCSI, apa lagi S-ATA (mungkin nanti Ver. 3.0)

* NIC 10/100 atau 100/1000

Untuk keperluan beban yang besar ( network yang kompleks, routing yang rumit dll) disarankan untuk mempertimbangkan pemilihan resource PC yang memadai.

Lebih lengkap bisa dilihat di www.mikrotik.com. Meskipun demikian Mikrotik bukanlah free software, artinya kita harus membeli licensi terhadap segala fasiltas yang disediakan. Free trial hanya untuk 24 jam saja.

Kita bisa membeli software MikroTik dalam bentuk “licence” di CITRAWEB, UFOAKSES, PC24 (atau download cracknya, he he he …) yang diinstall pada HardDisk yang sebelumnya download/dibuat MikroTik RouterOS ISO kekeping CD atau disk on module (DOM). Jika kita membeli DOM tidak perlu install tetapi tinggal pasang DOM pada slot IDE PC kita.

Langkah-langkah berikut adalah dasar-dasar setup mikrotik yang dikonfigurasikan untuk jaringan
sederhana sebagai gateway server.

1. Langkah pertama adalah install Mikrotik RouterOS pada PC atau pasang DOM.

2. Login Pada Mikrotik Routers melalui console :

MikroTik v2.9.39

Login: admin

Password: (kosongkan)

Sampai langkah ini kita sudah bisa masuk pada mesin Mikrotik. User default adalah admin dan tanpa password, tinggal ketik admin kemudian tekan tombol enter.

3. Untuk keamanan ganti password default

[admin@Mikrotik] > password

old password: *****

new password: *****

retype new password: *****

[admin@ Mikrotik] >

4. Mengganti nama Mikrotik Router, pada langkah ini nama server akan kita ganti menjadi
“r-WLI” (bebas, disesuaikan dengan nama jaringan kita…)

[admin@Mikrotik] > system identity set name=r-WLI

[admin@r-WLI] >

5. Melihat interface pada Mikrotik Router

[admin@r-WLI] > interface print

Flags: X - disabled, D - dynamic, R - running

# NAME TYPE RX-RATE TX-RATE MTU

0 R ether1 ether 0 0 1500

1 R ether2 ether 0 0 1500

[admin@r-WLI] >

6. Memberikan IP address pada interface Mikrotik. Misalkan ether1 akan kita gunakan untuk koneksi ke Internet dengan IP 192.168.0.1 dan ether2 akan kita gunakan untuk network local kita dengan IP 172.16.0.1

[admin@r-WLI] > ip address add address=192.168.0.1 /

netmask=255.255.255.0 interface=ether1

[admin@r-WLI] > ip address add address=172.16.0.1 /

netmask=255.255.255.0 interface=ether2

7. Melihat konfigurasi IP address yang sudah kita berikan

[admin@r-WLI] >ip address print

Flags: X - disabled, I - invalid, D - dynamic

# ADDRESS NETWORK BROADCAST INTERFACE

0 192.168.0.1/24 192.168.0.0 192.168.0.63 ether1

1 172.16.0.1/24 172.16.0.0 172.16.0.255 ether2

[admin@r-WLI] >

8. Memberikan default Gateway, diasumsikan gateway untuk koneksi internet adalah 192.168.0.254

[admin@r-WLI] > /ip route add gateway=192.168.0.254

9. Melihat Tabel routing pada Mikrotik Routers

[admin@r-WLI] > ip route print

Flags: X - disabled, A - active, D - dynamic,

C - connect, S - static, r - rip, b - bgp, o - ospf

# DST-ADDRESS PREF-SRC G GATEWAY DISTANCE INTERFACE

0 ADC 172.16.0.0/24 172.16.0.1 ether2

1 ADC 192.168.0.0/26 192.168.0.1 ether1

2 A S 0.0.0.0/0 r 192.168.0.254 ether1

[admin@r-WLI] >

10. Tes Ping ke Gateway untuk memastikan konfigurasi sudah benar

[admin@r-WLI] > ping 192.168.0.254

192.168.0.254 64 byte ping: ttl=64 time

11. Setup DNS pada Mikrotik Routers

[admin@r-WLI] > ip dns set primary-dns=192.168.0.10 /

allow-remoterequests=no

[admin@r-WLI] > ip dns set secondary-dns=192.168.0.11 /

allow-remoterequests=no

12. Melihat konfigurasi DNS

[admin@r-WLI] ip dns> pr

primary-dns: 192.168.0.10

secondary-dns: 192.168.0.11

allow-remote-requests: no

cache-size: 2048KiB

cache-max-ttl: 1w

cache-used: 21KiB

[admin@r-WLI] ip dns>

13. Tes untuk akses domain, misalnya dengan ping nama domain

[admin@r-WLI] > ping yahoo.com

216.109.112.135 64 byte ping: ttl=48 time=250 ms
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 571/571.0/571 ms
[admin@r-WLI] >

Jika sudah berhasil reply berarti seting DNS sudah benar.

14. Setup Masquerading, Jika Mikrotik akan kita pergunakan sebagai gateway server maka agar client computer pada network dapat terkoneksi ke internet perlu kita masquerading.

[admin@r-WLI]> ip firewall nat add action=masquerade /

outinterface=ether1 chain:srcnat

[admin@r-WLI] >

15. Melihat konfigurasi Masquerading

[admin@r-WLI]ip firewall nat print

Flags: X - disabled, I - invalid, D - dynamic

0 chain=srcnat out-interface=ether1 action=masquerade

[admin@r-WLI] >

Setelah langkah ini bisa dilakukan pemeriksaan untuk koneksi dari jaringan local. Dan jika berhasil berarti kita sudah berhasil melakukan instalasi MikroTik Router sebagai Gateway server. Setelah terkoneksi dengan jaringan Mikrotik dapat dimanage menggunakan WinBox yang bisa didownload dari MikroTik.com atau dari server mikrotik kita.

Misal Ip address server mikrotik kita 192.168.0.1, via browser buka http://192.168.0.1 dan download WinBox dari situ.
Jika kita menginginkan client mendapatkan IP address secara otomatis maka perlu kita setup dhcp server pada Mikrotik. Berikut langkah-langkahnya :

1. Buat IP address pool
/ip pool add name=dhcp-pool ranges=172.16.0.10-172.16.0.20

2. Tambahkan DHCP Network dan gatewaynya yang akan didistribusikan ke client Pada contoh ini networknya adalah 172.16.0.0/24 dan gatewaynya 172.16.0.1
/ip dhcp-server network add address=172.16.0.0/24 gateway=172.16.0.1

3. Tambahkan DHCP Server ( pada contoh ini dhcp diterapkan pada interface ether2 )
/ip dhcp-server add interface=ether2 address-pool=dhcp-pool

4. Lihat status DHCP server

[admin@r-WLI] > ip dhcp-server pr

Flags: X - disabled, I - invalid

# NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP

x dhcp1 ether2 dhcp_pool1 4w2d yes

[admin@r-WLI] >

Tanda X menyatakan bahwa DHCP server belum enable maka perlu dienablekan terlebih dahulu pada langkah 5.

5. Jangan Lupa dibuat enable dulu dhcp servernya
/ip dhcp-server enable 0

Kemudian cek kembali dhcp-server seperti langkah 4, jika tanda X sudah tidak ada berarti sudah aktif.

6. Tes Dari client

Run dari Comman Prompt

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\EsDat>ping www.yahoo.com

Pinging www.yahoo-ht3.akadns.net [69.147.114.210] with 32 bytes of data:

Reply from 124.158.129.5: bytes=32 time=34ms TTL=59
Reply from 124.158.129.5: bytes=32 time=24ms TTL=59
Reply from 124.158.129.5: bytes=32 time=41ms TTL=59
Reply from 124.158.129.5: bytes=32 time=29ms TTL=59

Ping statistics for 69.147.114.210:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 24ms, Maximum = 41ms, Average = 32ms

7. Untuk bandwith controller, bisa dengan sistem simple queue ataupun bisa dengan mangle

[admin@r-WLI] queue simple> add name=Komputer01 /

interface=ether2 target-address=172.16.0.1/24 max-limit=65536/131072

[admin@r-WLI] queue simple> add name=Komputer02 /

interface=ether2 target-address=172.16.0.2/24 max-limit=65536/131072

dan seterusnya…

14 langkah instalasi miktotik pakai speedy

/ip address add interface=ether1 address = 192.168.1.1 netmask= 255.255.255.0
/ip address add interface=ether2 address = 192.168.0.1 netmask= 255.255.255.0
/interface print
/inteface set 0 name=”Public”
/inteface set 1 name=”Lan”
/ip route add gateway=192.168.0.1
/ip dns set primary-dns=203.130.193.74 secondary-dns=202.134.0.155
/ip dns set allow-remote-requests=yes
/ip firewall nat add chain=srcnat out-inteface=Public action=masquerade
/ip firewall nat add chain=dstnat protocol=tcp dst-port=80 action=redirect to-ports=8080
/ip firewall nat add chain=dstnat protocol=tcp dst-port=3128 action=redirect to-ports=8080
/ip firewall nat add chain=dstnat protocol=tcp dst-port=8080 action=redirect to-ports=8080
/ip pool add name=”dhcp-pool” ranges=192.168.0.1-192.168.0.29
/ip dhcp-server add name=”dhcp1″ inteface=LAN address-pool=”dhcp-pool” lease-time=3d
/ip dns set allow-remote-requests=yes
/ip firewall nat add chain=srcnat out-inteface=Public action=masquerade
/ip firewall nat add chain=dstnat protocol=tcp dst-port=80 action=redirect to-ports=8080
/ip firewall nat add chain=dstnat protocol=tcp dst-port=3128 action=redirect to-ports=8080
/ip firewall nat add chain=dstnat protocol=tcp dst-port=8080 action=redirect to-ports=8080

Selasa, 08 April 2008

Filter

General Information
Summary

The firewall implements packet filtering and thereby provides security functions that are used to manage data flow to, from and through the router. Along with the Network Address Translation it serve as a tool for preventing unauthorized access to directly attached networks and the router itself as well as a filter for outgoing traffic.
Quick Setup Guide

To add a firewall rule which drops all TCP packets that are destined to port 135 and going through the router, use the following command:
/ip firewall filter add chain=forward dst-port=135 protocol=tcp action=drop

To deny acces to the router via Telnet (protocol TCP, port 23), type the following command:
/ip firewall filter add chain=input protocol=tcp dst-port=23 action=drop

To only allow not more than 5 simultaneous connections from each of the clients, do the following:
/ip firewall filter add chain=forward protocol=tcp tcp-flags=syn connection-limit=6,32 action=drop
Specifications
Packages required: system
License required: Level1 (P2P filters limited to 1) , Level3
Submenu level: /ip firewall filter
Standards and Technologies: IP, RFC2113
Hardware usage: Increases with filtering rules count
Firewall Filter
Submenu level: /ip firewall filter
Description

Network firewalls keep outside threats away from sensitive data available inside the network. Whenever different networks are joined together, there is always a threat that someone from outside of your network will break into your LAN. Such break-ins may result in private data being stolen and distributed, valuable data being altered or destroyed, or entire hard drives being erased. Firewalls are used as a means of preventing or minimizing the security risks inherent in connecting to other networks. Properly configured firewall plays a key role in efficient and secure network infrastrure deployment.

MikroTik RouterOS has very powerful firewall implementation with features including:
stateful packet inspection
Layer-7 protocol detection
peer-to-peer protocols filtering
traffic classification by:
source MAC address
IP addresses (network or list) and address types (broadcast, local, multicast, unicast)
port or port range
IP protocols
protocol options (ICMP type and code fields, TCP flags, IP options and MSS)
interface the packet arrived from or left through
internal flow and connection marks
DSCP byte
packet content
rate at which packets arrive and sequence numbers
packet size
packet arrival time
and much more!
General Filtering Principles

The firewall operates by means of firewall rules. A rule is a definitive form expression that tells the router what to do with a particular IP packet. Each rule consists of two parts that are the matcher which matches traffic flow against given conditions and the action which defines what to do with the mathched packets. Rules are organized in chains for better management.

The filter facility has three default chains: input, forward and output that are responsible for traffic coming from, throurh and to the router, respectively. New user-defined chains can be added, as necessary. Since these chains have no default traffic to match, rules with action=jump and relevant jump-target should be added to one or more of the three default chains.
Filter Chains

As mentioned before, the firewall filtering rules are grouped together in chains. It allows a packet to be matched against one common criterion in one chain, and then passed over for processing against some other common criteria to another chain. For example a packet should be matched against the IP address:port pair. Of course, it could be achieved by adding as many rules with IP address:port match as required to the forward chain, but a better way could be to add one rule that matches traffic from a particular IP address, e.g.: /ip firewall filter add src-address=1.1.1.2/32 jump-target="mychain" and in case of successfull match passes control over the IP packet to some other chain, id est mychain in this example. Then rules that perform matching against separate ports can be added to mychain chain without specifying the IP addresses.

There are three predefined chains, which cannot be deleted:
input - used to process packets entering the router through one of the interfaces with the destination IP address which is one of the router's addresses. Packets passing through the router are not processed against the rules of the input chain
forward - used to process packets passing through the router
output - used to process packets originated from the router and leaving it through one of the interfaces. Packets passing through the router are not processed against the rules of the output chain

When processing a chain, rules are taken from the chain in the order they are listed there from top to bottom. If a packet matches the criteria of the rule, then the specified action is performed on it, and no more rules are processed in that chain (the exception is the passthrough action). If a packet has not matched any rule within the chain, then it is accepted.
Property Description
action (accept | add-dst-to-address-list | add-src-to-address-list | drop | jump | log | passthrough | reject | return | tarpit; default: accept) - action to undertake if the packet matches the ruleaccept - accept the packet. No action is taken, i.e. the packet is passed through and no more rules are applied to it
add-dst-to-address-list - adds destination address of an IP packet to the address list specified by address-list parameter
add-src-to-address-list - adds source address of an IP packet to the address list specified by address-list parameter
drop - silently drop the packet (without sending the ICMP reject message)
jump - jump to the chain specified by the value of the jump-target parameter
log - each match with this action will add a message to the system log
passthrough - ignores this rule and goes on to the next one
reject - reject the packet and send an ICMP reject message
return - passes control back to the chain from where the jump took place
tarpit - captures and holds incoming TCP connections (replies with SYN/ACK to the inbound TCP SYN packet)
accept - accept the packet. No action is taken, i.e. the packet is passed through and no more rules are applied to it
add-dst-to-address-list - adds destination address of an IP packet to the address list specified by address-list parameter
add-src-to-address-list - adds source address of an IP packet to the address list specified by address-list parameter
drop - silently drop the packet (without sending the ICMP reject message)
jump - jump to the chain specified by the value of the jump-target parameter
log - each match with this action will add a message to the system log
passthrough - ignores this rule and goes on to the next one
reject - reject the packet and send an ICMP reject message
return - passes control back to the chain from where the jump took place
tarpit - captures and holds incoming TCP connections (replies with SYN/ACK to the inbound TCP SYN packet)

address-list (name) - specifies the name of the address list to collect IP addresses from rules having action=add-dst-to-address-list or action=add-src-to-address-list actions. These address lists could be later used for packet matching

address-list-timeout (time; default: 00:00:00) - time interval after which the address will be removed from the address list specified by address-list parameter. Used in conjunction with add-dst-to-address-list or add-src-to-address-list actions00:00:00 - leave the address in the address list forever
00:00:00 - leave the address in the address list forever

chain (forward | input | output | name) - specifies the chain to put a particular rule into. As the different traffic is passed through different chains, always be careful in choosing the right chain for a new rule. If the input does not match the name of an already defined chain, a new chain will be created

comment (text) - a descriptive comment for the rule. A comment can be used to identify rules form scripts

connection-bytes (integer-integer) - matches packets only if a given amount of bytes has been transfered through the particular connection0 - means infinity, exempli gratia: connection-bytes=2000000-0 means that the rule matches if more than 2MB has been transfered through the relevant connection
0 - means infinity, exempli gratia: connection-bytes=2000000-0 means that the rule matches if more than 2MB has been transfered through the relevant connection

connection-limit (integer,netmask) - restrict connection limit per address or address block

connection-mark (name) - matches packets marked via mangle facility with particular connection mark

connection-state (estabilished | invalid | new | related) - interprets the connection tracking analysis data for a particular packetestabilished - a packet which belongs to an existing connection, exempli gratia a reply packet or a packet which belongs to already replied connection
invalid - a packet which could not be identified for some reason. This includes out of memory condition and ICMP errors which do not correspond to any known connection. It is generally advised to drop these packets
new - a packet which begins a new TCP connection
related - a packet which is related to, but not part of an existing connection, such as ICMP errors or a packet which begins FTP data connection (the later requires enabled FTP connection tracking helper under /ip firewall service-port)
estabilished - a packet which belongs to an existing connection, exempli gratia a reply packet or a packet which belongs to already replied connection
invalid - a packet which could not be identified for some reason. This includes out of memory condition and ICMP errors which do not correspond to any known connection. It is generally advised to drop these packets
new - a packet which begins a new TCP connection
related - a packet which is related to, but not part of an existing connection, such as ICMP errors or a packet which begins FTP data connection (the later requires enabled FTP connection tracking helper under /ip firewall service-port)

connection-type (ftp | gre | h323 | irc | mms | pptp | quake3 | tftp) - matches packets from related connections based on information from their connection tracking helpers. A relevant connection helper must be enabled under /ip firewall service-port

content (text) - the text packets should contain in order to match the rule

dscp (integer: 0..63) - DSCP (ex-ToS) IP header field value

dst-address (IP address/netmask | IP address-IP address) - specifies the address range an IP packet is destined to. Note that console converts entered address/netmask value to a valid network address, i.e.:1.1.1.1/24 is converted to 1.1.1.0/24

dst-address-list (name) - matches destination address of a packet against user-defined address list

dst-address-type (unicast | local | broadcast | multicast) - matches destination address type of the IP packet, one of the:unicast - IP addresses used for one point to another point transmission. There is only one sender and one receiver in this case
local - matches addresses assigned to router's interfaces
broadcast - the IP packet is sent from one point to all other points in the IP subnetwork
multicast - this type of IP addressing is responsible for transmission from one or more points to a set of other points
unicast - IP addresses used for one point to another point transmission. There is only one sender and one receiver in this case
local - matches addresses assigned to router's interfaces
broadcast - the IP packet is sent from one point to all other points in the IP subnetwork
multicast - this type of IP addressing is responsible for transmission from one or more points to a set of other points

dst-limit (integer/time{0,1},integer,dst-address | dst-port | src-address{+},time{0,1}) - limits the packet per second (pps) rate on a per destination IP or per destination port base. As opposed to the limit match, every destination IP address / destination port has it's own limit. The options are as follows (in order of appearance):count - maximum average packet rate, measured in packets per second (pps), unless followed by time option
time - specifies the time interval over which the packet rate is measured
burst - number of packets to match in a burst
mode - the classifier(-s) for packet rate limiting
expire - specifies interval after which recorded IP addresses / ports will be deleted
count - maximum average packet rate, measured in packets per second (pps), unless followed by time option
time - specifies the time interval over which the packet rate is measured
burst - number of packets to match in a burst
mode - the classifier(-s) for packet rate limiting
expire - specifies interval after which recorded IP addresses / ports will be deleted

dst-port (integer: 0..65535-integer: 0..65535{*}) - destination port number or range

fragment (yes | no) - whether the packet is a fragment of an IP packet. Starting packet (i.e., first fragment) does not count. Note that is the connection tracking is enabled, there will be no fragments as the system automatically assembles every packet

hotspot (multiple choice: auth | from-client | http | local-dst | to-client) - matches packets received from clients against various HotSpot conditions. All values can be negatedauth - true, if a packet comes from an authenticted HotSpotclient
from-client - true, if a packet comes from any HotSpot client
http - true, if a HotSpot client sends a packet to the address and port previously detected as his proxy server (Universal Proxy technique) or if the destination port is 80 and transparent proxying is enabled for that particular client
local-dst - true, if a packet has local destination IP address
to-client - true, if a packet is sent to a client
auth - true, if a packet comes from an authenticted HotSpotclient
from-client - true, if a packet comes from any HotSpot client
http - true, if a HotSpot client sends a packet to the address and port previously detected as his proxy server (Universal Proxy technique) or if the destination port is 80 and transparent proxying is enabled for that particular client
local-dst - true, if a packet has local destination IP address
to-client - true, if a packet is sent to a client

icmp-options (integer:integer) - matches ICMP Type:Code fields

in-bridge-port (name) - actual interface the packet has entered the router through (if bridged, this property matches the actual bridge port, while in-interface - the bridge itself)

in-interface (name) - interface the packet has entered the router through (if the interface is bridged, then the packet will appear to come from the bridge interface itself)

ingress-priority (integer: 0..63) - INGRESS (received) priority of the packet, if set (0 otherwise). The priority may be derived from either VLAN or WMM priority

ipv4-options (any | loose-source-routing | no-record-route | no-router-alert | no-source-routing | no-timestamp | none | record-route | router-alert | strict-source-routing | timestamp) - match ipv4 header optionsany - match packet with at least one of the ipv4 options
loose-source-routing - match packets with loose source routing option. This option is used to route the internet datagram based on information supplied by the source
no-record-route - match packets with no record route option. This option is used to route the internet datagram based on information supplied by the source
no-router-alert - match packets with no router alter option
no-source-routing - match packets with no source routing option
no-timestamp - match packets with no timestamp option
record-route - match packets with record route option
router-alert - match packets with router alter option
strict-source-routing - match packets with strict source routing option
timestamp - match packets with timestamp
any - match packet with at least one of the ipv4 options
loose-source-routing - match packets with loose source routing option. This option is used to route the internet datagram based on information supplied by the source
no-record-route - match packets with no record route option. This option is used to route the internet datagram based on information supplied by the source
no-router-alert - match packets with no router alter option
no-source-routing - match packets with no source routing option
no-timestamp - match packets with no timestamp option
record-route - match packets with record route option
router-alert - match packets with router alter option
strict-source-routing - match packets with strict source routing option
timestamp - match packets with timestamp

jump-target (forward | input | output | name) - name of the target chain to jump to, if the action=jump is used

layer7-protocol (name) - Layer 7 filter name as set in the /ip firewall layer7-protocol menu. Caution: this matcher needs high computational power

limit (integer/time{0,1},integer) - restricts packet match rate to a given limit. Usefull to reduce the amount of log messagescount - maximum average packet rate, measured in packets per second (pps), unless followed by time option
time - specifies the time interval over which the packet rate is measured
burst - number of packets to match in a burst
count - maximum average packet rate, measured in packets per second (pps), unless followed by time option
time - specifies the time interval over which the packet rate is measured
burst - number of packets to match in a burst

log-prefix (text) - all messages written to logs will contain the prefix specified herein. Used in conjunction with action=log

nth (integer,integer: 0..15,integer{0,1}) - match a particular Nth packet received by the rule. One of 16 available counters can be used to count packetsevery - match every every+1th packet. For example, if every=1 then the rule matches every 2nd packet
counter - specifies which counter to use. A counter increments each time the rule containing nth match matches
packet - match on the given packet number. The value by obvious reasons must be between 0 and every. If this option is used for a given counter, then there must be at least every+1 rules with this option, covering all values between 0 and every inclusively.
every - match every every+1th packet. For example, if every=1 then the rule matches every 2nd packet
counter - specifies which counter to use. A counter increments each time the rule containing nth match matches
packet - match on the given packet number. The value by obvious reasons must be between 0 and every. If this option is used for a given counter, then there must be at least every+1 rules with this option, covering all values between 0 and every inclusively.

out-bridge-port (name) - actual interface the packet is leaving the router through (if bridged, this property matches the actual bridge port, while out-interface - the bridge itself)

out-interface (name) - interface the packet is leaving the router through (if the interface is bridged, then the packet will appear to leave through the bridge interface itself)

p2p (all-p2p | bit-torrent | blubster | direct-connect | edonkey | fasttrack | gnutella | soulseek | warez | winmx) - matches packets from various peer-to-peer (P2P) protocols

packet-mark (text) - matches packets marked via mangle facility with particular packet mark

packet-size (integer: 0..65535-integer: 0..65535{0,1}) - matches packet of the specified size or size range in bytesmin - specifies lower boundary of the size range or a standalone value
max - specifies upper boundary of the size range
min - specifies lower boundary of the size range or a standalone value
max - specifies upper boundary of the size range

port (port{0-16}) - matches if any (source or destination) port matches the specified list of ports or port ranges (note that the protocol must still be selected, just like for the regular src-port and dst-port matchers)

protocol (ddp | egp | encap | ggp | gre | hmp | icmp | idrp-cmtp | igmp | ipencap | ipip | ipsec-ah | ipsec-esp | iso-tp4 | ospf | pup | rdp | rspf | st | tcp | udp | vmtp | xns-idp | xtp | integer) - matches particular IP protocol specified by protocol name or number. You should specify this setting if you want to specify ports

psd (integer,time,integer,integer) - attempts to detect TCP and UDP scans. It is advised to assign lower weight to ports with high numbers to reduce the frequency of false positives, such as from passive mode FTP transfersWeightThreshold - total weight of the latest TCP/UDP packets with different destination ports coming from the same host to be treated as port scan sequence
DelayThreshold - delay for the packets with different destination ports coming from the same host to be treated as possible port scan subsequence
LowPortWeight - weight of the packets with privileged (<=1024) destination port
HighPortWeight - weight of the packet with non-priviliged destination port
WeightThreshold - total weight of the latest TCP/UDP packets with different destination ports coming from the same host to be treated as port scan sequence
DelayThreshold - delay for the packets with different destination ports coming from the same host to be treated as possible port scan subsequence
LowPortWeight - weight of the packets with privileged (<=1024) destination port
HighPortWeight - weight of the packet with non-priviliged destination port

random (integer: 1..99) - matches packets randomly with given propability

reject-with (icmp-admin-prohibited | icmp-echo-reply | icmp-host-prohibited | icmp-host-unreachable | icmp-net-prohibited | icmp-network-unreachable | icmp-port-unreachable | icmp-protocol-unreachable | tcp-reset | integer) - alters the reply packet of reject action

routing-mark (name) - matches packets marked by mangle facility with particular routing mark

src-address (IP address/netmask | IP address-IP address) - specifies the address range an IP packet is originated from. Note that console converts entered address/netmask value to a valid network address, i.e.:1.1.1.1/24 is converted to 1.1.1.0/24

src-address-list (name) - matches source address of a packet against user-defined address list

src-address-type (unicast | local | broadcast | multicast) - matches source address type of the IP packet, one of the:unicast - IP addresses used for one point to another point transmission. There is only one sender and one receiver in this case
local - matches addresses assigned to router's interfaces
broadcast - the IP packet is sent from one point to all other points in the IP subnetwork
multicast - this type of IP addressing is responsible for transmission from one or more points to a set of other points
unicast - IP addresses used for one point to another point transmission. There is only one sender and one receiver in this case
local - matches addresses assigned to router's interfaces
broadcast - the IP packet is sent from one point to all other points in the IP subnetwork
multicast - this type of IP addressing is responsible for transmission from one or more points to a set of other points

src-mac-address (MAC address) - source MAC address

src-port (integer: 0..65535-integer: 0..65535{*}) - source port number or range

tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg) - tcp flags to matchack - acknowledging data
cwr - congestion window reduced
ece - ECN-echo flag (explicit congestion notification)
fin - close connection
psh - push function
rst - drop connection
syn - new connection
urg - urgent data
ack - acknowledging data
cwr - congestion window reduced
ece - ECN-echo flag (explicit congestion notification)
fin - close connection
psh - push function
rst - drop connection
syn - new connection
urg - urgent data

tcp-mss (integer: 0..65535) - matches TCP MSS value of an IP packet

time (time-time,sat | fri | thu | wed | tue | mon | sun{+}) - allows to create filter based on the packets' arrival time and date or, for locally generated packets, departure time and date

Notes

Because the NAT rules are applied first, it is important to hold this in mind when setting up firewall rules, since the original packets might be already modified by the NAT
Filter Applications
Protect your RouterOS router

To protect your router, you should not only change admin's password but also set up packet filtering. All packets with destination to the router are processed against the ip firewall input chain. Note, that the input chain does not affect packets which are being transferred through the router.
/ ip firewall filter
add chain=input connection-state=invalid action=drop \
comment="Drop Invalid connections"
add chain=input connection-state=established action=accept \
comment="Allow Established connections"
add chain=input protocol=udp action=accept \
comment="Allow UDP"
add chain=input protocol=icmp action=accept \
comment="Allow ICMP"
add chain=input src-address=192.168.0.0/24 action=accept \
comment="Allow access to router from known network"
add chain=input action=drop comment="Drop anything else"

Protecting the Customer's Network

To protect the customer's network, we should check all traffic which goes through router and block unwanted. For icmp, tcp, udp traffic we will create chains, where will be droped all unwanted packets:
/ip firewall filter
add chain=forward protocol=tcp connection-state=invalid \
action=drop comment="drop invalid connections"
add chain=forward connection-state=established action=accept \
comment="allow already established connections"
add chain=forward connection-state=related action=accept \
comment="allow related connections"


Block IP addreses called "bogons":
add chain=forward src-address=0.0.0.0/8 action=drop
add chain=forward dst-address=0.0.0.0/8 action=drop
add chain=forward src-address=127.0.0.0/8 action=drop
add chain=forward dst-address=127.0.0.0/8 action=drop
add chain=forward src-address=224.0.0.0/3 action=drop
add chain=forward dst-address=224.0.0.0/3 action=drop


Make jumps to new chains:
add chain=forward protocol=tcp action=jump jump-target=tcp
add chain=forward protocol=udp action=jump jump-target=udp
add chain=forward protocol=icmp action=jump jump-target=icmp


Create tcp chain and deny some tcp ports in it:
add chain=tcp protocol=tcp dst-port=69 action=drop \
comment="deny TFTP"
add chain=tcp protocol=tcp dst-port=111 action=drop \
comment="deny RPC portmapper"
add chain=tcp protocol=tcp dst-port=135 action=drop \
comment="deny RPC portmapper"
add chain=tcp protocol=tcp dst-port=137-139 action=drop \
comment="deny NBT"
add chain=tcp protocol=tcp dst-port=445 action=drop \
comment="deny cifs"
add chain=tcp protocol=tcp dst-port=2049 action=drop comment="deny NFS"
add chain=tcp protocol=tcp dst-port=12345-12346 action=drop comment="deny NetBus"
add chain=tcp protocol=tcp dst-port=20034 action=drop comment="deny NetBus"
add chain=tcp protocol=tcp dst-port=3133 action=drop comment="deny BackOriffice"
add chain=tcp protocol=tcp dst-port=67-68 action=drop comment="deny DHCP"


Deny udp ports in udp chain:
add chain=udp protocol=udp dst-port=69 action=drop comment="deny TFTP"
add chain=udp protocol=udp dst-port=111 action=drop comment="deny PRC portmapper"
add chain=udp protocol=udp dst-port=135 action=drop comment="deny PRC portmapper"
add chain=udp protocol=udp dst-port=137-139 action=drop comment="deny NBT"
add chain=udp protocol=udp dst-port=2049 action=drop comment="deny NFS"
add chain=udp protocol=udp dst-port=3133 action=drop comment="deny BackOriffice"


Allow only needed icmp codes in icmp chain:
add chain=icmp protocol=icmp icmp-options=0:0 action=accept \
comment="drop invalid connections"
add chain=icmp protocol=icmp icmp-options=3:0 action=accept \
comment="allow established connections"
add chain=icmp protocol=icmp icmp-options=3:1 action=accept \
comment="allow already established connections"
add chain=icmp protocol=icmp icmp-options=4:0 action=accept \
comment="allow source quench"
add chain=icmp protocol=icmp icmp-options=8:0 action=accept \
comment="allow echo request"
add chain=icmp protocol=icmp icmp-options=11:0 action=accept \
comment="allow time exceed"
add chain=icmp protocol=icmp icmp-options=12:0 action=accept \
comment="allow parameter bad"
add chain=icmp action=drop comment="deny all other types"