MTCTCE
MTCTCE
MTCTCE
Schedule
09:00 10:30 Morning Session I
10:30 11:00 Morning Break
www.LearnMikroTik.ir
LearnMikroTik.ir 2013
Instructor
Housekeeping
Course materials
Routers, cables
Break times and lunch
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
Course Objective
Introduce Yourself
Your name
Your Company
Your previous knowledge about RouterOS
Your previous knowledge about networking
What do you expect from this course?
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
01/08/2014
Class Setup
LearnMikroTik.ir 2013
Small ISP
LearnMikroTik.ir 2013
10
LearnMikroTik.ir 2013
11
LearnMikroTik.ir 2013
12
01/08/2014
LearnMikroTik.ir 2013
13
DHCP
14
LearnMikroTik.ir 2013
15
DHCP Discovery
src-mac=<client>, dst-mac=<broadcast>, protocol=udp,
src-ip=0.0.0.0:68, dst-ip=255.255.255.255:67
DHCP Offer
src-mac=<DHCP-server>, dst-mac=<broadcast>, protocol=udp,
src-ip=<DHCP-server>:67, dst-ip=255.255.255.255:67
DHCP Request
src-mac=<client>, dst-mac=<broadcast>, protocol=udp,
src-ip=0.0.0.0:68, dst-ip=255.255.255.255:67
DHCP Acknowledgement
src-mac=<DHCP-server>, dst-mac=<broadcast>, protocol=udp,
src-ip=<DHCP-server>:67, dst-ip=255.255.255.255:67
LearnMikroTik.ir 2013
16
DHCP Client
17
LearnMikroTik.ir 2013
18
01/08/2014
DHCP Server
DHCP Networks
http://www.iana.org/assignments/bootp-dhcp-parameters
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
19
DHCP Options
20
21
IP Address Pool
LearnMikroTik.ir 2013
22
IP Address Pools
23
LearnMikroTik.ir 2013
24
01/08/2014
LearnMikroTik.ir 2013
25
LearnMikroTik.ir 2013
26
DHCP Server
27
LearnMikroTik.ir 2013
28
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
29
30
01/08/2014
DHCP Relay
DHCP Relay
31
DHCP Lab
Interconnect with your neighbour
Ethernet cable
Create 3 independent setups:
LearnMikroTik.ir 2013
32
33
LearnMikroTik.ir 2013
34
35
LearnMikroTik.ir 2013
36
01/08/2014
Connection Tracking
Conntrack Placement
37
LearnMikroTik.ir 2013
38
39
LearnMikroTik.ir 2013
40
CHAIN INPUT
LearnMikroTik.ir 2013
41
LearnMikroTik.ir 2013
42
01/08/2014
43
RouterOS Services
Nr.
Port
Protocol
Comment
Nr.
Port
Protocol
Comment
20
TCP
21
53
UDP
DNS
21
TCP
22
67
UDP
22
TCP
23
68
UDP
23
TCP
Telnet protocol
24
123
UDP
53
TCP
DNS
25
161
UDP
SNMP
80
TCP
26
500
UDP
179
TCP
27
520
UDP
443
TCP
28
521
UDP
646
TCP
29
646
UDP
10
1080
TCP
30
1701
UDP
11
1723
TCP
PPTP
31
1900
UDP
12
2828
TCP
32
5678
UDP
MNDP
13
2000
TCP
33
20561
UDP
MAC winbox
14
8080
TCP
Web Proxy
34
---
/41
IPv6 (encapsulation)
15
8291
TCP
Winbox
35
---
/47
16
8728
TCP
API
36
---
/50
ESP (IPSec)
17
8729
TCP
API-SSL
37
---
/51
AH (IPSec)
18
---
/1
ICMP
38
---
/89
19
---
/2
Multicast | IGMP
39
---
/103
Multicast | PIM
20
---
/4
IPIP encapsulation
40
---
/112
VRRP
LearnMikroTik.ir 2013
44
45
CHAIN FORWARD
LearnMikroTik.ir 2013
46
Create 3 rules to ensure that only connectionstate new packets will proceed through the
input filter
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
47
01/08/2014
Bogon IPs
49
50
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
51
LearnMikroTik.ir 2013
52
NAT Types
As there are two IP addresses and ports in an
IP packet header, there are two types of NAT
The one, which rewrites source IP address and/or
port is called source NAT (src-nat)
The other, which rewrites destination IP address
and/or port is called destination NAT (dst-nat)
LearnMikroTik.ir 2013
54
01/08/2014
IP Firewall Diagram
55
Dst-nat Action
LearnMikroTik.ir 2013
56
LearnMikroTik.ir 2013
57
Redirect
LearnMikroTik.ir 2013
58
LearnMikroTik.ir 2013
59
LearnMikroTik.ir 2013
60
10
01/08/2014
Redirect Lab
Dst-nat Lab
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
61
Universal Plug-and-Play
62
UPnP
63
Requirements:
Public IP address for
VIP clients
Guaranteed speed for
VIP clients
LearnMikroTik.ir 2013
64
Situation:
You have public IP
address and
/30 subnet of public
addresses,
You sometimes reach
ISP speed limitation
(5Mbps/5Mbps)
LearnMikroTik.ir 2013
Clients:
I love my ISP
Web-server
VIP client 2
VIP client 1
65
LearnMikroTik.ir 2013
66
11
01/08/2014
NAT Helpers
Src-nat Lab
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
67
68
What is Mangle?
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.
FIREWALL MANGLE
LearnMikroTik.ir 2013
69
Mangle Structure
LearnMikroTik.ir 2013
70
71
LearnMikroTik.ir 2013
72
12
01/08/2014
Mangle actions
73
Marking Connections
LearnMikroTik.ir 2013
74
75
Marking Packets
LearnMikroTik.ir 2013
76
77
LearnMikroTik.ir 2013
78
13
01/08/2014
Mangle View
79
LearnMikroTik.ir 2013
80
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 or older versions support 3 virtual
HTBs (global-in, global-total, global-out) and one
more just before every interface
RouterOS v6 support 1 virtual HTB (global) and
one more just before every interface
HTB
LearnMikroTik.ir 2013
81
LearnMikroTik.ir 2013
83
LearnMikroTik.ir 2013
82
LearnMikroTik.ir 2013
84
14
01/08/2014
HTB (cont.)
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
85
86
LearnMikroTik.ir 2013
87
LearnMikroTik.ir 2013
Dual Limitation
88
HTB - limit-at
89
LearnMikroTik.ir 2013
90
15
01/08/2014
HTB - max-limit
LearnMikroTik.ir 2013
91
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
92
93
LearnMikroTik.ir 2013
94
Queue Tree
Queue tree is direct implementation of HTB
Each queue in queue tree can be assigned only in one
HTB
Each child queue must have packet mark assigned to it
Advanced queue structures
QUEUE TREE
LearnMikroTik.ir 2013
95
LearnMikroTik.ir 2013
96
16
01/08/2014
HTB Lab
97
98
LearnMikroTik.ir 2013
99
Situation:
Your network is growing rapidly
and now offer public IPs to the
customers
Requirements:
LearnMikroTik.ir 2013
100
101
LearnMikroTik.ir 2013
102
17
01/08/2014
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
103
104
Burst
105
LearnMikroTik.ir 2013
Burst (Part 2)
106
Web-Proxy
Web-proxy have 3 mayor features
HTTP and FTP traffic caching
DNS name filtering
DNS redirection
107
LearnMikroTik.ir 2013
108
18
01/08/2014
Web-Proxy Caching
Web-Proxy Options
No caching
Maximal-clientconnections: number of
connections accepted
from clients
Maximal-serverconnections: number of
connections made by
server
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
109
Web-Proxy Options
LearnMikroTik.ir 2013
110
Web-Proxy Statistics
111
LearnMikroTik.ir 2013
Proxy Rules
It is
possible
to
intercept HTTP request
based on:
TCP/IP information
URL
HTTP method
Access list also allow
you to redirect denied
request to specific page
112
113
LearnMikroTik.ir 2013
114
19
01/08/2014
URL Filtering
Regular Expressions
http://www.mikrotik.com/docs/ros/2.9/graphics:packet_flow31.jpg
Destination host
Destination path
Special characters
* - any number of any characters
? - any character
www.mi?roti?.com
www.mikrotik*
*mikrotik*
LearnMikroTik.ir 2013
115
LearnMikroTik.ir 2013
Web-Proxy Lab
Next problems
117
Problems:
LearnMikroTik.ir 2013
Ping flood
Port scan
DoS attack
DDoS attack
LearnMikroTik.ir 2013
118
Ping Flood
116
119
Ping
flood
usually
consist from volumes of
random ICMP messages
With limit condition it
is possible to bound the
rule match rate to a
given limit
This condition is often
used with action log
LearnMikroTik.ir 2013
120
20
01/08/2014
LearnMikroTik.ir 2013
121
LearnMikroTik.ir 2013
Port Scan
LearnMikroTik.ir 2013
122
123
LearnMikroTik.ir 2013
124
PSD Lab
DoS Attacks
LearnMikroTik.ir 2013
125
LearnMikroTik.ir 2013
126
21
01/08/2014
127
LearnMikroTik.ir 2013
DDoS attacks
128
A Distributed Denial of
Service attack is very
similar to DoS attack
only it occurs from
multiple compromised
systems
Only thing that could
help is TCPSyn Cookie
option in conntrack
system
129
LearnMikroTik.ir 2013
130
Changing TTL
131
LearnMikroTik.ir 2013
132
22
01/08/2014
Queue Types
100% Shaper
133
100% Scheduler
LearnMikroTik.ir 2013
134
135
LearnMikroTik.ir 2013
FIFO
136
FIFO (Cont.)
Behaviour:
What comes in first is handled first, what comes
in next waits until the first is finished. Number of
waiting units (Packets or Bytes) is limited by
queue size option. If queue is full next units
are dropped
mq-pfifo is pfifo with support for multiple
transmit queues.
LearnMikroTik.ir 2013
137
LearnMikroTik.ir 2013
138
23
01/08/2014
LearnMikroTik.ir 2013
139
LearnMikroTik.ir 2013
140
LearnMikroTik.ir 2013
142
LearnMikroTik.ir 2013
144
RED
Behaviour:
Same as FIFO with feature additional drop
probability even if queue is not full.
This probability is based on
comparison of
average
queue length over some
period of time to minimal
and maximal threshold
closer to maximal threshold
bigger the chance of drop.
LearnMikroTik.ir 2013
141
SFQ
Behaviour:
Based on
hash value from source and
destination address SFQ divides traffic into 1024
sub-streams
Then
Round
Robin
algorithm will distribute
equal amount of traffic to
each sub-stream
LearnMikroTik.ir 2013
143
24
01/08/2014
SFQ Example
PCQ
Behaviour:
Based on classifier PCQ divides traffic into substreams. Each sub-stream can be considered as
FIFO queue with queue size specified by limit
option
After this PCQ can be
considered as FIFO
queue where queue size
is specified by totallimit option.
LearnMikroTik.ir 2013
145
LearnMikroTik.ir 2013
146
LearnMikroTik.ir 2013
147
LearnMikroTik.ir 2013
148
149
LearnMikroTik.ir 2013
150
25
01/08/2014
Packet Sniffer
NTH
LearnMikroTik.ir 2013
LearnMikroTik.ir 2013
151
152
LearnMikroTik.ir 2013
153
26