MTCTCE English PDF
MTCTCE English PDF
MTCTCE English PDF
TRAFFIC CONTROL
ID-NETWORKERS | www.training-mikrotik.com
3
ID-NETWORKERS | www.training-mikrotik.com
4
www.trainingmikrotik.com
Host Subdomain Top-Level Domain
ID-NETWORKERS | www.training-mikrotik.com
5
ID-NETWORKERS | www.training-mikrotik.com
6
ID-NETWORKERS | www.training-mikrotik.com
7
Static DNS
• DNS Cache can also serve as a simple DNS
server.
• For each static DNS settings, the router will add
the parameter "A" and "PTR" is automatically.
"A" - Address Mapping Domain to IP Address
"PTR" - To map the Reverse DNS
• Static DNS will override dynamic entries in the
DNS cache
ID-NETWORKERS | www.training-mikrotik.com
8
Dns request
ID-NETWORKERS | www.training-mikrotik.com
10
ID-NETWORKERS | www.training-mikrotik.com
11
ID-NETWORKERS | www.training-mikrotik.com
12
ID-NETWORKERS | www.training-mikrotik.com
13
DHCP
Dynamic Host Configuration Protocol
ID-NETWORKERS | www.training-mikrotik.com
14
DHCP
• The Dynamic Host Configuration Protocol is
used for dynamic distribution of network setting
such as:
• IP address and netmask
• Default gateway address
• DNS and NTP server addresses
• More than 100 other custom option
(supported only by specific DHCP clients)
• DHCP is basically insecure system and should
only be used in own trusted networks
ID-NETWORKERS | www.training-mikrotik.com
15
ID-NETWORKERS | www.training-mikrotik.com
16
DHCP Server
• DHCP server can be run on each interface on the router, even
on some virtual interface.
• One interface only can run 1 DHCP server.
• To easily DHCP server settings, add the IP address first for
the interface will run DHCP server.
• DHCP server settings on the menu IP> DHCP Server> DHCP
Setup, just follow the step easily
ID-NETWORKERS | www.training-mikrotik.com
17
ID-NETWORKERS | www.training-mikrotik.com
18
ID-NETWORKERS | www.training-mikrotik.com
19
ID-NETWORKERS | www.training-mikrotik.com
20
ID-NETWORKERS | www.training-mikrotik.com
21
DHCP Options
• Implemented DHCP options
̶ Subnet-Mask (option 1) - netmask
̶ Router (option 3) - gateway
̶ Domain-Server (option 6) - dns-server
̶ Domain-Name (option 15) - domain
̶ NTP-Servers (option 42) - ntp-server
̶ NETBIOS-Name-Server (option 44) - wins-server
• Custom DHCP options (Example:)
Classless Static Route (C) - “0x100A270A260101” =
“network=10.39.0.0/16 gateway=10.38.1.1”
• For completed DHCP code, see:
http://www.iana.org/assignments/bootp-dhcp-parameters
ID-NETWORKERS | www.training-mikrotik.com
22
DHCP Options
Raw Format of 10.39.0.0/16 and 10.38.1.1:
• 0x | 10 | 0A27 | 0A260101 | all
• 0x – Hex Number
• 10 – Subnet/Prefix = 16
• 0A27 – Network = 10.39.0.0
• 0A260101 – Gateway = 10.38.1.1
ID-NETWORKERS | www.training-mikrotik.com
23
Static route
ID-NETWORKERS | www.training-mikrotik.com
25
DHCP Options
• IP address pools are used to define range of IP
addresses for dynamic distribution (DHCP, PPP,
Hotspot)
• Address pool must exclude already address that
already used as static device (such as server)
• It is possible to assign more that one range in IP pool
• It is possible to chain several pools together by using
“Next Pool” option
• By default the IP address will start give IP from the
bigger one from the pool.
ID-NETWORKERS | www.training-mikrotik.com
26
IP Pool
ID-NETWORKERS | www.training-mikrotik.com
27
ID-NETWORKERS | www.training-mikrotik.com
28
ID-NETWORKERS | www.training-mikrotik.com
29
DHCP Relay
• DHCP Relay is just like a proxy that receive
DHCP discovery and request and resend them
to the DHCP server
• There can be only one DHCP relay between
DHCP server and DHCP client
• DHCP communication with relay does not
require IP address on the relay,
• But DHCP Relay's “local address” option must
be same with DHCP Server's “relay address”
option
ID-NETWORKERS | www.training-mikrotik.com
30
Ether1 Ether1
192.168.1.1/24 192.168.1.2/24
Ether2
192.168.22.1/24
ID-NETWORKERS | www.training-mikrotik.com
31
ID-NETWORKERS | www.training-mikrotik.com
32
Interface LAN
Configure client as DHCP client at the laptop and it should get IP from DHCP
server
ID-NETWORKERS | www.training-mikrotik.com
33
PROXY
MikroTik HTTP Proxy
ID-NETWORKERS | www.training-mikrotik.com
34
Web Proxy
• Web-proxy have 3 mayor features
– HTTP and FTP traffic caching
– DNS name filtering
– DNS redirection
• Web-proxy have two operation modes
– Regular – browser must be configured to use this
proxy
– Transparent – this proxy is not visible for
customers NAT rules must be applied
ID-NETWORKERS | www.training-mikrotik.com
35
Web Proxy
• Without Proxy
• With Proxy
ID-NETWORKERS | www.training-mikrotik.com
36
ID-NETWORKERS | www.training-mikrotik.com
37
ID-NETWORKERS | www.training-mikrotik.com
38
ID-NETWORKERS | www.training-mikrotik.com
39
ID-NETWORKERS | www.training-mikrotik.com
40
ID-NETWORKERS | www.training-mikrotik.com
41
ID-NETWORKERS | www.training-mikrotik.com
42
ID-NETWORKERS | www.training-mikrotik.com
43
• Special Characters
* = any character/characters
? = one character
• Example
www.do?ai?.com
www.domain.*
*domain*
• Also support regular expression format
ID-NETWORKERS | www.training-mikrotik.com
44
ID-NETWORKERS | www.training-mikrotik.com
45
Web-Proxy Options
• Maximal-client-
connections - number of
connections accepted from
clients
• Maximal-server-
connections - number of
connections made by
server
ID-NETWORKERS | www.training-mikrotik.com
46
Web-Proxy Caching
• No caching
• Max-cache-size = none
• Cache to RAM
• Max-cache-size ≠ none
• Cache-on-disk = no
• Cache to HDD
• Max-cache-size ≠ none
• Cache-on-disk = yes
• Cache drive
• Choose partition
ID-NETWORKERS | www.training-mikrotik.com
47
ID-NETWORKERS | www.training-mikrotik.com
48
FIREWALL
Basic & Advanced
ID-NETWORKERS | www.training-mikrotik.com
49
Connection Tracking
• Connection Tracking is the heart of firewall, it
gathers and manages information about all
active connections.
• By disabling the connection tracking system you
will lose functionality of the NAT and most of the
filter and mangle conditions.
• Each connection tracking table entry represents
bidirectional data exchange
• Connection tracking takes a lot of CPU
resources (disable it, if you don't use firewall)
ID-NETWORKERS | www.training-mikrotik.com
50
Connection State
• Connection state is a status assigned to each packet by
connection tracking system:
– New – packet is opening a new connection
– Established – packet belongs to already known
connection
– Invalid – packet does not belong to any of the known
connections
– Related – packet is also opening a new connection,
but it is in some kind relation to already known
connection
• Connection state not same with TCP state in connection
tracking
ID-NETWORKERS | www.training-mikrotik.com
51
Firewall Basic
• Each firewall filter rules are organized in a chain and read
sequentially.
• Each chain will be read by the router from top to bottom.
• In Firewall Filter Rule there 3 default chain
• input – processes packets sent to the router
• output – processes packets sent by the router
• forward – processes packets sent through the router
• In addition to the 3 default chain, We can make chain by our self as
needed.
• Every user-defined chain should subordinate to at least one of the
default chains
• To implemented the right chain we need to know about packet flow
in the router
ID-NETWORKERS | www.training-mikrotik.com
52
Packet Flow
• Simple Diagram
ID-NETWORKERS | www.training-mikrotik.com
53
Packet Flow
• Diagram showing the process flow of data packets
ID-NETWORKERS | www.training-mikrotik.com
54
Packet Flow
• Traffic going in to the router (input)
ID-NETWORKERS | www.training-mikrotik.com
55
Packet Flow
• Traffic going out from the router itself (output)
ID-NETWORKERS | www.training-mikrotik.com
56
Packet Flow
• Traffic pass-through the router (forward)
ID-NETWORKERS | www.training-mikrotik.com
57
Firewall on Bridge
If we want to use IP Firewall in bridge devices, we need to activate
ID-NETWORKERS | www.training-mikrotik.com
58
Firewall Strategy
• Rule IF….THEN….
• IF packet match with our define criteria.
• THEN what will we do for that packet?
• In IP firewall IF condition define in tab General,
Advanced and Extra, and THEN condition define
in Action tab
ID-NETWORKERS | www.training-mikrotik.com
59
Firewall Strategy
• Drop all unneeded, accept everything else
Firewall Strategy
• Accept only needed, drop everything else
ID-NETWORKERS | www.training-mikrotik.com
61
ID-NETWORKERS | www.training-mikrotik.com
62
ID-NETWORKERS | www.training-mikrotik.com
63
ID-NETWORKERS | www.training-mikrotik.com
64
• count - maximum average packet rate measured in packets per time interval
• time - specifies the time interval in which the packet rate is measured
(optional)
• burst - number of packets which are not counted by packet rate
• mode - the classifier for packet rate limiting
ID-NETWORKERS | www.training-mikrotik.com
65
ID-NETWORKERS | www.training-mikrotik.com
66
ID-NETWORKERS | www.training-mikrotik.com
67
ID-NETWORKERS | www.training-mikrotik.com
68
ID-NETWORKERS | www.training-mikrotik.com
69
ID-NETWORKERS | www.training-mikrotik.com
70
ID-NETWORKERS | www.training-mikrotik.com
71
ID-NETWORKERS | www.training-mikrotik.com
72
IP Firewall Mangle
ID-NETWORKERS | www.training-mikrotik.com
73
IP Firewall Mangle
• Use to IP packet marking and IP header fields
adjustment
• The mangle facility allows to mark IP packets with
special marks.
• These marks are used by other router facilities like
routing and bandwidth management to identify the
packets.
• Additionally, the mangle facility is used to modify some
fields in the IP header, like TOS (DSCP) and TTL fields.
• Mangle will be used by router its self, mean mangle can’t
transfer to another router
ID-NETWORKERS | www.training-mikrotik.com
74
IP Firewall Mangle
• Like IP firewall filter, mangle rules are organized in chains
• There are five built-in chains:
• Prerouting- making a mark before Global-In queue
• Postrouting - making a mark before Global-Out queue
• Input - making a mark before Input filter
• Output - making a mark before Output filter
• Forward - making a mark before Forward filter
• New user-defined chains can be added, as necessary
ID-NETWORKERS | www.training-mikrotik.com
75
ID-NETWORKERS | www.training-mikrotik.com
76
ID-NETWORKERS | www.training-mikrotik.com
77
first packet)
• mark-packet – mark a flow (all packets)
the packet
• change TOS - change type of service
ID-NETWORKERS | www.training-mikrotik.com
78
Mark Connection
• Use mark connection to identify one or group
of connections with the specific connection
mark
• Connection marks are stored in the
connection tracking table
• There can be only one connection mark for
one connection.
• Connection tracking helps to associate each
packet to a specific connection (connection
mark)
ID-NETWORKERS | www.training-mikrotik.com
79
ID-NETWORKERS | www.training-mikrotik.com
80
ID-NETWORKERS | www.training-mikrotik.com
81
ID-NETWORKERS | www.training-mikrotik.com
82
Mark Packet
Packets can be marked
• Indirectly. Using the connection tracking
facility, based on previously created
connection marks (faster)
• Directly. Without the connection tracking
- no connection marks necessary, router
will compare each packet to a given
conditions (this process imitates some of
the connection tracking features)
ID-NETWORKERS | www.training-mikrotik.com
83
Mangle Passtrough
ID-NETWORKERS | www.training-mikrotik.com
84
Mangle Passtrough
ID-NETWORKERS | www.training-mikrotik.com
85
ID-NETWORKERS | www.training-mikrotik.com
86
3,3
ID-NETWORKERS | www.training-mikrotik.com
87
• Mean packet will be counted every 2 packets, and will start with
packet number 0 (first packet)
• NTH counting packet start from 1 but PCC counting packet start
from 0
ID-NETWORKERS | www.training-mikrotik.com
88
3,2
ID-NETWORKERS | www.training-mikrotik.com
89
HTB
Hierarchical Token Bucket
ID-NETWORKERS | www.training-mikrotik.com
90
HTB
• All Quality of Service implementation in
RouterOS is based on Hierarchical Token Bucket
• HTB allows to create hierarchical queue structure
and determine relations between parent and
child queues and relation between child queues
• RouterOS V5 support 3 virtual HTBs (global-in,
global-total, global-out) and one more just before
every interface
ID-NETWORKERS | www.training-mikrotik.com
91
ID-NETWORKERS | www.training-mikrotik.com
92
• When packet travels through the router, it passes all 4 HTB trees
• When packet travels to the router, it passes only global-in and global-total HTB.
• When packet travels from the router, it passes global-out, global-total and interface
HTB.
ID-NETWORKERS | www.training-mikrotik.com
93
HTB
• As soon as queue have at least one child it
become parent queue
• All child queues (don't matter how many levels of
parents they have) are on the same bottom level
of HTB
• Child queues make actual traffic consumption,
parent queues are responsible only for traffic
distribution
• Child queues will get limit-at first and then rest of
the traffic will distributed by parents
ID-NETWORKERS | www.training-mikrotik.com
94
HTB Structure
ID-NETWORKERS | www.training-mikrotik.com
95
HTB Limitation
• HTB has two rate limits:
• CIR (Committed Information Rate) – (limit-at in
ID-NETWORKERS | www.training-mikrotik.com
96
HTB Limitation
• Maximal rate of the parent should be equal or
bigger than sum of committed rates of the
children
• MIR (parent) ≥ CIR(child1) +...+ CIR(childN)
• Maximal rate of any child should be less or
equal to maximal rate of the parent
• MIR (parent) ≥ MIR(child1)
• MIR (parent) ≥ MIR(child2)
• MIR (parent) ≥ MIR(childN)
ID-NETWORKERS | www.training-mikrotik.com
97
HTB Limitation
Max-limit parent should be equal or bigger than
summary of limit-at of the clients
• max-limit(parent) >= limit-at(child1) + .... + limit-
at(child*)
example:
• queue1 – limit-at=512k – parent=parent1
• queue2 – limit-at=512k – parent=parent1
• queue3 – limit-at=512k – parent=parent1
max-limit parent1 at least (512k*3) or 1,5M, if less
than 1,5M max-limit will not work properly
ID-NETWORKERS | www.training-mikrotik.com
98
HTB Limitation
Max-limit parent should be equal or bigger than
summary of limit-at of the clients
• max-limit(parent) >= limit-at(child1) + .... + limit-
at(child*)
example:
• queue1 – limit-at=512k – parent=parent1
• queue2 – limit-at=512k – parent=parent1
• queue3 – limit-at=512k – parent=parent1
max-limit parent1 at least (512k*3) or 1,5M, if less
than 1,5M max-limit will not work properly
ID-NETWORKERS | www.training-mikrotik.com
99
Tips
• Top of the parent no need limit-at and priority
parameter
• Priority only work in the last child, comparing all
of end child
• Priority will be calculate after all limit-at (CIR)
was delivered. And the rest bandwidth will be
distribute by looking the priority of the childs
ID-NETWORKERS | www.training-mikrotik.com
100
Tips
• Top of the parent no need limit-at and priority
parameter
• Priority only work in the last child, comparing all
of end child
• Priority will be calculate after all limit-at (CIR)
was delivered. And the rest bandwidth will be
distribute by looking the priority of the childs
ID-NETWORKERS | www.training-mikrotik.com
101
ID-NETWORKERS | www.training-mikrotik.com
102
• Even max-limit of the parent is 2M, child B and C still can get 2M, that way
max-limit parent >= total limit-at of all clients
• If B not using internet C still cant up until 4M, but still on 2M
ID-NETWORKERS | www.training-mikrotik.com
103
• B will get bandwidth more than limit-at because priority is 1, higher than C
that has priority 8
ID-NETWORKERS | www.training-mikrotik.com
104
ID-NETWORKERS | www.training-mikrotik.com
105
ID-NETWORKERS | www.training-mikrotik.com
106
• If all of limit-at has been fulfilled, the rest of bandwidth will be devided by
priority
ID-NETWORKERS | www.training-mikrotik.com
107
ID-NETWORKERS | www.training-mikrotik.com
108
ID-NETWORKERS | www.training-mikrotik.com
109
ID-NETWORKERS | www.training-mikrotik.com
110
ID-NETWORKERS | www.training-mikrotik.com