LAB 10: DHCP Server Multi Interfaces + Firewall

LAB 10: DHCP Server Multi Interfaces + Firewall


Assalamualaikum wr wb..
Pada Lab sebelumnya kita telah membuat dhcp server yang akan membagikan IP Address secara otomatis ke client. Namun, pada lab tersebut kita hanya membuat satu interface DHCP Server. Kali ini kita akan  membuat beberapa interface yang akan kita jadikan sebagai DHCP Server.

Kenapa kita perlu untuk membagi menjadi beberapa interface? kenapa tidak satu interface saja? karena ini akan memudahkan kita sebagai adiministarator untuk melakukan konfigurasi sesuai dengan kebutuhan, karena bisa saja masing-masing (kelompok) client tersebut membutuhkan konfigurasi yang berbeda, misalnya suatu kelompok akan kita berikan rule firewall tertentu dan sebagainya.

Sebenarnya ada cara lainnya. Namun kali ini kita akan melakukan pengelompokkan tersebut menggunakan pengelompokkan dhcp.

Kita akan memulai melakukan konfigurasinya. Pertama, kita berikan ip address pada masing-masing interface yang akan kita jadikan sebagai interface untuk dhcp server.

Setting DHCP-Server
1. Setting IP Address
[admin@IDN_R2] > ip address print
Flags: X - disabled, I - invalid, D - dynamic
 #   ADDRESS            NETWORK         INTERFACE                                            
 0   192.168.1.1/24     192.168.1.0     ether2                                               
 1   192.168.2.1/24     192.168.2.0     ether3                                               
 2   192.168.3.1/24     192.168.3.0     ether4                                               
Selanjutnya kita atur dhcp-server setup, dan gunakan interface yang sesuai dengan interface pada ip address yang kita buat sebelumnya.

2. Setting DHCP-Server Pada Router
[admin@IDN_R2] > ip dhcp-server setup
Select interface to run DHCP server on

dhcp server interface: ether2
Select network for DHCP addresses

dhcp address space: 192.168.1.0/24
Select gateway for given network

gateway for dhcp network: 192.168.1.1
Select pool of ip addresses given out by DHCP server

addresses to give out: 192.168.1.100-192.168.1.120
Select DNS servers

dns servers: 8.8.8.8
Select lease time

lease time: 10m
[admin@IDN_R2] > ip dhcp-server setup
Select interface to run DHCP server on

dhcp server interface: ether3
Select network for DHCP addresses

dhcp address space: 192.168.2.0/24
Select gateway for given network

gateway for dhcp network: 192.168.2.1
Select pool of ip addresses given out by DHCP server

addresses to give out: 192.168.2.100-192.168.2.120
Select DNS servers

dns servers: 8.8.8.8
Select lease time

lease time: 10m
[admin@IDN_R2] > ip dhcp-server setup
Select interface to run DHCP server on

dhcp server interface: ether4
Select network for DHCP addresses

dhcp address space: 192.168.3.0/24
Select gateway for given network

gateway for dhcp network: 192.168.3.1
Select pool of ip addresses given out by DHCP server

addresses to give out: 192.168.3.100-192.168.3.120
Select DNS servers

dns servers: 8.8.8.8
Select lease time

lease time: 10m
[admin@IDN_R2] > ip dhcp-server print
Flags: X - disabled, I - invalid
 #   NAME          INTERFACE          RELAY           ADDRESS-POOL          LEASE-TIME ADD-ARP
 0   dhcp1         ether2                             dhcp_pool1            10m      
 1   dhcp2         ether3                             dhcp_pool2            10m      
 2   dhcp3         ether4                             dhcp_pool3            10m      


Lalu kita cuma perlu mengatur PC sebagai DHCP Client.
3. Setting DHCP-Client
PC2> dhcp
DORA IP 192.168.1.118/24 GW 192.168.1.1

PC2>       
PC5> dhcp
DORA IP 192.168.2.120/24 GW 192.168.2.1

PC5> 
PC7> dhcp
DORA IP 192.168.3.120/24 GW 192.168.3.1

PC7> 


Selanjutnya, berikan rule firewall pada rotuer tersebut.

Firewall
Kali ini kita akan bermain firewall, tujuan dari konfigurasi firewall adalah untuk mengamankan network dan atau router kita.




Secara default, jika kita tidak mengatur atau membuat rule untutk firewall filter maka router akan mengizinkan berbagai hak akses dari berbagai client, seperti yang terlihat pada percobaan test ping dibawah ini bahwa semua client bisa melakukan PING
PC8> ping 192.168.3.119

84 bytes from 192.168.3.119 icmp_seq=1 ttl=64 time=0.443 ms
84 bytes from 192.168.3.119 icmp_seq=2 ttl=64 time=0.233 ms
^C
PC8> 
PC8> ping 192.168.3.1

84 bytes from 192.168.3.1 icmp_seq=1 ttl=64 time=2.474 ms
84 bytes from 192.168.3.1 icmp_seq=2 ttl=64 time=0.828 ms
84 bytes from 192.168.3.1 icmp_seq=3 ttl=64 time=0.855 ms
^C
PC8> 


PC7> ping 192.168.3.120

84 bytes from 192.168.3.120 icmp_seq=1 ttl=64 time=0.273 ms
84 bytes from 192.168.3.120 icmp_seq=2 ttl=64 time=0.290 ms
^C
PC7> ping 192.168.3.1  

84 bytes from 192.168.3.1 icmp_seq=1 ttl=64 time=0.724 ms
84 bytes from 192.168.3.1 icmp_seq=2 ttl=64 time=0.849 ms
^C

Selanjutnya, tambahkan rule firewall filter pada rotuer mikrotik kita tersebut dengan action drop. Action drop akan menghasil timeout disisi client seperti ketika client melakukan ping.
[admin@IDN_R2] > ip firewall filter add chain=input in-interface=ether4 action=drop 
Selanjutnya, lakukan percobaan dengan PING ke Router, dan ke PC Sebelahnya.
PC7> ping 192.168.3.1

192.168.3.1 icmp_seq=1 timeout
192.168.3.1 icmp_seq=2 timeout
192.168.3.1 icmp_seq=3 timeout
192.168.3.1 icmp_seq=4 timeout
192.168.3.1 icmp_seq=5 timeout
^C
PC7> ping 192.168.3.120                                                                        
                                                                                               
84 bytes from 192.168.3.120 icmp_seq=1 ttl=64 time=0.187 ms                                    
84 bytes from 192.168.3.120 icmp_seq=2 ttl=64 time=0.244 ms  

PC8> ping 192.168.3.1

192.168.3.1 icmp_seq=1 timeout
192.168.3.1 icmp_seq=2 timeout
192.168.3.1 icmp_seq=3 timeout
192.168.3.1 icmp_seq=4 timeout
^C                                                                                             

PC8> ping 192.168.3.119                                                                        
                                                                                               
84 bytes from 192.168.3.119 icmp_seq=1 ttl=64 time=0.315 ms                                    
84 bytes from 192.168.3.119 icmp_seq=2 ttl=64 time=0.243 ms                                    
^C                                                                                             
PC8>          
Dari percabaan diatas, kita akan mendapatkan reply timeout. Hal ini dikarenakan kita telah mengatur chain=input pada router tersebut dengan action=drop. Maka setiap router yang berusaha untuk menuju router akan memperoleh jawab timeout. Tapi, ketika PC lainnya melakukan PING ke PC lainnya (Sesama PC).


Sekarang kita beraanjak ke PC yang berada pada Switch 1.
PC1> ping 192.168.1.1

84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=0.993 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=1.123 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=64 time=1.328 ms
^C
PC1> ping 192.168.1.118

84 bytes from 192.168.1.118 icmp_seq=1 ttl=64 time=0.309 ms
84 bytes from 192.168.1.118 icmp_seq=2 ttl=64 time=0.257 ms
^C
PC1> ping 192.168.1.120

84 bytes from 192.168.1.120 icmp_seq=1 ttl=64 time=0.231 ms
84 bytes from 192.168.1.120 icmp_seq=2 ttl=64 time=0.289 ms


PC2> ping 192.168.1.1

84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=0.998 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=0.882 ms
^C
PC2> ping 192.168.1.119

84 bytes from 192.168.1.119 icmp_seq=1 ttl=64 time=0.153 ms
^C
PC2> ping 192.168.1.120

84 bytes from 192.168.1.120 icmp_seq=1 ttl=64 time=0.302 ms
84 bytes from 192.168.1.120 icmp_seq=2 ttl=64 time=0.326 ms
^C
PC2> 
Dari percobaan dengan test PING diatas terlihat bahwa semuanya memperoleh jawaban dari device-device atau router yang dihubungi.

Selanjutnya kita atur firewall filter seperti dibawah ini.
[admin@IDN_R2] > ip firewall filter add chain=input action=reject src-address=192.168.1.118-192
.168.1.119 in-interface=ether2 
[admin@IDN_R2] > ip firewall filter print 
Flags: X - disabled, I - invalid, D - dynamic 
 0   chain=input action=drop in-interface=ether4 

 1   chain=input action=reject reject-with=icmp-network-unreachable 
     src-address=192.168.1.118/24 in-interface=ether2 


Lakukan PING ulang, maka ketika kita PING interface router yang mengarah ke PC maka kita akan memperoleh jawaban Destination network unreachable. Ini terjadi karena kita telah mengatur action=reject untuk address 192.168.1.119 yang merupakan IP Address dari PC 1

PC1> ping 192.168.1.1

*192.168.1.1 icmp_seq=1 ttl=64 time=0.991 ms (ICMP type:3, code:0, Destination network unreachable)
*192.168.1.1 icmp_seq=2 ttl=64 time=1.078 ms (ICMP type:3, code:0, Destination network unreachable)
*192.168.1.1 icmp_seq=3 ttl=64 time=1.615 ms (ICMP type:3, code:0, Destination network unreachable)
^C
PC1> ping 192.168.1.120

84 bytes from 192.168.1.120 icmp_seq=1 ttl=64 time=0.292 ms
84 bytes from 192.168.1.120 icmp_seq=2 ttl=64 time=0.280 ms
^C
PC1> ping 192.168.1.118

84 bytes from 192.168.1.118 icmp_seq=1 ttl=64 time=0.417 ms
84 bytes from 192.168.1.118 icmp_seq=2 ttl=64 time=0.309 ms
84 bytes from 192.168.1.118 icmp_seq=3 ttl=64 time=0.256 ms
^C
PC1> 


PC3> ping 192.168.1.1                                                                          
                                                                                               
84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=1.094 ms                                      
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=1.092 ms                                      
^C                                                                                             
PC3> ping 192.168.1.119                                                                        
                                                                                               
84 bytes from 192.168.1.119 icmp_seq=1 ttl=64 time=0.293 ms
84 bytes from 192.168.1.119 icmp_seq=2 ttl=64 time=0.288 ms
^C
PC3> ping 192.168.1.118

84 bytes from 192.168.1.118 icmp_seq=1 ttl=64 time=0.243 ms
84 bytes from 192.168.1.118 icmp_seq=2 ttl=64 time=0.286 ms
^C
PC3> 

Selanjutnya, tambahkan konfigurasi pada Firewall Filter
[admin@IDN_R2] > ip firewall filter add chain=forward in-interface=ether2 src-address=192.168.1
.120/24 action=drop 
[admin@IDN_R2] > 

Lalu lakukan PING untuk menguji hasil dari pengaturan firewall kita tersebut.
PC3> ping 192.168.1.1  

84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=0.943 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=1.262 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=64 time=1.181 ms
^C
Taraaa .. lha, kok Tidak berpengaruh apa-apa, kenapa bisa? |
karena... chain nya kita atur dengan foward, sedangkan packet PING kita ini merupakan paket yang menuju Router bukan yang melewati router untuk keluar misalnya.


Lalu, kita tambahkan konfigurasi firewall filter seperti dibawah.
[admin@IDN_R2] > ip firewall filter add chain=input action=accept   src-address=192.168.2.120 in-interface=ether3        
[admin@IDN_R2] > ip firewall filter add chain=input action=drop    src-address=192.168.2.0/24 in-interface=ether3   
[admin@IDN_R2] > ip firewall filter print 
Flags: X - disabled, I - invalid, D - dynamic 
 0   chain=input action=drop in-interface=ether4 

 1   chain=input action=reject reject-with=icmp-network-unreachable 
     src-address=192.168.1.118/31 in-interface=ether2 

 2   chain=forward action=drop src-address=192.168.1.0/24 in-interface=ether2 

 3   chain=input action=accept src-address=192.168.2.120 in-interface=ether3 

 4   chain=input action=drop src-address=192.168.2.0/24 in-interface=ether3 


Seperti biasa, lakukan PING ke router dari PC5 dan  PC6.
[admin@IDN_R2] > 
PC5> ping 192.168.2.1

192.168.2.1 icmp_seq=1 timeout
192.168.2.1 icmp_seq=2 timeout
192.168.2.1 icmp_seq=3 timeout

PC6> ping 192.168.1.1

84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=0.975 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=1.125 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=64 time=1.041 ms
Seperti yang terlihat, bahwa PC 5 mendapatkan jawaban timeout, sedangkan PC6 memperoleh jawaban yang menunjukkan komunikasi berhasil.

Kenapa bisa seperti itu? Karena, mengatur action accept untuk src-address 192.168.2.120 yang merupakan IP dari PC6
chain=input action=accept src-address=192.168.2.120 in-interface=ether3 


Sedangkan, rule selanjutnya (rule no4):
chain=input action=drop src-address=192.168.2.0/24 in-interface=ether3 
Melakukan drop terhadap seluruh ip pada network 192.168.2.0/24 yang melalui interface ether3.

Logika dari firewall adalah, Jika rule pertama sudah terpenuhi, maka router tidak akan memeriksa rule selanjutnya, namun jika rule pertama belum terpenuhi, maka router akan meneruskan pemeriksaan dari suatu packet data.

No comments:

Post a Comment

Tak ada gading yang tak retak!!
Komentar dan masukan yang bersifat membangun selalu kami harapkan, demi kebaikan bersama.

Pages