⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shorewall-nesting.5

📁 sharewall is very good
💻 5
字号:
.\"     Title: shorewall-nesting.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author].\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/>.\"      Date: 03/19/2009.\"    Manual: [FIXME: manual].\"    Source: [FIXME: source].\"  Language: English.\".TH "SHOREWALL\-NESTING" "5" "03/19/2009" "[FIXME: source]" "[FIXME: manual]".\" -----------------------------------------------------------------.\" * (re)Define some macros.\" -----------------------------------------------------------------.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" toupper - uppercase a string (locale-aware).\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de toupper.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\\$*.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz...\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" SH-xref - format a cross-reference to an SH section.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de SH-xref.ie n \{\.\}.toupper \\$*.el \{\\\$*.\}...\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" SH - level-one heading that works better for non-TTY output.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de1 SH.\" put an extra blank line of space above the head in non-TTY output.if t \{\.sp 1.\}.sp \\n[PD]u.nr an-level 1.set-an-margin.nr an-prevailing-indent \\n[IN].fi.in \\n[an-margin]u.ti 0.HTML-TAG ".NH \\n[an-level]".it 1 an-trap.nr an-no-space-flag 1.nr an-break-flag 1\." make the size of the head bigger.ps +3.ft B.ne (2v + 1u).ie n \{\.\" if n (TTY output), use uppercase.toupper \\$*.\}.el \{\.nr an-break-flag 0.\" if not n (not TTY), use normal case (not uppercase)\\$1.in \\n[an-margin]u.ti 0.\" if not n (not TTY), put a border/line under subheading.sp -.6\l'\n(.lu'.\}...\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" SS - level-two heading that works better for non-TTY output.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de1 SS.sp \\n[PD]u.nr an-level 1.set-an-margin.nr an-prevailing-indent \\n[IN].fi.in \\n[IN]u.ti \\n[SN]u.it 1 an-trap.nr an-no-space-flag 1.nr an-break-flag 1.ps \\n[PS-SS]u\." make the size of the head bigger.ps +2.ft B.ne (2v + 1u).if \\n[.$] \&\\$*...\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" BB/BE - put background/screen (filled box) around block of text.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de BB.if t \{\.sp -.5.br.in +2n.ll -2n.gcolor red.di BX.\}...de EB.if t \{\.if "\\$2"adjust-for-leading-newline" \{\.sp -1.\}.br.di.in.ll.gcolor.nr BW \\n(.lu-\\n(.i.nr BH \\n(dn+.5v.ne \\n(BHu+.5v.ie "\\$2"adjust-for-leading-newline" \{\\M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[].\}.el \{\\M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[].\}.in 0.sp -.5v.nf.BX.in.sp .5v.fi.\}...\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.\" BM/EM - put colored marker in margin next to block of text.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.de BM.if t \{\.br.ll -2n.gcolor red.di BX.\}...de EM.if t \{\.br.di.ll.gcolor.nr BH \\n(dn.ne \\n(BHu\M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[].in 0.nf.BX.in.fi.\}...\" -----------------------------------------------------------------.\" * set default formatting.\" -----------------------------------------------------------------.\" disable hyphenation.nh.\" disable justification (adjust text to left margin only).ad l.\" -----------------------------------------------------------------.\" * MAIN CONTENT STARTS HERE *.\" -----------------------------------------------------------------.SH "Name"nesting \- Shorewall Nested Zones.SH "Synopsis".fam C.HP \w'\ 'u\fIchild\-zone\fR[:\fIparent\-zone\fR[,\fIparent\-zone\fR]\&.\&.\&.].fam.SH "Description".PPIn\m[blue]\fBshorewall\-zones\fR\m[]\&\s-2\u[1]\d\s+2(5), a zone may be declared to be a sub\-zone of one or more other zones using the above syntax\&..PPWhere zones are nested, the CONTINUE policy in\m[blue]\fBshorewall\-policy\fR\m[]\&\s-2\u[2]\d\s+2(5) allows hosts that are within multiple zones to be managed under the rules of all of these zones\&..SH "Example".PP\FC/etc/shorewall/zones\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE    TYPE        OPTION        fw       firewall        net      ipv4        sam:net  ipv4        loc      ipv4.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PP\FC/etc/shorewall/interfaces\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE     INTERFACE     BROADCAST     OPTIONS        \-         eth0          detect        dhcp,norfc1918        loc       eth1          detect.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PP\FC/etc/shorewall/hosts\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE     HOST(S)                     OPTIONS        net       eth0:0\&.0\&.0\&.0/0        sam       eth0:206\&.191\&.149\&.197.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PP\FC/etc/shorewall/policy\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #SOURCE      DEST        POLICY       LOG LEVEL        loc          net         ACCEPT        sam          all         CONTINUE        net          all         DROP         info        all          all         REJECT       info.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPThe second entry above says that when Sam is the client, connection requests should first be processed under rules where the source zone is sam and if there is no match then the connection request should be treated under rules where the source zone is net\&. It is important that this policy be listed BEFORE the next policy (net to all)\&. You can have this policy generated for you automatically by using the IMPLICIT_CONTINUE option in\m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[3]\d\s+2(5)\&..PPPartial\FC/etc/shorewall/rules\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ACTION   SOURCE    DEST            PROTO    DEST PORT(S)        \&.\&.\&.        DNAT      sam       loc:192\&.168\&.1\&.3 tcp      ssh        DNAT      net       loc:192\&.168\&.1\&.5 tcp      www        \&.\&.\&..EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPGiven these two rules, Sam can connect to the firewall\'s internet interface with ssh and the connection request will be forwarded to 192\&.168\&.1\&.3\&. Like all hosts in the net zone, Sam can connect to the firewall\'s internet interface on TCP port 80 and the connection request will be forwarded to 192\&.168\&.1\&.5\&. The order of the rules is not significant\&. Sometimes it is necessary to suppress port forwarding for a sub\-zone\&. For example, suppose that all hosts can SSH to the firewall and be forwarded to 192\&.168\&.1\&.5 EXCEPT Sam\&. When Sam connects to the firewall\'s external IP, he should be connected to the firewall itself\&. Because of the way that Netfilter is constructed, this requires two rules as follows:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ACTION   SOURCE    DEST            PROTO    DEST PORT(S)        \&.\&.\&.        ACCEPT+   sam       $FW             tcp      ssh        DNAT      net       loc:192\&.168\&.1\&.3 tcp      ssh        \&.\&.\&..EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPThe first rule allows Sam SSH access to the firewall\&. The second rule says that any clients from the net zone with the exception of those in the \(lqsam\(rq zone should have their connection port forwarded to 192\&.168\&.1\&.3\&. If you need to exclude more than one zone, simply use multiple ACCEPT+ rules\&. This technique also may be used when the ACTION is REDIRECT\&..PPCare must be taken when nesting occurs as a result of the use of wildcard interfaces (interface names ends in \'+\')\&..PPHere\'s an example\&.\FC/etc/shorewall/zones\F[]:.PP\FC/etc/shorewall/interfaces\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE    INTERFACE      BROADCAST        OPTIONS        net      ppp0        loc      eth1        loc      ppp+        dmz      eth2.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPBecause the net zone is declared before the loc zone, net is an implicit sub\-zone of loc and in the absence of a net\->\&.\&.\&. CONTINUE policy, traffic from the net zone will not be passed through loc\->\&.\&.\&. rules\&. But DNAT and REDIRECT rules are an exception!.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}DNAT and REDIRECT rules generate two Netfilter rules: a \'nat\' table rule that rewrites the destination IP address and/or port number, and a \'filter\' table rule that ACCEPTs the rewritten connection\&..RE.sp.RS 4.ie n \{\\h'-04'\(bu\h'+03'\c.\}.el \{\.sp -1.IP \(bu 2.3.\}Policies only affect the \'filter\' table\&..RE.PPAs a consequence, the following rules will have unexpected behavior:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ACTION     SOURCE               DEST      PROTO        DEST        #                                                       PORT(S)        ACCEPT      net                  dmz       tcp          80        REDIRECT    loc                  3128      tcp          80.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPThe second rule is intended to redirect local web requests to a proxy running on the firewall and listening on TCP port 3128\&. But the \'nat\' part of that rule will cause all connection requests for TCP port 80 arriving on interface ppp+ (including ppp0!) to have their destination port rewritten to 3128\&. Hence, the web server running in the DMZ will be inaccessible from the web\&..PPThe above problem can be corrected in several ways\&..PPThe preferred way is to use the\fBifname\fRpppd option to change the \'net\' interface to something other than ppp0\&. That way, it won\'t match ppp+\&..PPIf you are running Shorewall version 4\&.1\&.4 or later, a second way is to simply make the nested zones explicit:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE    TYPE        OPTION        fw       firewall        loc      ipv4        net:loc  ipv4        dmz      ipv4.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPIf you take this approach, be sure to set IMPLICIT_CONTINUE=No in\FCshorewall\&.conf\F[]\&..PPWhen using other Shorewall versions, another way is to rewrite the DNAT rule (assume that the local zone is entirely within 192\&.168\&.2\&.0/23):.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ACTION     SOURCE                 DEST      PROTO      DEST        #                                                       PORT(S)        ACCEPT      net                    dmz       tcp        80        REDIRECT    loc:192\&.168\&.2\&.0/23     3128      tcp        80.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PPAnother way is to restrict the definition of the loc zone:.PP\FC/etc/shorewall/interfaces\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE    INTERFACE      BROADCAST        OPTIONS        net      ppp0        loc      eth1        \-        ppp+        dmz      eth2.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.PP\FC/etc/shorewall/hosts\F[]:.sp.if n \{\.RS 4.\}.fam C.ps -1.nf.BB lightgray        #ZONE    HOST(S)             OPTIONS        loc      ppp+:192\&.168\&.2\&.0/23.EB lightgray.fi.fam.ps +1.if n \{\.RE.\}.SH "FILES".PP/etc/shorewall/zones.PP/etc/shorewall/interfaces.PP/etc/shorewall/hosts.PP/etc/shorewall/policy.PP/etc/shorewall/rules.SH "See ALSO".PPshorewall(8), shorewall\-accounting(5), shorewall\-actions(5), shorewall\-blacklist(5), shorewall\-hosts(5), shorewall\-interfaces(5), shorewall\-ipsec(5), shorewall\-maclist(5), shorewall\-masq(5), shorewall\-nat(5), shorewall\-netmap(5), shorewall\-params(5), shorewall\-policy(5), shorewall\-providers(5), shorewall\-proxyarp(5), shorewall\-route_rules(5), shorewall\-routestopped(5), shorewall\-rules(5), shorewall\&.conf(5), shorewall\-tcclasses(5), shorewall\-tcdevices(5), shorewall\-tcrules(5), shorewall\-tos(5), shorewall\-tunnels(5), shorewall\-zones(5).SH "Notes".IP " 1." 4shorewall-zones.RS 4\%http://www.shorewall.net/manpages/shorewall-zones.html.RE.IP " 2." 4shorewall-policy.RS 4\%http://www.shorewall.net/manpages/shorewall-policy.html.RE.IP " 3." 4shorewall.conf.RS 4\%http://www.shorewall.net/manpages/shorewall.conf.html.RE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -