SlideShare a Scribd company logo
www.glcnetworks.com
Layer 7 Firewall
on mikrotik
GLC Webinar,
27 May 2021
Achmad Mardiansyah
achmad@glcnetworks.com
GLC Networks, Indonesia
1
L7 firewall
www.glcnetworks.com
Agenda
● Introduction
● Review prerequisite knowledge
● Firewall
● L7 firewall
● Tips and trick
● Live practice
● Q & A
2
www.glcnetworks.com
introduction
3
www.glcnetworks.com
What is GLC?
● Garda Lintas Cakrawala (www.glcnetworks.com)
● Based in Bandung, Indonesia
● Areas: Training, IT Consulting
● Certified partner for: Mikrotik, Ubiquity, Linux foundation
● Product: GLC radius manager
● Regular event
4
www.glcnetworks.com
Trainer Introduction
● Name: Achmad Mardiansyah
● Base: bandung, Indonesia
● Linux user since 1999, mikrotik user since 2007, UBNT
2011
● Mikrotik Certified Trainer
(MTCNA/RE/WE/UME/INE/TCE/IPv6)
● Mikrotik/Linux Certified Consultant
● Website contributor: achmadjournal.com, mikrotik.tips,
asysadmin.tips
● More info:
http://au.linkedin.com/in/achmadmardiansyah
5
www.glcnetworks.com
Past experience
6
● 2021 (Congo DRC, Malaysia): network support,
radius/billing integration
● 2020 (Congo DRC, Malaysia): IOT integration,
network automation
● 2019, Congo (DRC): build a wireless ISP from
ground-up
● 2018, Malaysia: network revamp, develop billing
solution and integration, setup dynamic routing
● 2017, Libya (north africa): remote wireless migration
for a new Wireless ISP
● 2016, United Kingdom: workshop for wireless ISP,
migrating a bridged to routed network
www.glcnetworks.com
About GLC webinar?
● First webinar: january 1, 2010 (title:
tahun baru bersama solaris - new year
with solaris OS)
● As a sharing event with various topics:
linux, networking, wireless, database,
programming, etc
● Regular schedule
● Irregular schedule: as needed
● Checking schedule:
http://www.glcnetworks.com/schedule
● You are invited to be a presenter
○ No need to be an expert
○ This is a forum for sharing: knowledge,
experiences, information
7
www.glcnetworks.com
Please introduce yourself
● Your name
● Your company/university?
● Your networking experience?
● Your mikrotik experience?
● Your expectation from this course?
8
www.glcnetworks.com
Prerequisite
● This presentation some prerequisite knowledge
● We assume you already know:
○ 7 OSI layer
○ Encapsulation
○ How to use mikrotik device
○ Mikrotik firewall
○ Regular expression
○
9
www.glcnetworks.com
Review prerequisite knowledge
10
www.glcnetworks.com
7 OSI layer & protocol
11
● OSI layer Is a conceptual model from ISO
(International Standard Organization) for project
OSI (Open System Interconnection)
● When you send a message with a courier, you
need to add more info to get your message arrived
at the destination (This process is called
encapsulation)
● What is protocol
○ Is a set of rules for communication
○ Available on each layer
● Communication consist of series encapsulation
○ SDU: service data unit (before PDU)
○ PDU: protocol data unit (after header is added)
www.glcnetworks.com
Layered model (TCP/IP vs ISO) and encapsulation
12
/ datagram
www.glcnetworks.com
Layer 4 header (which one is TCP?)
13
www.glcnetworks.com
Layer 3 header (which one is IPv4?)
14
www.glcnetworks.com
Ethernet header (which is the MTU?)
15
www.glcnetworks.com
802.11 header
16
www.glcnetworks.com
Did you notice?
● There is a big overhead on encapsulation process
● More encapsulation means less payload?
17
www.glcnetworks.com
HUB, switch, router, firewall
18
www.glcnetworks.com
Regular Expression (REGEX), part 1
● Regex = Regular Expression, a feature to search pattern in a data (useful to
apply custom filter)
● Applied on filter (l7 firewall, routing filter)
● Regex code:
○ () → grouping characters together
○ . → match 1 character
○ ?, *, + → shows how the previous character is repeated
■ ? → match 0 or 1 repetition of previous string
■ * → match 0 or many repetition of previous string
■ + → match 1 or many repetition of previous string
○ ^ → matches the beginning of string
○ $ → matches at the end of string
○  → escape character (ffrfom ?*+|^$)
○ [] → match 1 character from the bracket
■ [abc] → match 1 character from the bracket (a or b or c)
■ [a-z] → match 1 character from the bracket (a to z)
●
19
www.glcnetworks.com
Regular Expression (REGEX), part 2
● Regex code:
○ | → similar to or, match left or right part
○ [x09-x0d -~] → match on all printable ASCII characters & space
○ [x09-x0d ] → match a TAB, LF, Vertical Tab, Form Feed, Carriage Return (CR) or space
○ [!-~] → match non-whitespace printable characters
○
20
www.glcnetworks.com
Mikrotik firewall
21
www.glcnetworks.com
On which layer does the (traditional)
Firewall works?
22
● All firewall inspect traffic between segment → layer
3
● Some firewall supports tracking → layer 4
● Some firewall support inside-segment filtering →
layer 2
● See the encapsulation process before
www.glcnetworks.com
What is Mikrotik firewall?
● Is a feature to
○ Control network access (filter)
○ Modify network header (NAT)
○ Marking packet for further processing (mangle)
● Developed from linux
● Consist of 2 parts: matcher & action
● Executed sequentially
● Netadmin must understand the application’s characteristics in order to build a
matcher (e.g. browsing → using TCP/UDP port 80,443)
23
www.glcnetworks.com
How firewall works?
● Setup matcher -> then action
● Mikrotik has lots of options for matcher
-> very flexible
● Matcher + Action = Firewall rule
● Rule is executed sequentially
24
www.glcnetworks.com
25
Where the packet
is processed?
A: see packet flow
Note: ipsec is removed in this
diagram
www.glcnetworks.com
26
26
What's the
difference between
forward and input?
FORWARD
INPUT
www.glcnetworks.com
Layer 7 firewall
27
www.glcnetworks.com
What is Layer-7 Firewall on mikrotik?
● layer7-protocol is a method of searching for patterns in ICMP/TCP/UDP
payload streams
● Is used as matchers
● L7 matcher collects the first 10 packets of a connection or the first 2KB,
stored them in a buffer, and then search for pattern.
● IF pattern not found → pass
● Doesnt guarantee always work → application has its own pattern
28
www.glcnetworks.com
p2p matcher is not available
anymore
● P2p matchers is not available since 6.39
● Previously p2p matchers is based on pattern
matchers
● Because torrent traffic now is encrypted, the
pattern matching is useless
● Mikrotik remove the p2p matchers feature
● Need a different approach to deal with torrent
traffic
29
Not available anymore
www.glcnetworks.com
Example: create l7-pattern
30
www.glcnetworks.com
Example: Create firewall rule
31
www.glcnetworks.com
Not recommended!!
● Its not recommended to put direct action on packet (drop/reject).
32
www.glcnetworks.com
Tips trick
33
www.glcnetworks.com
Tips and trick
● Applied on forward chain → l7 firewall must see both directions (inbound and
outbound)
● Combine it with address-list/connection-mark. After match is done, then put it
on address-list. → to reduce CPU usage
● Put the l7 rules on top → to reduce cpu usage
● Do not check packet that previously marked. Use “connection-mark=no-mark”
or “packet-mark=no-mark” → to reduce CPU
● Do not check packet that previously put on address-list.
● L7 firewall cannot inspect HTTPS payload
● If you want to match based on https header and domain name, use “tls-host”
● Do not use l7 on high traffic
● Be careful when blocking based on IP address, it can host multiple domain.
○ If you block youtube IP address, those IP addresses are used for google drive and other
services
34
www.glcnetworks.com
Tips and trick
● L7 protocol references:
○ http://www.mikrotik.com/download/share/l7_protocols_may_2009.zip
○ https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/L7
○ http://l7-filter.sourceforge.net/
● Some regex references
○ https://regexone.com/
○ http://regexr.com/
○ https://regex101.com/
○ http://buildregex.com/
●
35
www.glcnetworks.com
LIVE practice
36
www.glcnetworks.com
preparation
● SSH client
● SSH parameters
○ SSH address
○ SSH port
○ SSH username
○ SSH password
37
www.glcnetworks.com
Q & A
38
www.glcnetworks.com
Interested? Just come to our training...
● Topics are arranged in systematic and logical way
● You will learn from experienced teacher
● Not only learn the materials, but also sharing experiences, best-practices, and
networking
39
www.glcnetworks.com
End of slides
● Thank you for your attention
● Please submit your feedback: http://bit.ly/glcfeedback
● Find our further event on our website : https://www.glcnetworks.com/en/
● Like our facebook page: https://www.facebook.com/glcnetworks
● Slide: https://www.slideshare.net/glcnetworks/
● Recording (youtube): https://www.youtube.com/c/GLCNetworks
● Stay tune with our schedule
● Any questions?
40

More Related Content

What's hot (20)

PDF
Mikrotik firewall raw table
Achmad Mardiansyah
 
PDF
VLAN on mikrotik
Achmad Mardiansyah
 
PDF
BGP on mikrotik
Achmad Mardiansyah
 
PDF
Linux Networking Explained
Thomas Graf
 
PDF
Mikrotik IP Settings For Performance and Security
GLC Networks
 
PDF
Network LACP/Bonding/Teaming with Mikrotik
GLC Networks
 
PDF
Mikrotik Bridge Deep Dive
GLC Networks
 
PDF
Build enterprise wireless with CAPsMAN
GLC Networks
 
PDF
Mikrotik fasttrack
Achmad Mardiansyah
 
PDF
MikroTik & RouterOS
Faelix Ltd
 
PDF
BGP on RouterOS7 -Part 1
GLC Networks
 
PDF
ISP Load Balancing with Mikrotik ECMP
GLC Networks
 
PDF
Network Monitoring with The Dude and Whatsapp
GLC Networks
 
DOC
Tutorial radius client mikrotik
Adi Utami
 
PDF
MikroTik Security
Rofiq Fauzi
 
PDF
Mikrotik fastpath
Achmad Mardiansyah
 
PDF
Zabbix for Monitoring
GLC Networks
 
PDF
Policy Based Routing (PBR) on Mikrotik
GLC Networks
 
PDF
Choosing Mikrotik Platform x86 vs chr
GLC Networks
 
PDF
Advanced OpenVPN Concepts - pfSense Hangout September 2014
Netgate
 
Mikrotik firewall raw table
Achmad Mardiansyah
 
VLAN on mikrotik
Achmad Mardiansyah
 
BGP on mikrotik
Achmad Mardiansyah
 
Linux Networking Explained
Thomas Graf
 
Mikrotik IP Settings For Performance and Security
GLC Networks
 
Network LACP/Bonding/Teaming with Mikrotik
GLC Networks
 
Mikrotik Bridge Deep Dive
GLC Networks
 
Build enterprise wireless with CAPsMAN
GLC Networks
 
Mikrotik fasttrack
Achmad Mardiansyah
 
MikroTik & RouterOS
Faelix Ltd
 
BGP on RouterOS7 -Part 1
GLC Networks
 
ISP Load Balancing with Mikrotik ECMP
GLC Networks
 
Network Monitoring with The Dude and Whatsapp
GLC Networks
 
Tutorial radius client mikrotik
Adi Utami
 
MikroTik Security
Rofiq Fauzi
 
Mikrotik fastpath
Achmad Mardiansyah
 
Zabbix for Monitoring
GLC Networks
 
Policy Based Routing (PBR) on Mikrotik
GLC Networks
 
Choosing Mikrotik Platform x86 vs chr
GLC Networks
 
Advanced OpenVPN Concepts - pfSense Hangout September 2014
Netgate
 

Similar to Layer 7 Firewall on Mikrotik (20)

PDF
Firewall mangle PBR: steering outbound path similar to inbound
GLC Networks
 
PDF
Mikrotik firewall filter
Achmad Mardiansyah
 
PDF
BGP Services IP Transit vs IP Peering
GLC Networks
 
PDF
Best Current Practice (BCP) 38 Ingress Filtering for Security
GLC Networks
 
PDF
Controlling Access Between Devices in the same Layer 2 Segment
GLC Networks
 
PDF
Mikrotik firewall mangle
Achmad Mardiansyah
 
PDF
Internet Protocol Deep-Dive
GLC Networks
 
PDF
Networking in Telecommunication (signalling, tcp, ucp, ss7, sctp, sigtran)
GLC Networks
 
PDF
Mikrotik Fastpath vs Fasttrack
GLC Networks
 
PDF
IPv6 with Mikrotik
GLC Networks
 
PDF
Running BGP with Mikrotik
GLC Networks
 
PDF
OSPF On Router OS7
GLC Networks
 
PDF
CCNA : Intro to Cisco IOS - Part 1
GLC Networks
 
PDF
RouterOS Migration From v6 to v7
GLC Networks
 
PDF
Troubleshooting Layer 2 Ethernet Problem: Loop, Broadcast, Security
GLC Networks
 
PDF
MPLS on Router OS V7 - Part 1
GLC Networks
 
PDF
MTCNA Intro to routerOS
GLC Networks
 
PDF
Steering traffic in OSPF: Interface cost
GLC Networks
 
PDF
Using Mikrotik Switch Features to Improve Your Network
GLC Networks
 
PDF
Routing fundamentals with mikrotik
Achmad Mardiansyah
 
Firewall mangle PBR: steering outbound path similar to inbound
GLC Networks
 
Mikrotik firewall filter
Achmad Mardiansyah
 
BGP Services IP Transit vs IP Peering
GLC Networks
 
Best Current Practice (BCP) 38 Ingress Filtering for Security
GLC Networks
 
Controlling Access Between Devices in the same Layer 2 Segment
GLC Networks
 
Mikrotik firewall mangle
Achmad Mardiansyah
 
Internet Protocol Deep-Dive
GLC Networks
 
Networking in Telecommunication (signalling, tcp, ucp, ss7, sctp, sigtran)
GLC Networks
 
Mikrotik Fastpath vs Fasttrack
GLC Networks
 
IPv6 with Mikrotik
GLC Networks
 
Running BGP with Mikrotik
GLC Networks
 
OSPF On Router OS7
GLC Networks
 
CCNA : Intro to Cisco IOS - Part 1
GLC Networks
 
RouterOS Migration From v6 to v7
GLC Networks
 
Troubleshooting Layer 2 Ethernet Problem: Loop, Broadcast, Security
GLC Networks
 
MPLS on Router OS V7 - Part 1
GLC Networks
 
MTCNA Intro to routerOS
GLC Networks
 
Steering traffic in OSPF: Interface cost
GLC Networks
 
Using Mikrotik Switch Features to Improve Your Network
GLC Networks
 
Routing fundamentals with mikrotik
Achmad Mardiansyah
 
Ad

More from GLC Networks (20)

PDF
Internal BGP tuning: Mesh peering to avoid loop
GLC Networks
 
PDF
BGP tuning: Peer with loopback
GLC Networks
 
PDF
BGP security tuning: pull-up route
GLC Networks
 
PDF
BGP troubleshooting: route origin
GLC Networks
 
PDF
Tuning OSPF: Bidirectional Forwarding Detection (BFD)
GLC Networks
 
PDF
Tuning OSPF: Prefix Aggregate
GLC Networks
 
PDF
Tuning OSPF: area hierarchy, LSA, and area type
GLC Networks
 
PDF
Stable OSPF: choosing network type.pdf
GLC Networks
 
PDF
GIT as Mikrotik Configuration Management
GLC Networks
 
PDF
Building a Web Server with NGINX
GLC Networks
 
PDF
EOIP Deep Dive
GLC Networks
 
PDF
Policy Based Routing with Indirect BGP - Part 2
GLC Networks
 
PDF
Policy Based Routing with Indirect BGP - Part 1
GLC Networks
 
PPTX
Automatic Backup via FTP - Part 2
GLC Networks
 
PDF
Automatic Backup via FTP - Part 1
GLC Networks
 
PDF
Voice Services, From Circuit Switch to VoIP
GLC Networks
 
PDF
MPLS on Router OS V7 - Part 2
GLC Networks
 
PDF
BGP on RouterOS7 - Part 2
GLC Networks
 
PDF
OSPF On Router OS7 - Part 2
GLC Networks
 
PDF
Using Zettabyte Filesystem (ZFS)
GLC Networks
 
Internal BGP tuning: Mesh peering to avoid loop
GLC Networks
 
BGP tuning: Peer with loopback
GLC Networks
 
BGP security tuning: pull-up route
GLC Networks
 
BGP troubleshooting: route origin
GLC Networks
 
Tuning OSPF: Bidirectional Forwarding Detection (BFD)
GLC Networks
 
Tuning OSPF: Prefix Aggregate
GLC Networks
 
Tuning OSPF: area hierarchy, LSA, and area type
GLC Networks
 
Stable OSPF: choosing network type.pdf
GLC Networks
 
GIT as Mikrotik Configuration Management
GLC Networks
 
Building a Web Server with NGINX
GLC Networks
 
EOIP Deep Dive
GLC Networks
 
Policy Based Routing with Indirect BGP - Part 2
GLC Networks
 
Policy Based Routing with Indirect BGP - Part 1
GLC Networks
 
Automatic Backup via FTP - Part 2
GLC Networks
 
Automatic Backup via FTP - Part 1
GLC Networks
 
Voice Services, From Circuit Switch to VoIP
GLC Networks
 
MPLS on Router OS V7 - Part 2
GLC Networks
 
BGP on RouterOS7 - Part 2
GLC Networks
 
OSPF On Router OS7 - Part 2
GLC Networks
 
Using Zettabyte Filesystem (ZFS)
GLC Networks
 
Ad

Recently uploaded (20)

PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
The Future of Artificial Intelligence (AI)
Mukul
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 

Layer 7 Firewall on Mikrotik

  • 1. www.glcnetworks.com Layer 7 Firewall on mikrotik GLC Webinar, 27 May 2021 Achmad Mardiansyah [email protected] GLC Networks, Indonesia 1 L7 firewall
  • 2. www.glcnetworks.com Agenda ● Introduction ● Review prerequisite knowledge ● Firewall ● L7 firewall ● Tips and trick ● Live practice ● Q & A 2
  • 4. www.glcnetworks.com What is GLC? ● Garda Lintas Cakrawala (www.glcnetworks.com) ● Based in Bandung, Indonesia ● Areas: Training, IT Consulting ● Certified partner for: Mikrotik, Ubiquity, Linux foundation ● Product: GLC radius manager ● Regular event 4
  • 5. www.glcnetworks.com Trainer Introduction ● Name: Achmad Mardiansyah ● Base: bandung, Indonesia ● Linux user since 1999, mikrotik user since 2007, UBNT 2011 ● Mikrotik Certified Trainer (MTCNA/RE/WE/UME/INE/TCE/IPv6) ● Mikrotik/Linux Certified Consultant ● Website contributor: achmadjournal.com, mikrotik.tips, asysadmin.tips ● More info: http://au.linkedin.com/in/achmadmardiansyah 5
  • 6. www.glcnetworks.com Past experience 6 ● 2021 (Congo DRC, Malaysia): network support, radius/billing integration ● 2020 (Congo DRC, Malaysia): IOT integration, network automation ● 2019, Congo (DRC): build a wireless ISP from ground-up ● 2018, Malaysia: network revamp, develop billing solution and integration, setup dynamic routing ● 2017, Libya (north africa): remote wireless migration for a new Wireless ISP ● 2016, United Kingdom: workshop for wireless ISP, migrating a bridged to routed network
  • 7. www.glcnetworks.com About GLC webinar? ● First webinar: january 1, 2010 (title: tahun baru bersama solaris - new year with solaris OS) ● As a sharing event with various topics: linux, networking, wireless, database, programming, etc ● Regular schedule ● Irregular schedule: as needed ● Checking schedule: http://www.glcnetworks.com/schedule ● You are invited to be a presenter ○ No need to be an expert ○ This is a forum for sharing: knowledge, experiences, information 7
  • 8. www.glcnetworks.com Please introduce yourself ● Your name ● Your company/university? ● Your networking experience? ● Your mikrotik experience? ● Your expectation from this course? 8
  • 9. www.glcnetworks.com Prerequisite ● This presentation some prerequisite knowledge ● We assume you already know: ○ 7 OSI layer ○ Encapsulation ○ How to use mikrotik device ○ Mikrotik firewall ○ Regular expression ○ 9
  • 11. www.glcnetworks.com 7 OSI layer & protocol 11 ● OSI layer Is a conceptual model from ISO (International Standard Organization) for project OSI (Open System Interconnection) ● When you send a message with a courier, you need to add more info to get your message arrived at the destination (This process is called encapsulation) ● What is protocol ○ Is a set of rules for communication ○ Available on each layer ● Communication consist of series encapsulation ○ SDU: service data unit (before PDU) ○ PDU: protocol data unit (after header is added)
  • 12. www.glcnetworks.com Layered model (TCP/IP vs ISO) and encapsulation 12 / datagram
  • 13. www.glcnetworks.com Layer 4 header (which one is TCP?) 13
  • 14. www.glcnetworks.com Layer 3 header (which one is IPv4?) 14
  • 17. www.glcnetworks.com Did you notice? ● There is a big overhead on encapsulation process ● More encapsulation means less payload? 17
  • 19. www.glcnetworks.com Regular Expression (REGEX), part 1 ● Regex = Regular Expression, a feature to search pattern in a data (useful to apply custom filter) ● Applied on filter (l7 firewall, routing filter) ● Regex code: ○ () → grouping characters together ○ . → match 1 character ○ ?, *, + → shows how the previous character is repeated ■ ? → match 0 or 1 repetition of previous string ■ * → match 0 or many repetition of previous string ■ + → match 1 or many repetition of previous string ○ ^ → matches the beginning of string ○ $ → matches at the end of string ○ → escape character (ffrfom ?*+|^$) ○ [] → match 1 character from the bracket ■ [abc] → match 1 character from the bracket (a or b or c) ■ [a-z] → match 1 character from the bracket (a to z) ● 19
  • 20. www.glcnetworks.com Regular Expression (REGEX), part 2 ● Regex code: ○ | → similar to or, match left or right part ○ [x09-x0d -~] → match on all printable ASCII characters & space ○ [x09-x0d ] → match a TAB, LF, Vertical Tab, Form Feed, Carriage Return (CR) or space ○ [!-~] → match non-whitespace printable characters ○ 20
  • 22. www.glcnetworks.com On which layer does the (traditional) Firewall works? 22 ● All firewall inspect traffic between segment → layer 3 ● Some firewall supports tracking → layer 4 ● Some firewall support inside-segment filtering → layer 2 ● See the encapsulation process before
  • 23. www.glcnetworks.com What is Mikrotik firewall? ● Is a feature to ○ Control network access (filter) ○ Modify network header (NAT) ○ Marking packet for further processing (mangle) ● Developed from linux ● Consist of 2 parts: matcher & action ● Executed sequentially ● Netadmin must understand the application’s characteristics in order to build a matcher (e.g. browsing → using TCP/UDP port 80,443) 23
  • 24. www.glcnetworks.com How firewall works? ● Setup matcher -> then action ● Mikrotik has lots of options for matcher -> very flexible ● Matcher + Action = Firewall rule ● Rule is executed sequentially 24
  • 25. www.glcnetworks.com 25 Where the packet is processed? A: see packet flow Note: ipsec is removed in this diagram
  • 28. www.glcnetworks.com What is Layer-7 Firewall on mikrotik? ● layer7-protocol is a method of searching for patterns in ICMP/TCP/UDP payload streams ● Is used as matchers ● L7 matcher collects the first 10 packets of a connection or the first 2KB, stored them in a buffer, and then search for pattern. ● IF pattern not found → pass ● Doesnt guarantee always work → application has its own pattern 28
  • 29. www.glcnetworks.com p2p matcher is not available anymore ● P2p matchers is not available since 6.39 ● Previously p2p matchers is based on pattern matchers ● Because torrent traffic now is encrypted, the pattern matching is useless ● Mikrotik remove the p2p matchers feature ● Need a different approach to deal with torrent traffic 29 Not available anymore
  • 32. www.glcnetworks.com Not recommended!! ● Its not recommended to put direct action on packet (drop/reject). 32
  • 34. www.glcnetworks.com Tips and trick ● Applied on forward chain → l7 firewall must see both directions (inbound and outbound) ● Combine it with address-list/connection-mark. After match is done, then put it on address-list. → to reduce CPU usage ● Put the l7 rules on top → to reduce cpu usage ● Do not check packet that previously marked. Use “connection-mark=no-mark” or “packet-mark=no-mark” → to reduce CPU ● Do not check packet that previously put on address-list. ● L7 firewall cannot inspect HTTPS payload ● If you want to match based on https header and domain name, use “tls-host” ● Do not use l7 on high traffic ● Be careful when blocking based on IP address, it can host multiple domain. ○ If you block youtube IP address, those IP addresses are used for google drive and other services 34
  • 35. www.glcnetworks.com Tips and trick ● L7 protocol references: ○ http://www.mikrotik.com/download/share/l7_protocols_may_2009.zip ○ https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/L7 ○ http://l7-filter.sourceforge.net/ ● Some regex references ○ https://regexone.com/ ○ http://regexr.com/ ○ https://regex101.com/ ○ http://buildregex.com/ ● 35
  • 37. www.glcnetworks.com preparation ● SSH client ● SSH parameters ○ SSH address ○ SSH port ○ SSH username ○ SSH password 37
  • 39. www.glcnetworks.com Interested? Just come to our training... ● Topics are arranged in systematic and logical way ● You will learn from experienced teacher ● Not only learn the materials, but also sharing experiences, best-practices, and networking 39
  • 40. www.glcnetworks.com End of slides ● Thank you for your attention ● Please submit your feedback: http://bit.ly/glcfeedback ● Find our further event on our website : https://www.glcnetworks.com/en/ ● Like our facebook page: https://www.facebook.com/glcnetworks ● Slide: https://www.slideshare.net/glcnetworks/ ● Recording (youtube): https://www.youtube.com/c/GLCNetworks ● Stay tune with our schedule ● Any questions? 40