انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية تكنولوجيا المعلومات
القسم قسم شبكات المعلومات
المرحلة 3
أستاذ المادة علاء عبد الحسين مهدي كريم
02/03/2015 10:00:31
manual:ip/firewall/nat 1 manual:ip/firewall/nat applies to routeros: v3, v4 + summary sub-menu: /ip firewall nat network address translation is an internet standard that allows hosts on local area networks to use one set of ip addresses for internal communications and another set of ip addresses for external communications. a lan that uses nat is referred as natted network. for nat to function, there should be a nat gateway in each natted network. the nat gateway (nat router) performs ip address rewriting on the way a packet travel from/to lan. there are two types of nat: • source nat or srcnat. this type of nat is performed on packets that are originated from a natted network. a nat router replaces the private source address of an ip packet with a new public ip address as it travels through the router. a reverse operation is applied to the reply packets travelling in the other direction. • destination nat or dstnat. this type of nat is performed on packets that are destined to the natted network. it is most comonly used to make hosts on a private network to be acceesible from the internet. a nat router performing dstnat replaces the destination ip address of an ip packet as it travel through the router towards a private network. hosts behind a nat-enabled router do not have true end-to-end connectivity. therefore some internet protocols might not work in scenarios with nat. services that require the initiation of tcp connection from outside the private network or stateless protocols such as udp, can be disrupted. moreover, some protocols are inherently incompatible with nat, a bold example is ah protocol from the ipsec suite. to overcome these limitations routeros includes a number of so-called nat helpers, that enable nat traversal for various protocols. properties property description action (action name default: accept) action to take if packet is matched by the rule: manual:ip/firewall/nat 2 • accept - accept the packet. packet is not passed to next nat rule. • add-dst-to-address-list - add destination address to address list specified by address-list parameter • add-src-to-address-list - add source address to address list specified by address-list parameter • dst-nat - replaces destination address and/or port of an ip packet to values specified by to-addresses and to-ports parameters • jump - jump to the user defined chain specified by the value of jump-target parameter • log - add a message to the system log containing following data: in-interface, out-interface, src-mac, protocol, src-ip:port->dst-ip:port and length of the packet. after packet is matched it is passed to next rule in the list, similar as passthrough • masquerade - replace source address of an ip packet to ip determined by routing facility. • netmap - creates a static 1:1 mapping of one set of ip addresses to another one. often used to distribute public ip addresses to hosts on private networks • passthrough - ignore this rule and go to next one (useful for statistics). • redirect - replaces destination port of an ip packet to one specified by to-ports parameter and destination address to one of the router s local addresses • return - passes control back to the chain from where the jump took place • same - gives a particular client the same source/destination ip address from supplied range for each connection. this is most frequently used for services that expect the same client address for multiple connections from the same client • src-nat - replaces source address of an ip packet to values specified by to-addresses and to-ports parameters address-list (string default: ) name of the address list to be used. applicable if action is add-dst-to-address-list or add-src-to-address-list address-list-timeout (time default: 00:00:00) time interval after which the address will be removed from the address list specified by address-list parameter. used in conjunction with add-dst-to-address-list or add-src-to-address-list actions value of 00:00:00 will leave the address in the address list forever chain (name default: ) specifies to which chain rule will be added. if the input does not match the name of an already defined chain, a new chain will be created. comment (string default: ) descriptive comment for the rule. connection-bytes (integer-integer default: ) matches packets only if a given amount of bytes has been transfered through the particular connection. 0 - means infinity, for example connection-bytes=2000000-0 means that the rule matches if more than 2mb has been transfered through the relevant connection connection-limit (integer,netmaks default: ) restrict connection limit per address or address block/td> connection-mark (no-mark | string default: ) matches packets marked via mangle facility with particular connection mark. if no-mark is set, rule will match any unmarked connection. connection-rate (integer 0..4294967295 default: ) connection rate is a firewall matcher that allow to capture traffic based on present speed of the connection. read more>> manual:ip/firewall/nat 3 connection-state (estabilished | invalid | new | related default: ) interprets the connection tracking analysis data for a particular packet: • established - a packet which belongs to an existing connection • invalid - a packet which could not be identified for some reason • new - a packet which begins a new connection • related - a packet which is related to, but not part of an existing connection, such as icmp errors or a packet which begins ftp data connection connection-type (ftp | h323 | irc | pptp | quake3 | sip | tftp default: ) matches packets from related connections based on information from their connection tracking helpers. a relevant connection helper must be enabled under /ip firewall service-port content (string default: ) match packets that contain specified text dscp (integer: 0..63 default: ) matches dscp ip header field. dst-address (ip/netmask | ip range default: ) matches packets which destination is equal to specified ip or falls into specified ip range. dst-address-list (name default: ) matches destination address of a packet against user-defined address list dst-address-type (unicast | local | broadcast | multicast default: ) matches destination address type: • unicast - ip address used for point to point transmission • local - if dst-address is assigned to one of router s interfaces • broadcast - packet is sent to all devices in subnet • multicast - packet is forwarded to defined group of devices dst-limit (integer,time,integer,dst-address | dst-port | src-address, time default: ) matches packets within given pps limit. as opposed to the limit matcher, every destination ip address / destination port has it s own limit. parameters are written in following format: count,time,burst,mode,expire. • count - maximum average packet rate measured in packets per time interval • time - specifies the time interval in which the packet rate is measured • burst - number of packets which are not counted by packet rate • mode - the classifier for packet rate limiting • expire - specifies interval after which recored ip address /port will be deletingd dst-port (integer[-integer]: 0..65535 default: ) list of destination port numbers or port number ranges fragment (yes|no default: ) matches fragmented packets. first (starting) fragment does not count. if connection tracking is enabled there will be no fragments as system automatically assembles every packet hotspot (auth | from-client | http | local-dst | to-client default: ) icmp-options (integer:integer default: ) matches icmp type:code fileds in-bridge-port (name default: ) actual interface the packet has entered the router, if incoming interface is bridge in-interface (name default: ) interface the packet has entered the router ingress-priority (integer: 0..63 default: ) matches ingress priority of the packet. priority may be derived from vlan, wmm or mpls exp bit. read more>> manual:ip/firewall/nat 4 ipv4-options (any | loose-source-routing | no-record-route | no-router-alert | no-source-routing | no-timestamp | none | record-route | router-alert | strict-source-routing | timestamp default: ) matches ipv4 header options. • any - match packet with at least one of the ipv4 options • loose-source-routing - match packets with loose source routing option. this option is used to route the internet datagram based on information supplied by the source • no-record-route - match packets with no record route option. this option is used to route the internet datagram based on information supplied by the source • no-router-alert - match packets with no router alter option • no-source-routing - match packets with no source routing option • no-timestamp - match packets with no timestamp option • record-route - match packets with record route option • router-alert - match packets with router alter option • strict-source-routing - match packets with strict source routing option • timestamp - match packets with timestamp jump-target (name default: ) name of the target chain to jump to. applicable only if action=jump layer7-protocol (name default: ) layer7 filter name defined in layer7 protocol menu. limit (integer,time,integer default: ) matches packets if given pps limit is exceeded. parameters are written in following format: count,time,burst. • count - maximum average packet rate measured in packets per time interval • time - specifies the time interval in which the packet rate is measured • burst - number of packets which are not counted by packet rate log-prefix (string default: ) adds specified text at the beginning of every log message. applicable if action=log nth (integer,integer default: ) matches every nth packet. read more >> out-bridge-port (name default: ) actual interface the packet is leaving the router, if outgoing interface is bridge out-interface ( default: ) interface the packet is leaving the router packet-mark (no-mark | string default: ) matches packets marked via mangle facility with particular packet mark. if no-mark is set, rule will match any unmarked packet. packet-size (integer[-integer]:0..65535 default: ) matches packets of specified size or size range in bytes. per-connection-classifier (valuestohash:denominator/remainder default: ) pcc matcher allows to divide traffic into equal streams with ability to keep packets with specific set of options in one particular stream. read more >> port (integer[-integer]: 0..65535 default: ) matches if any (source or destination) port matches the specified list of ports or port ranges. applicable only if protocol is tcp or udp protocol (name or protocol id default: tcp) matches particular ip protocol specified by protocol name or number psd (integer,time,integer,integer default: ) attempts to detect tcp and udp scans. parameters are in following format weightthreshold, delaythreshold, lopportweight, highportweight • weightthreshold - total weight of the latest tcp/udp packets with different destination ports coming from the same host to be treated as port scan sequence • delaythreshold - delay for the packets with different destination ports coming from the same host to be treated as possible port scan subsequence • lowportweight - weight of the packets with privileged (<=1024) destination port • highportweight - weight of the packet with non-priviliged destination port random (integer: 1..99 default: ) matches packets randomly with given probability. manual:ip/firewall/nat 5 routing-mark (string default: ) matches packets marked by mangle facility with particular routing mark same-not-by-dst (yes | no default: ) specifies whether to take into account or not destination ip address when selecting a new source ip address. applicable if action=same src-address (ip/netmaks, ip range default: ) matches packets which source is equal to specified ip or falls into specified ip range. src-address-list (name default: ) matches source address of a packet against user-defined address list src-address-type (unicast | local | broadcast | multicast default: ) matches source address type: • unicast - ip address used for point to point transmission • local - if address is assigned to one of router s interfaces • broadcast - packet is sent to all devices in subnet • multicast - packet is forwarded to defined group of devices src-port (integer[-integer]: 0..65535 default: ) list of source ports and ranges of source ports. applicable only if protocol is tcp or udp. src-mac-address (mac address default: ) matches source mac address of the packet tcp-flags (ack | cwr | ece | fin | psh | rst | syn | urg default: ) matches specified tcp flags • ack - acknowledging data • cwr - congestion window reduced • ece - ecn-echo flag (explicit congestion notification) • fin - close connection • psh - push function • rst - droping connection • syn - new connection • urg - urgent data tcp-mss (integer: 0..65535 default: ) matches tcp mss value of an ip packet time (time-time,sat | fri | thu | wed | tue | mon | sun default: ) allows to create filter based on the packets arrival time and date or, for locally generated packets, departure time and date to-addresses (ip address[-ip address] default: 0.0.0.0) replace original address with specified one. applicable if action is dst-nat, netmap, same, src-nat to-ports (integer[-integer]: 0..255 default: ) replace original port with specified one. applicable if action is dst-nat, redirect, netmap, same, src-nat ttl (integer: 0..255 default: ) matches packets ttl value /ip firewall nat print stats will show additional read-only properties property description bytes (integer) total amount of bytes matched by the rule packets (integer) total amount of packets matched by the rule by default print is equivalent to print static and shows only static rules. [admin@dzeltenais_burkaans] /ip firewall mangle> print stats flags: x - disabled, i - invalid, d - dynamic # chain action bytes packets 0 prerouting mark-routing 17478158 127631 1 prerouting mark-routing 782505 4506 to print also dynamic rules use print all. [admin@dzeltenais_burkaans] /ip firewall mangle> print all stats flags: x - disabled, i - invalid, d - dynamic manual:ip/firewall/nat 6 # chain action bytes packets 0 prerouting mark-routing 17478158 127631 1 prerouting mark-routing 782505 4506 2 d forward change-mss 0 0 3 d forward change-mss 0 0 4 d forward change-mss 0 0 5 d forward change-mss 129372 2031 or to print only dynamic rules use print dynamic [admin@dzeltenais_burkaans] /ip firewall mangle> print stats dynamic flags: x - disabled, i - invalid, d - dynamic # chain action bytes packets 0 d forward change-mss 0 0 1 d forward change-mss 0 0 2 d forward change-mss 0 0 3 d forward change-mss 132444 2079 property description reset-counters (id) reset statistics counters for specified firewall rules. reset-counters-all () reset statistics counters for all firewall rules. basic examples if you want to "hide" the private lan 192.168.0.0/24 "behind" one address 10.5.8.109 given to you by the isp, you should use the source network address translation (masquerading) feature of the mikrotik router. the masquerading will change the source ip address and port of the packets originated from the network 192.168.0.0/24 to the address 10.5.8.109 of the router when the packet is routed through it. to use masquerading, a source nat rule with action masquerade should be added to the firewall configuration: /ip firewall nat add chain=srcnat action=masquerade out-interface=public all outgoing connections from the network 192.168.0.0/24 will have source address 10.5.8.109 of the router and source port above 1024. no access from the internet will be possible to the local addresses. if you want to allow connections to the server on the local network, you should use destination network address translation (nat). if you want to link public ip 10.5.8.200 address to local one 192.168.0.109, you should use destination address translation feature of the mikrotik router. also if you want allow local server to talk with outside with given public ip you should use source address translation, too. add public ip to public interface: /ip address add address=10.5.8.200/32 interface=public add rule allowing access to the internal server from external networks: /ip firewall nat add chain=dstnat dst-address=10.5.8.200 action=dst-nat \ to-addresses=192.168.0.109 add rule allowing the internal server to talk to the outer networks having its source address translated to 10.5.8.200: /ip firewall nat add chain=srcnat src-address=192.168.0.109 action=src-nat \ to-addresses=10.5.8.200 manual:ip/firewall/nat 7 if you want to link public ip subnet 11.11.11.0/24 to local one 2.2.2.0/24, you should use destination address translation and source address translation features with action=netmap. /ip firewall nat add chain=dstnat dst-address=11.11.11.1-11.11.11.254 \ action=netmap to-addresses=2.2.2.1-2.2.2.254 /ip firewall nat add chain=srcnat src-address=2.2.2.1-2.2.2.254 \ action=netmap to-addresses=11.11.11.1-11.11.11.254 if you would like to direct requests for a certain port to an internal machine (sometimes called opening a port, port mapping), you can do it like this: /ip firewall nat add chain=dstnat dst-port=1234 action=dst-nat protocol=tcp to-address=192.168.1.1 to-port=1234 this rule translates to: when an incoming connection requests tcp port 1234, use the dst-nat action and redirect it to local address 192.168.1.1 and the port 1234 [ top | back to content ] article sources and contributors 8 article sources and contributors manual:ip/firewall/nat source: http://wiki.mikrotik.com/index.php?oldid=23043 contributors: janisk, marisb, normis, sergejsb image sources, licenses and contributors image:version.png source: http://wiki.mikrotik.com/index.php?title=file:version.png license: unknown contributors: normis
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|