Firewall PDF
Firewall PDF
Table of Contents
Table of Contents
General Information
Summary
Quick Setup Guide
Specifications
Related Documents
Description
Packet Flow
Description
Firewall Rules
Description
Property Description
Notes
Example
Firewall Chains
Description
Notes
Example
IP Firewall Applications
Description
Example of Firewall Filters
Protecting the Customer's Network
Enforcing the 'Internet Policy'
Example of Source NAT (Masquerading)
Example of Destination NAT
General Information
Summary
•
! "#$
%
/ip firewall rule forward add dst-port=135 protocol=tcp action=drop
Page 1 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• & ! '#(
%
/ip firewall rule input add protocol=tcp dst-port=23 action=drop
Specifications
Packages required: system
License required: level1 (P2P filters limited to 1), level3
Home menu level: /ip firewall
Standards and Technologies: IP
Hardware usage: Increases with filtering rules count
Related Documents
• ! )
• *! +!
• + ,- ) + ! +
•
• ! ) &)(
Description
.
/
0 1 2
3
) + 41
-
Packet Flow
Description
) + 41
*
5
*!
%
%
%
Page 2 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• *
7
• .
-
*! 7
& 8
id est
(
Firewall Rules
Home menu level: /ip firewall rule <chain name>
Description
)
* .57
0
* )! <!,% 49, *
Page 3 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• • 3:4 - Fragmentation-DF-Set
! ):
•
>* )! ,2+- ,2+
•
>02,7 ! 2:
•
):>* )! 3
29321
• 5
Type of Service
* -
exempli gratia
?
?
*
41
Property Description
action (accept | drop | jump | passthrough | reject | return; default: accept) - action to undertake if
the packet matches the rule, one of the:
Page 4 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• accept - accept the packet. No action, i.e., the packet is passed through without undertaking any
action, except for mangle, and no more rules are processed in the relevant list/chain
• drop - silently drop the packet (without sending the ICMP reject message)
• jump - jump to the chain specified by the value of the jump-target argument
• passthrough - ignore this rule, except for mangle, go on to the next one. Acts the same way as
a disabled rule, except for ability to count and mangle packets
• reject - reject the packet and send an ICMP reject message
• return - return to the previous chain, from where the jump took place
comment (text; default: "") - a descriptive comment for the rule
connection (text; default: "") - connection mark to match. Only connections (including related)
marked in the MANGLE would be matched
connection-limit (integer; default: 0) - match the number of concurrent connections from each
particular IP address
connection-state (any | established | invalid | new | related; default: any) - connection state
content (text; default: "") - the text packets should contain in order to match the rule
disabled (yes | no; default: no) - specifies whether the rule is disabled or not
dst-address (IP address/mask:port; default: 0.0.0.0/0:0-65535) - destination IP address
dst-netmask (IP address) - destination netmask in decimal form x.x.x.x
dst-port (integer: 0..65535) - destination port number or range
• 0 - all ports 1-65535
flow (text) - flow mark to match. Only packets marked in the MANGLE would be matched
icmp-options (integer; default: any:any) - matches ICMP Type:Code fields
in-interface (name; default: all) - interface the packet has entered the router through.
• all - may include the local loopback interface for packets originated from the router
jump-target (name) - name of the target chain, if the action=jump is used
limit-burst (integer; default: 0) - allowed burst regarding the limit-count/limit-time, measuret in
bits/s
limit-count (integer; default: 0) - how many times to use the rule during the limit-time period
limit-time (time; default: 0) - time interval measured in seconds, used in conjunction with
limit-count
• 0 - forever
log (yes | no; default: no) - specifies to log the action or not
out-interface (name; default: name) - interface the packet is leaving the router from
• all - may include the local loopback interface for packets with destination to the router
p2p (any | all-p2p | bit-torrent | direct-connect | fasttrack | soulseek | blubster | edonkey | gnutella |
warez; default: any) - match Peer-to-Peer (P2P) connections:
• all-p2p - match all known P2P traffic
• any - match any packet (i.e., do not check this property)
protocol (ah | egp | ggp | icmp | ipencap | ospf | rspf | udp | xtp | all | encap | gre | idpr-cmtp | ipip |
pup | st | vmtp | ddp | esp | hmp | igmp | iso-tp4 | rdp | tcp | xns-idp; default: all) - protocol setting
Page 5 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• all - cannot be used, if you want to specify ports
src-address (IP address/mask:port; default: 0.0.0.0/0:0-65535) - source IP address
src-mac-address (MAC address; default: 00:00:00:00:00:00) - host's MAC address the packet has
been received from
src-netmask (IP address) - source netmask in decimal form x.x.x.x
src-port (integer: 0..65535) - source port number or range (0-65535)
• 0 - all ports 1-65535
tcp-options (any | syn-only | non-syn-only; default: any) - TCP options
tos (<integer> | dont-change | low-cost | low-delay | max-reliability | max-throughput | normal | any
| integer; default: any) - specifies a match to the value of Type of Service (ToS) field of IP header:
• any - match any packet (i.e., do not check this property)
Notes
Example
3
/
dst-port=8080%
/ip firewall rule input add dst-port=8080 protocol=tcp action=reject
[admin@MikroTik] ip firewall rule input> print
Flags: X - disabled, I - invalid
0 src-address=0.0.0.0/0:0-65535 in-interface=all
dst-address=0.0.0.0/0:8080 out-interface=all protocol=tcp
icmp-options=any:any tcp-options=any connection-state=any flow=""
sconnection="" content="" rc-mac-address=00:00:00:00:00:00 limit-count=0
limit-burst=0 limit-time=0s action=reject log=no
@
*! %
Firewall Chains
Home menu level: /ip firewall
Description
*
0
7
*!
*!
)
*!
Page 6 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
• input
!
input
• forward
• output
! output
.
*
*
:
)
jump
none
&
(
Notes
5 input output F <
drop
Example
[admin@MikroTik] ip firewall> print
# NAME POLICY
0 input accept
1 forward accept
2 output accept
[admin@MikroTik] ip firewall> add name=router
[admin@MikroTik] ip firewall> print
# NAME POLICY
0 input accept
1 forward accept
2 output accept
3 router none
Page 7 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
IP Firewall Applications
Description
*
*!
7
6
*
%
3
6
!
non-syn-only
,7
%
Page 8 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
•
*
"D'"BCG"A
•
* )!
6 7 "D'"BCG"A
Page 9 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
add action=drop log=yes comment="Drop and log everything else"
*!
6
0 /
%
/ip firewall rule forward
add out-interface=Local action=jump \
jump-target=customer
Local &
6
(
customer
6 * 7 "D'"BCG"A
%
/ip firewall rule forward
add connection-state=invalid action=drop \
comment="Drop invalid connection packets"
add connection-state=established \
comment="Allow established connections"
add connection-state=related \
comment="Allow related connections"
add protocol=icmp out-interface=Public \
comment="Allow ICMP ping packets"
add src-address=192.168.0.17/32 out-interface=Public \
comment="Allow outgoing connections from the server at 192.168.0.17"
add action=drop out-interface=Public log=yes \
comment="Drop and log everything else"
*
?? 0 "D'"BCGG8'@ ?? "GGG'"A
*1! &
,7
(
&
- ( )
-
*!
"D'"BCGG8'@ "GGG'"A
Page 10 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.
&( ) + ! %
"GGG'"A%CG
0 % "D'"BCG@%CG 4
- %
/ip firewall dst-nat add action=nat protocol=tcp \
dst-address=10.0.0.217/32:80 to-dst-address=192.168.0.4
Page 11 of 11
Copyright 1999-2006, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.