OSDN Git Service

76b0842d440e992e45860c286690c2b12e4710a5
[opengate/opengate.git] / opengate / doc / en / b.html
1 <html>
2 <head>
3 <title>Opegnate Install</title>
4 <meta http-equiv="content-type" content="text/html;charset=Shift_JIS">
5 <link rel="stylesheet" type="text/css" media="screen" href="style.css">
6 </head>
7
8 <body bgcolor="#BBEECC">
9
10 <!-- Start:Setup ipfw,ip6fw -->
11 <h3>B&nbsp;Setup ipfw,ip6fw<a name="ipfw0" href="#ipfw0" class="anchor">&dagger;</a></h3>
12
13 <ul>
14         <li class="list_num"><a href="#ipfw1">Prepare kernel</a></li>
15         <li class="list_num"><a href="#ipfw2">Setup ipfw</a></li>
16         <li class="list_num"><a href="#ipfw3">Setup ip6fw</a></li>
17 </ul>
18
19 <!-- ************ 1 ************** -->
20 <h4>B.1&nbsp;Prepare kernel<a name="ipfw1" href="#ipfw1" class="anchor">&dagger;</a></h4>
21
22 <p>Prepare kernel having ipfw and ip6fw functions.</p>
23
24 <p>Copy kernel options file.</p>
25
26 <table><tr><td><pre>
27 # cd /usr/src/sys/i386/conf
28 # cp GENERIC MYKERNEL
29 </pre></td></tr></table>
30
31 <p>Add next lines.</p>
32
33 <table><tr><td><pre>
34 options IPDIVERT
35
36 options IPFIREWALL
37 options IPFIREWALL_FORWARD
38 options IPFIREWALL_VERBOSE
39 options IPFIREWALL_VERBOSE_LIMIT=100
40
41 options IPV6FIREWALL
42 options IPV6FIREWALL_VERBOSE
43 options IPV6FIREWALL_VERBOSE_LIMIT=100
44
45 options IPSEC
46 options IPSEC_ESP
47 options TCP_DROP_SYSFIN
48 </pre></td></tr></table>
49
50 <li>When use NAT, IPDIVERT is necessary.</li>
51 <li>When need firewal log, *VERBOSE is necessary.</li>
52 <li>When use IPSEC, *IPSEC is nnecessary.</li>
53
54 <p>compile and install kernel having ipfw and ip6fw functions.</p>
55
56 <table><tr><td><pre>
57 # config MYKERNEL
58 # cd ../compile/MYKERNEL
59 # make depend
60 # make
61 # make install
62 </pre></td></tr></table>
63
64 <p>Add next lines to "/etc/rc.conf".</p>
65
66 <table><tr><td><pre>
67 firewall_enable="YES"
68 firewall_script="/etc/rc.firewall"
69
70 ipv6_firewall_enable="YES"
71 ipv6_firewall_script="/etc/rc.firewall6"
72
73 natd_enable="YES"
74 natd_interface="em0"
75 </pre></td></tr></table>
76
77 <p>Validate a ipfw and ip6fw. And setup configuration script path. 
78 When use NAT, Validate natd and setup natd interface.</p>
79
80 <div align="right"><a href="#ipfw0">top</a></div>
81
82 <!-- ************ 2 ************** -->
83 <h4>B.2&nbsp;Setup ipfw<a name="ipfw2" href="#ipfw2" class="anchor">&dagger;</a></h4>
84
85 <p>Write a rule of ipfw for Opengate. This is example "/etc/rc.firewall".</p>
86
87 <table><tr><td><pre>
88 ### set these to your outside interface network and netmask and ip
89 oif="em0"
90 onet="192.168.0.0"
91 omask="255.255.255.0"
92 oip="192.168.0.34"
93
94 ### set these to your inside interface network and netmask and ip
95 iif="bge0"
96 inet="192.168.55.0"
97 imask="255.255.255.0"
98 iip="192.168.55.1"
99
100 fwcmd="/sbin/ipfw"
101
102 ### divert packet to NATD 
103 $fwcmd add 1 divert natd ip from any to any via ${oif}
104
105 ### Stop spoofing
106 $fwcmd add deny all from ${inet}:${imask} to any in via ${oif}
107 $fwcmd add deny all from ${onet}:${omask} to any in via ${iif}
108
109 ### Stop http from softeather
110 $fwcmd add deny tcp from 192.168.0.0:255.255.255.0 to ${oip} 80
111 $fwcmd add deny tcp from 192.168.0.0:255.255.255.0 to ${oip} 443
112
113 ### Allow from / to myself
114 $fwcmd add pass all from ${iip} to any via ${iif}
115 $fwcmd add pass all from ${oip} to any via ${oif}
116 $fwcmd add pass all from any to ${iip} via ${iif}
117 $fwcmd add pass all from any to ${oip} via ${oif}
118
119 ### Allow DNS queries out in the world
120 ### (if DNS is on localhost, delete passDNS)
121 $fwcmd add pass udp from any 53 to any
122 $fwcmd add pass udp from any to any 53
123 $fwcmd add pass tcp from any to any 53
124 $fwcmd add pass tcp from any 53 to any
125
126 ### Forwarding http connection from unauth client 
127 $fwcmd add 60000 fwd localhost tcp from ${inet}:${imask} to any 80
128 $fwcmd add 60010 fwd localhost tcp from ${inet}:${imask} to any 443
129
130 ### Allow TCP through if setup succeeded 
131 $fwcmd add 60100 pass tcp from any to any established
132 </pre></td></tr></table>
133
134 <p>Rule number for [forward] Command must be larger than the rule numbers used in opengate(10000-40000).
135 Rule number for [divert to natd] must be smaller than most rules.</p>
136
137 <p>The file [conf/opengatefw.conf] is the script describing the above rules.
138  You can edit and use this script instead of rc.firewall. </p>
139
140 <p>Be falimiar with ipfw command. Opengate is a software to send out the ipfw command like above one.</p>
141
142 <div align="right"><a href="#ipfw0">top</a></div>
143
144 <!-- ************ 3 ************** -->
145 <h4>B.3&nbsp;Setup ip6fw<a name="ipfw3" href="#ipfw3" class="anchor">&dagger;</a></h4>
146
147 <p>Write a rule of ip6fw for Opengate. This is example "/etc/rc.firewall6".</p>
148
149 <table><tr><td><pre>
150 ### set these to your outside interface network and prefixlen and ip
151 oif="em0"
152 onet="2001:e38:3661:1a0::"
153 oprefixlen="64"
154 oip="2001:e38:3661:1a0::34"
155
156 ### set these to your inside interface network and prefixlen and ip
157 iif="bge0"
158 inet="2001:e38:3661:1a5::"
159 iprefixlen="64"
160 iip="2001:e38:3661:1a5::1"
161
162 ### path to command "ip6fw"
163 fw6cmd="/sbin/ip6fw"
164
165 ${fw6cmd} add pass all from ${iip} to any
166 ${fw6cmd} add pass all from any to ${iip}
167 ${fw6cmd} add pass all from ${oip} to any
168 ${fw6cmd} add pass all from any to ${oip}
169
170 ### Allow RA RS NS NA Redirect...
171 ${fw6cmd} add pass ipv6-icmp from any to any
172
173 # Allow IP fragments to pass through
174 ${fw6cmd} add pass all from any to any frag
175
176 # Allow RIPng
177 ${fw6cmd} add pass udp from fe80::/10 521 to ff02::9 521
178 ${fw6cmd} add pass udp from fe80::/10 521 to fe80::/10 521
179
180 ### Allow TCP through if setup succeeded
181 ${fw6cmd} add 60100 pass tcp from any to any established
182
183 # TCP reset notice message
184 ${fw6cmd} add 60200 reset tcp from any to any 80
185 ${fw6cmd} add 60300 reset tcp from any to any 443
186 </pre></td></tr></table>
187
188 <p>ip6fw dose not have [forward] function. Threrfore Opengate waits for 
189 timeout of IPv6 HTTP request. And uses [forward] function of ipfw.</p>
190
191 <p>When use FreeBSD 5.2 more, ip6fw has TCP reset function.
192 TCP reset try to send a TCP reset (RST) notice.</p>
193
194 <p>The file [conf/opengatefw6.conf] is the script describing the above rules.
195  You can edit and use this script instead of rc.firewall6. </p>
196
197 <p>Be falimiar with ip6fw command too.</p>
198
199
200 <div align="right"><a href="#ipfw0">top</a></div>
201
202 </body>
203 </html>