OSDN Git Service

Ver.1.4.38: Modified english document.
[opengate/opengate.git] / opengate / doc / en / install.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4         <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
5         <TITLE>Opengate Install</TITLE>
6
7 </HEAD>
8 <BODY LANG="en-US" BGCOLOR="#fafff0" DIR="ltr">
9 <H2><A href="#top" name=top><FONT SIZE=4>Opengate Installation
10 Procedure</FONT></A></H2>
11
12 <!-- Start:content table -->
13 <UL>
14         <LI><A href="#outline0">Outline</A>
15                 
16         <UL>
17                 <LI><A href="#outline1">System Configuration</A>  </LI>
18                 <LI><A href="#outline2">Installation Procedure</A>  </LI>
19                 <LI><A href="#outline3">Support Page</A></LI>
20         </UL>
21         <LI><A href="#freebsd0">FreeBSD Installation</A>  </LI>
22         <UL>
23                 <LI><A href="#freebsd1">Basic Installation</A>  </LI>
24                 <LI><A href="#freebsd2">Adding NAT and Firewall</A>  </LI>
25                 <LI><A href="#freebsd3">Setting up IPv6</A></LI>
26         </UL>
27         <LI><A href="#bind0">BIND9 Installation (Optional)</A>  </LI>
28         <UL>
29                 <LI><A href="#bind1">Ports Installation</A> </LI>
30                 <LI><A href="#bind2">Making RNDC Key</A> </LI>
31                 <LI><A href="#bind3">Setting up named.conf</A>  </LI>
32                 <LI><A href="#bind4">Creating a Zone file</A>  </LI>
33                 <LI><A href="#bind5">Checking Behavior</A></LI>
34         </UL>
35         <LI><A href="#dhcp0">isc-dhcp3 Installation (Optional)</A> 
36         <UL>
37                 <LI><A href="#dhcp1">Ports Installation</A> </LI>
38                 <LI><A href="#dhcp2">Setting up DHCP</A></LI>
39         </UL>
40         <LI><A href="#apache0">Apache2 Installation</A> </LI>
41         <UL>
42                 <LI><A href="#apache1">Ports Installation</A> </LI>
43                 <LI><A href="#apache2">Making Certificates</A>  </LI>
44                 <LI><A href="#apache3">Setting up VirtualHost</A>  </LI>
45                 <LI><A href="#apache4">Other Settings and Checking the Installation</A></LI>
46         </UL>
47         <LI><A href="#opengate0">Opengate Installation</A> </LI>
48         <UL>
49                 <LI><A href="#opengate1">Opengate Package</A>  </LI>
50                 <LI><A href="#opengate2">Installation</A> </LI>
51                 <LI><A href="#opengate3">Setting up Config File</A>  </LI>
52                 <LI><A href="#opengate4">Setting up IPFW</A>  </LI>
53                 <LI><A href="#opengate5">Setting up Syslog</A>  </LI>
54                 <LI><A href="#opengate6">Checking Behavior</A>  </LI>
55                 <LI><A href="#opengate7">Modifying Pages</A>  </LI>
56                         </UL>
57         <LI><A href="#mrtg0">MRTG Install(Optional)</A>  </LI>
58         <UL>
59                 <LI><A href="#mrtg1">Ports Installation</A> </LI>
60                 <LI><A href="#mrtg2">Setting up MRTG</A> </LI>
61                 <LI><A href="#mrtg3">Confirming MRTG Startup Operation</A> </LI>
62                 <LI><A href="#mrtg4">Registering to Crontab</A> </LI>
63         </UL>
64         <LI><A href="#rulechk">rulechk Installation (Optional)</A> </LI>
65 </UL>
66
67 <BR><BR>
68 <P></P><!-- End:content table --><!-- Start:Outline -->
69
70
71 <H3><A href="#outline0" name=outline0>A&nbsp;Outline</A></H3>
72 <UL>
73         <LI><A href="#outline1">System Configuration</A>  </LI>
74
75         <LI><A href="#outline2">Installation Procedure</A> </LI>
76 </UL>
77
78 <H4><!-- ************1************* -->
79 <A href="#outline1" name=outline1>A.1&nbsp;System
80 Configuration</A></H4>
81 <UL>
82         <LI>Gateway Machine </LI>
83         <UL>
84                 <LI>FreeBSD Ver 4.x, 5.x, 6.x or 7.x </LI>
85                 <LI>Having two or more NICs </LI>
86         </UL></LI>
87 </UL>
88 <P>In this document, we use the system configuration as follows. The
89 network connecting terminals is called "lower-side network" and
90 the network having servers is called "upper-side network".</P>
91 <TABLE CELLPADDING=2 CELLSPACING=2>
92         <TR>
93                 <TD>
94                         <PRE>upper-side network:192.168.0.0/24, 2001:1:2:3/64
95 Gateway to upper-side network:fxp1, 192.168.0.124, 2001:1:2:3::4
96 Gateway to lower-side network:fxp0, 192.168.1.1, 2001:5:6:7::1
97 lower-side network:192.168.1.0/24, 2001:5:6:7/64</PRE>
98                 </TD>
99         </TR>
100 </TABLE>
101 <P>Opengate recognizes both IPv4 and IPv6 addresses, and controls
102 both firewalls. It can be used for IPv4 control only if the FreeBSD
103 environment is not set up for IPv6.</P>
104
105
106 <H4><!-- ***********2************** -->
107 <A href="#outline2" name=outline2>A.2&nbsp;Installation
108 Procedure</A></H4>
109 <P>The following steps are necessary to complete the installation of
110 Opengate. <BR>Items marked with '*' are mandatory.</P>
111 <UL>
112         <LI>FreeBSD Installation&nbsp;* </LI>
113
114         <LI>Adding the Firewall&nbsp;* </LI>
115
116         <LI>BIND9 Installation and Setup </LI>
117
118         <LI>DHCP Installation and Setup </LI>
119
120         <LI>Apache2 Installation and Setup&nbsp;*</LI>
121
122         <LI>Opengate Installation and Setup&nbsp;*</LI>
123 </UL>
124
125
126 <H4><!-- ***********3************** -->
127 <A href="#outline3" name=outline3>A.2&nbsp;Support Page</A></H4>
128 <P STYLE="MARGIN-BOTTOM: 0in">The Opengate support page can be
129 consulted at: 
130 </P>
131 <TABLE CELLPADDING=2 CELLSPACING=2>
132         <TR>
133                 <TD>
134                         <PRE>  http://www.cc.saga-u.ac.jp/opengate/index-e.html</PRE>
135                 </TD>
136         </TR>
137 </TABLE>
138 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#outline0">back</A>&nbsp;<A href="#top">top</A></P>
139 <HR>
140
141
142 <!-- Start:FreeBSD Install-->
143 <H3><A href="#freebsd0" name=freebsd0>B&nbsp;FreeBSD Installation</A></H3>
144 <UL>
145         <LI><A href="#freebsd1">Basic Installation</A> </LI>
146         <LI><A href="#freebsd2">Adding NAT and Firewall</A> </LI>
147         <LI><A href="#freebsd3">Setting up IPv6</A> </LI>
148 </UL>
149
150
151 <H4><!-- ************1************* -->
152 <A href="#freebsd1" name=freebsd1>B.1&nbsp;Basic Installation</A></H4>
153
154 <P>Use FreeBSD4.x or later. FreeBSD6.1 or later is preferred. <BR>Choose
155 distribution "Developer (Full sources, binaries and doc)" or
156 "all" because we have to compile a custom kernel.</P>
157 <P>Add the following line to "/etc/rc.conf", to enable the
158 gateway function:</P>
159 <TABLE CELLPADDING=2 CELLSPACING=2>
160         <TR>
161                 <TD>
162                         <P><CODE>gateway_enable="YES"</CODE></P>
163                 </TD>
164         </TR>
165 </TABLE>
166 <P ALIGN=right><A href="#freebsd0">back</A>&nbsp;<A href="#top">top</A></P>
167
168
169 <H4><!-- ************ 2 ************** --><A href="#freebsd2" name=freebsd2>B.2&nbsp;Adding
170 NAT and Firewall</A></H4>
171 <P>Preparing the kernel to include IPFW and IP6FW functionality.</P>
172 <P>Copy the kernel configuration file:</P>
173 <TABLE CELLPADDING=2 CELLSPACING=2>
174         <TR>
175                 <TD>
176                         <PRE># cd /usr/src/sys/i386/conf
177 # cp GENERIC MYKERNEL</PRE>
178                 </TD>
179         </TR>
180 </TABLE>
181 <P>Add the following lines to the kernel configuration file:</P>
182 <P>A. FreeBSD6.0 or earlier</P>
183 <TABLE CELLPADDING=2 CELLSPACING=2>
184         <TR>
185                 <TD>
186                         <PRE>options IPDIVERT
187
188 options IPFIREWALL
189 options IPFIREWALL_FORWARD
190 options IPFIREWALL_VERBOSE
191 options IPFIREWALL_VERBOSE_LIMIT=100
192
193 options IPV6FIREWALL
194 options IPV6FIREWALL_VERBOSE
195 options IPV6FIREWALL_VERBOSE_LIMIT=100
196
197 options IPSEC
198 options IPSEC_ESP
199 options TCP_DROP_SYNFIN</PRE>
200                 </TD>
201         </TR>
202 </TABLE>
203 <P>B. FreeBSD6.1 or later</P>
204 <TABLE CELLPADDING=2 CELLSPACING=2>
205         <TR>
206                 <TD>
207                         <PRE>options IPDIVERT
208
209 options IPFIREWALL
210 options IPFIREWALL_FORWARD
211 options IPFIREWALL_VERBOSE
212 options IPFIREWALL_VERBOSE_LIMIT=100
213
214 options IPSEC
215 device crypto</PRE>
216                 </TD>
217         </TR>
218 </TABLE>
219 <P>compile and install the new kernel (incl. added support for IPFW
220 and IP6FW).</P>
221 <TABLE CELLPADDING=2 CELLSPACING=2>
222 <TR><TD>
223 <PRE>#cd /usr/src
224 #make buildkernel KERNCONF=MYKERNEL
225 #make installkernel KERNCONF=MYKERNEL
226 </PRE>
227 </TD></TR>
228 </TABLE>
229 <P>It might be failed in old FreeBSD.&nbsp;&nbsp;In the case, execute the following.</P>
230 <TABLE CELLPADDING=2 CELLSPACING=2>
231 <TR><TD>
232 <PRE># config MYKERNEL
233 # cd ../compile/MYKERNEL
234 # make depend
235 # make
236 # make install</PRE>
237 </TD></TR>
238 </TABLE>
239 <P>"make clean" might be requested before "make
240 depend". 
241 </P>
242 <P>Add the following lines to "/etc/rc.conf":</P>
243 <P>a. FreeBSD6.0 or earlier</P>
244 <TABLE CELLPADDING=2 CELLSPACING=2>
245         <TR>
246                 <TD>
247                         <PRE>firewall_enable="YES"
248 firewall_script="/etc/rc.firewall"
249 firewall_type="open"
250
251 ipv6_firewall_enable="YES"
252 ipv6_firewall_script="/etc/rc.firewall6"
253 ipv6_firewall_type="open"
254
255 natd_enable="YES"
256 natd_interface="fxp1"</PRE>
257                 </TD>
258         </TR>
259 </TABLE>
260 <P>b. FreeBSD6.1 or later</P>
261 <TABLE CELLPADDING=2 CELLSPACING=2>
262         <TR>
263                 <TD>
264                         <PRE>firewall_enable="YES"
265 firewall_script="/etc/rc.firewall"
266 firewall_type="open"
267
268 natd_enable="YES"
269 natd_interface="fxp1"</PRE>
270                 </TD>
271         </TR>
272 </TABLE>
273 <P>When enabling IPFW (and IP6FW), make sure
274 to also set the firewall_type to 'OPEN', to prevent  unpredictable
275 system behavior during installation. <BR>To enable NAT, set
276 natd_enable to 'YES' and define the natd interface (Upper-side
277 interface).</P>
278 <P>Connect a client pc to the lower-side
279 network and check the IPv4 behavior.<BR>Since DHCP is not yet set up,
280 the client's network settings must be configured manually.</P>
281 <P ALIGN=right><A href="#freebsd0">back</A>&nbsp;<A href="#top">top</A></P>
282
283
284 <H4><!-- ************ 3 ************** -->
285 <A href="#freebsd3" name=freebsd3>B.3&nbsp;Setting up IPv6</A></H4>
286 <P>If you need IPv4 only, this section can
287 be skipped. <BR>Though explanation is omitted, many parameters, like
288 the ones used in the following sample, can be set in /etc/rc.conf.
289 <BR>It is advised to read up on IPv6 and carefully set up its
290 parameters. 
291 </P>
292 <TABLE CELLPADDING=2 CELLSPACING=2>
293         <TR>
294                 <TD>
295                         <PRE>##ENABLE IPv6
296 ipv6_enable="YES"
297 ipv6_network_interfaces="gif0 fxp0"
298
299 ##TUNNELLING INTERFACE
300 gif_interfaces="gif0"
301 gifconfig_gif0="192.168.0.124 192.168.0.126"
302
303 ##IPv6 ADDRESS 
304 ipv6_prefix_fxp0="2001:5:6:7"
305 ipv6_ifconfig_fxp0="2001:5:6:7::1 prefixlen 64"
306
307 ##ADVERTISE
308 rtadvd_enable="YES"
309 rtadvd_interfaces="fxp0"
310
311 ##DEFAULT GATEWAY
312 ipv6_default_interface="gif0"
313 ipv6_defaultrouter="fe80::a:b:c:d%gif0"
314
315 ##ROUTING(RIPv6)
316 ipv6_gateway_enable="YES"
317 ipv6_router_enable="YES"
318 ipv6_router="/usr/sbin/route6d"
319 ipv6_router_flags="-O 2001:5:6:7::/64,gif0"</PRE>
320                 </TD>
321         </TR>
322 </TABLE>
323 <P>Connect a client pc to the lower-side
324 network and check the behavior of IPv6.<BR>On a Windows pc, the
325 command "ipv6 install" might be needed to activate IPv6.</P>
326 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#ipfw0">back</A>&nbsp;<A href="#top">top</A></P>
327 <HR>
328
329
330 <H3><!-- Start:BIND9 Install --><A href="#bind0" name=bind0>C&nbsp;BIND9
331 Install(Optional)</A></H3>
332 <UL>
333         <LI><A href="#bind1">Ports Install</A></LI>
334         <LI><A href="#bind2">Making RNDC Key</A></LI>
335         <LI><A href="#bind3">Setting up named.conf</A></LI>
336         <LI><A href="#bind4">Creating up a Zone file</A> </LI>
337         <LI><A href="#bind5">Checking Behavior</A> </LI>
338 </UL>
339
340
341 <H4><!-- ********** 1 *********** -->
342 <A href="#bind1" name=bind1>C.1&nbsp;Ports Install</A></H4>
343
344 <P>     You can ignore DNS
345 settings, if you control with IP address base
346 or use existing DNS servers.</P>
347 <P>     Installing BIND9 from
348 ports:<BR>      
349 Note: The "sysinstall" command can also be used.</P>
350 <TABLE CELLPADDING=2 CELLSPACING=2>
351         <TR>
352                 <TD>
353                         <PRE># cd /usr/ports/dns/bind9/
354 # make clean
355 # make install clean ; rehash</PRE>
356                 </TD>
357         </TR>
358 </TABLE>
359 <P>During installation  the directory "/etc/namedb
360 (/var/named/etc/namedb)" is created.</P>
361 <P ALIGN=right><A href="#bind0">back</A>&nbsp;<A href="#top">top</A></P>
362
363
364 <H4><!-- ********** 2 ********** -->
365 <A href="#bind2" name=bind2>C.2&nbsp;Making RNDC key</A></H4>
366 <P>Use the "rndc" command to further secure BIND9.</P>
367 <P>Create the rndc key as follows:</P>
368 <TABLE CELLPADDING=2 CELLSPACING=2>
369         <TR>
370                 <TD>
371                         <PRE># cd /etc/namebd/
372 # rndc-confgen -b 512 &gt; rndc.conf</PRE>
373                 </TD>
374         </TR>
375 </TABLE>
376 <P>This will generate the "rndc.conf" file.</P>
377 <TABLE CELLPADDING=2 CELLSPACING=2>
378         <TR>
379                 <TD>
380                         <PRE># Start of rndc.conf
381 key "rndc-key" {
382         algorithm hmac-md5;
383         secret "wMpASEmnRVnD602MtEb+RqtMee5+n0RVgpaUrlAHvPpgH3SoK7f2nRZBUH7a0urvmyBuAg0dwtk/Otg9Ker3gA==";
384 };
385
386 options {
387         default-key "rndc-key";
388         default-server 127.0.0.1;
389         default-port 953;
390 };
391 # End of rndc.conf
392
393 # Use with the following in named.conf, adjusting the allow list as needed:
394 # key "rndc-key" {
395 #       algorithm hmac-md5;
396 #       secret "wMpASEmnRVnD602MtEb+RqtMee5+n0RVgpaUrlAHvPpgH3SoK7f2nRZBUH7a0urvmyBuAg0dwtk/Otg9Ker3gA==";
397 # };
398
399 # controls {
400 #       inet 127.0.0.1 port 953
401 #               allow { 127.0.0.1; } keys { "rndc-key"; };
402 # };
403 # End of named.conf</PRE>
404                 </TD>
405         </TR>
406 </TABLE>
407 <P ALIGN=right><A href="#bind0">back</A>&nbsp;<A href="#top">top</A></P>
408
409
410 <H4><!-- ********* 3 ********* -->
411 <A href="#bind3" name=bind3>C.3&nbsp;Setting up named.conf</A></H4>
412 <P>After installation,  look for the
413 "/etc/namedb/named.conf" file and copy the last half of the
414 "rndc.conf" file to it, making sure to remove comments, and
415 add IPv6 configuration where/if required.</P>
416 <TABLE CELLPADDING=2 CELLSPACING=2>
417         <TR>
418                 <TD>
419                         <PRE># Use with the following in named.conf, adjusting the allow list as needed:
420 key "rndc-key" {
421         algorithm hmac-md5;
422         secret "wMpASEmnRVnD602MtEb+RqtMee5+n0RVgpaUrlAHvPpgH3SoK7f2nRZBUH7a0urvmyBuAg0dwtk/Otg9Ker3gA==";
423 };
424
425 controls {
426         inet ::1 port 953 allow { ::1; } keys { "rndc-key"; };
427         inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; };
428 };
429 # End of named.conf</PRE>
430                 </TD>
431         </TR>
432 </TABLE>
433 <P>For security reasons, it is better to write the "key"
434 directive in the other file.</P>
435 <P>Edit the "options" directive in "named.conf":</P>
436 <TABLE CELLPADDING=2 CELLSPACING=2>
437         <TR>
438                 <TD>
439                         <PRE>options {
440         directory "/etc/namedb";
441         pid-file "/var/run/named/pid";
442         auth-nxdomain yes;
443         listen-on-v6 { any; };
444 };</PRE>
445                 </TD>
446         </TR>
447 </TABLE>
448 <P>Create the corresponding "pid" directory.</P>
449 <P ALIGN=right><A href="#bind0">back</A>&nbsp;<A href="#top">top</A></P>
450
451
452 <H4><!-- ******** 4 ********* -->
453 <A href="#bind4" name=bind4>C.4&nbsp;Creating a  Zone file</A></H4>
454 <P>Edit the "view" and "zone" directives in "named.conf".</P>
455 <P>The "view" directive is implemented in BIND9. Replying
456 to the inquiries from matched-clients, BIND9 sends the information as
457 described in the corresponding "view"</P>
458 <TABLE CELLPADDING=2 CELLSPACING=2>
459         <TR>
460                 <TD>
461                         <PRE>view "og" {
462         match-clients
463         {
464         192.168.1.0/24;
465         };
466
467         recursion yes;
468
469         zone "." {
470                 type hint;
471                 file "named.root";
472         };
473
474         zone "og.saga-u.ac.jp" {
475                 type master;
476                 file "og.saga-u.ac.jp";
477         };
478
479         zone "0.0.127.IN-ADDR.ARPA" {
480                 type master;
481                 file "master/localhost.rev";
482         };
483
484         // RFC 3152
485         zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.\
486               0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA" {
487                 type master;
488                 file "master/localhost-v6.rev";
489         };
490
491         // RFC 1886 -- deprecated
492         zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.\
493               0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" {
494                 type master;
495                 file "master/localhost-v6.rev";
496         };
497 };</PRE>
498                 </TD>
499         </TR>
500 </TABLE>
501 <P><BR>Make a "zone" file for the domain "og.saga-u.ac.jp".
502 <BR>The domain name and IPv4/6 addresses should be modified properly.
503 If you don't need IPv6, remove the line containing "AAAA ....".</P>
504 <TABLE CELLPADDING=2 CELLSPACING=2>
505         <TR>
506                 <TD>
507                         <PRE>$TTL    3600
508 $ORIGIN og.saga-u.ac.jp.
509
510 @       IN      SOA     ns.og.saga-u.ac.jp. postmaster (
511                         2005051702 ;
512                         3600
513                         1200
514                         2419200
515                         86400 )
516                 IN      NS      ns.og.saga-u.ac.jp.
517                 IN      A       192.168.1.1
518                 IN      MX      10 opengate.og.saga-u.ac.jp.
519
520 ns              IN      A       192.168.1.1
521
522 opengate        IN      A       192.168.1.1
523                         AAAA    2001:5:6:7::1</PRE>
524                 </TD>
525         </TR>
526 </TABLE>
527 <P ALIGN=right><A href="#bind0">back</A>&nbsp;<A href="#top">top</A></P>
528
529
530 <H4><!-- ********* 5 ********* -->
531 <A href="#bind5" name=bind5>C.5&nbsp;Checking Behavior</A></H4>
532 <P>Confirm starting of "named" after completings its
533 configuration.</P>
534 <TABLE CELLPADDING=2 CELLSPACING=2>
535         <TR>
536                 <TD>
537                         <PRE># /usr/local/sbin/named -u bind -c /etc/namedb/named.conf</PRE>
538                 </TD>
539         </TR>
540 </TABLE>
541 <P>If "named" starts without problems, add the following
542 lines to "/etc/rc.conf" to allow it to automatically start
543 on boot up.</P>
544 <TABLE CELLPADDING=2 CELLSPACING=2>
545         <TR>
546                 <TD>
547                         <PRE>named_enable="YES"
548 named_program="/usr/local/sbin/named"
549 named_flags="-u bind -c /etc/namedb/named.conf"</PRE>
550                 </TD>
551         </TR>
552 </TABLE>
553 <P>Because the management of a DNS server
554 can be complicated,  it is strongly advised to carefully read the
555 BIND9 manual, and/or consult other documentation.</P>
556 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#bind0">back</A>&nbsp;<A href="#top">top</A></P>
557
558
559 <HR>
560 <H3><!-- Start:isc-dhcp3 Install -->
561 <A href="#dhcp0" name=dhcp0>D&nbsp;isc-dhcp3 Installation (Optional)</A></H3>
562 <UL>
563         <LI><A href="#dhcp1">Ports Installation</A> 
564         <LI><A href="#dhcp2">Setting up DHCP</A> </LI>
565 </UL>
566
567
568 <H4><!-- *********** 1 ************* -->
569 <A href="#dhcp1" name=dhcp1>D.1&nbsp;Ports Install</A></H4>
570 <P>If many client PCs are going to be
571 connected, using the DHCP service might be a desirable solution for
572 assigning IP addresses to these clients.</P>
573 <P>Installing isc-dhcp3 from ports:<BR>Note:
574 the "sysinstall" command can also be used.</P>
575 <TABLE CELLPADDING=2 CELLSPACING=2>
576         <TR>
577                 <TD>
578                         <PRE># cd /usr/ports/net/isc-dhcp3-server
579 # make clean
580 # make install clean ; rehash</PRE>
581                 </TD>
582         </TR>
583 </TABLE>
584 <P ALIGN=right><A href="#dhcp0">back</A>&nbsp;<A href="#top">top</A></P>
585
586
587 <H4><!-- ************ 2 ************** -->
588 <A href="#dhcp2" name=dhcp2>D.2&nbsp;Setting up DHCP</A></H4>
589 <P>The"/usr/local/etc/dhcpd.conf.sample"
590  configuration file is created during installation. <BR>Copy
591 "dhcpd.conf.sample" to "dhcpd.conf" and edit the
592 file. <BR><BR>The following is an example setup: <BR>The lease time
593 must be greater than the maximum usage duration (Duration/Max in
594 opengatesrv.conf).<BR>The domain name and IP addresses should be
595 modified. 
596 </P>
597 <TABLE CELLPADDING=2 CELLSPACING=2>
598         <TR>
599                 <TD>
600                         <PRE>option domain-name "og.saga-u.ac.jp";
601 option domain-name-servers 192.168.1.1;
602 option subnet-mask 255.255.255.0;
603 option broadcast-address 192.168.1.255;
604 option routers 192.168.1.1;
605
606 default-lease-time 86400;
607 max-lease-time 604800;
608 ddns-update-style none;
609 log-facility local7;
610
611 subnet 192.168.55.0 netmask 255.255.255.0 {
612   range 192.168.1.10 192.168.1.250;
613 }</PRE>
614                 </TD>
615         </TR>
616 </TABLE>
617 <P>Add the following lines to "/etc/rc.conf" to allow it to
618 automatically start on boot up.</P>
619 <TABLE CELLPADDING=2 CELLSPACING=2>
620         <TR>
621                 <TD>
622                         <PRE>dhcpd_enable="YES"
623 dhcpd_ifaces="fxp0"
624 dhcpd_conf="/usr/local/etc/dhcpd.conf"</PRE>
625                 </TD>
626         </TR>
627 </TABLE>
628 <P>In this example, the value of
629 "dhcpd_ifaces" is the interface providing the DHCP service
630 <BR>(to the lower-side network).</P>
631 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#dhcp0">back</A>&nbsp;<A href="#top">top</A></P>
632 <HR>
633
634
635 <H3><!-- Start:Apache2 Install--><A href="#apache0" name=apache0>E&nbsp;Apache2
636 Installation</A></H3>
637 <UL>
638         <LI><A href="#apache1">Ports Installation</A> </LI>
639         <LI><A href="#apache2">Making Certificates</A> </LI>
640         <LI><A href="#apache3">Setting up SSL</A></LI>
641         <LI><A href="#apache4">Other Settings and Checking the installation</A> </LI>
642 </UL>
643
644
645 <H4><!-- ************ 1 ************** --><A href="#apache1" name=apache1>E.1&nbsp;Ports
646 Install</A></H4>
647 <P>When using IPv6, Opengate needs Apache2
648 to support IPv6. <BR>By default, Apache2 supports SSL which is
649 preferred for secure authentication.</P>
650 <P>Installing Apache2 from ports:<BR>Note:
651 The "sysinstall" command can also be used.</P>
652 <TABLE CELLPADDING=2 CELLSPACING=2>
653         <TR>
654                 <TD>
655                         <PRE># cd /usr/ports/www/apache22
656 # make clean
657 # make install clean ; rehash</PRE>
658                 </TD>
659         </TR>
660 </TABLE>
661 <P ALIGN=right><A href="#apache0">back</A>&nbsp;<A href="#top">top</A></P>
662
663
664 <H4><!-- ************ 2 ************** --><A href="#apache2" name=apache2>E.2&nbsp;Making
665 Certificates</A></H4>
666 <P>It is better to obtain a formal key from
667 some CA. But we will show you how to create a self-signed private key
668 and certificate. 
669 </P>
670 <P>Creating a private key:</P>
671 <TABLE CELLPADDING=2 CELLSPACING=2>
672         <TR>
673                 <TD>
674                         <PRE># cd /usr/local/etc/apache22
675 # mkdir ssl.key ssl.crt
676 # chmod 700 ssl.key ssl.crt
677
678 # /usr/bin/openssl genrsa -out /usr/local/etc/apache22/server.key 1024</PRE>
679                 </TD>
680         </TR>
681 </TABLE>
682 <P><BR>Making a certificate from the created key:</P>
683 <TABLE CELLPADDING=2 CELLSPACING=2>
684         <TR>
685                 <TD>
686                         <PRE># /usr/bin/openssl req -new -x509 -days 365 \
687     -key /usr/local/etc/apache22/server.key \
688     -out /usr/local/etc/apache22/server.crt
689
690 You are about to be asked to enter information that will be incorporated
691 into your certificate request.
692 What you are about to enter is what is called a Distinguished Name or a DN.
693 There are quite a few fields but you can leave some blank
694 For some fields there will be a default value,
695 If you enter '.', the field will be left blank.
696 -----
697 Country Name (2 letter code) [AU]:JP
698 State or Province Name (full name) [Some-State]:Saga
699 Locality Name (eg, city) []:Saga-city
700 Organization Name (eg, company) [Internet Widgits Pty Ltd]:Saga-university
701 Organizational Unit Name (eg, subsection) []:Opengate Management
702 Common Name (eg, YOUR name) []:opengate.og.saga-u.ac.jp
703 Email Address []:administrator@opengate.og.saga-u.ac.jp
704
705 Please enter the following 'extra' attributes
706 to be sent with your certificate request
707 A challenge password []:
708 An optional company name []:</PRE>
709                 </TD>
710         </TR>
711 </TABLE>
712 <P ALIGN=right><A href="#apache0">back</A>&nbsp;<A href="#top">top</A></P>
713
714
715 <H4><!-- ************ 3 ************** --><A href="#apache3" name=apache3>E.3&nbsp;
716 Setting up SSL</A></H4>
717 <P>Edit "/usr/local/etc/apache22/extra/httpd-ssl.conf" as
718 shown in the following example:</P>
719 <TABLE CELLPADDING=2 CELLSPACING=2>
720         <TR>
721                 <TD>
722                         <P>ssl.conf 
723                         </P>
724                 </TD>
725         </TR>
726         <TR>
727                 <TD>
728                         <PRE>&lt;VirtualHost _default_:443&gt;
729     DocumentRoot "/usr/local/www/apache22/data"
730     ServerName opengate.og.saga-u.ac.jp:443
731     ServerAdmin administrator@opengate.og.saga-u.ac.jp
732     ErrorLog "|/usr/bin/logger -p local6.info"
733     CustomLog "|/usr/bin/logger -p local5.info" combined
734
735     SSLEngine on
736     SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
737     SSLCertificateFile /usr/local/etc/apache22/server.crt
738     SSLCertificateKeyFile /usr/local/etc/apache22/server.key
739 &lt;/VirtualHost&gt;</PRE>
740                 </TD>
741         </TR>
742 </TABLE>
743 <P>Since Apache2 has many settings,
744 familiarize yourself with the Apache2 configuration options for
745 adequate control.</P>
746 <P ALIGN=right><A href="#apache0">back</A>&nbsp;<A href="#top">top</A></P>
747
748
749 <H4><!-- ************ 4 ************** --><A href="#apache4" name=apache4>E.4&nbsp;Other
750 Settings and Checking the Installation</A></H4>
751 <P>Edit "/usr/local/etc/apache22/httpd.conf" as follows:</P>
752 <P>Opengate should send back the
753 authentication page in response to any kind of HTTP request. <BR>To
754 do so, add the following line to httpd.conf: <BR> (the top page will
755 be sent back on an HTTP_ERROR 404 [file not found] error).</P>
756 <TABLE CELLPADDING=2 CELLSPACING=2>
757         <TR>
758                 <TD>
759                         <PRE>ErrorDocument 404 /</PRE>
760                 </TD>
761         </TR>
762 </TABLE>
763 <P><BR>Add "ExecCGI" to allow executing CGI programs in the
764 cgi-bin directory.</P>
765 <TABLE CELLPADDING=2 CELLSPACING=2>
766         <TR>
767                 <TD>
768                         <PRE>&lt;Directory "/usr/local/www/cgi-bin"&gt;
769     ...
770     Options ExecCGI
771     ...
772 &lt;/Directory&gt;</PRE>
773                 </TD>
774         </TR>
775 </TABLE>
776 <P>Remove the comment mark ("#") to
777 enable the following setting: 
778 </P>
779 <TABLE CELLPADDING=2 CELLSPACING=2>
780         <TR>
781                 <TD>
782                         <PRE>AddHandler cgi-script .cgi
783 AddHandler type-map .var</PRE>
784                 </TD>
785         </TR>
786 </TABLE>
787 <P>Add "index.html.var" to
788 DirectoryIndex: 
789 </P>
790 <TABLE CELLPADDING=2 CELLSPACING=2>
791         <TR>
792                 <TD>
793                         <PRE>DirectoryIndex index.html.var index.html</PRE>
794                 </TD>
795         </TR>
796 </TABLE>
797 <P>Include ssl conf file:</P>
798 <TABLE CELLPADDING=2 CELLSPACING=2>
799         <TR>
800                 <TD>
801                         <PRE>Include etc/apache22/extra/httpd-ssl.conf</PRE>
802                 </TD>
803         </TR>
804 </TABLE>
805 <P>Set ServerName: 
806 </P>
807 <TABLE CELLPADDING=2 CELLSPACING=2>
808         <TR>
809                 <TD>
810                         <PRE>ServerName opengate.og.saga-u.ac.jp</PRE>
811                 </TD>
812         </TR>
813 </TABLE>
814 <P>Start Apache2 with "apachectl start"
815 and check for errors. <BR>If no errors are displayed, add the
816 following lines to "/etc/rc.conf" to allow Apache to start
817 on boot up:</P>
818 <TABLE CELLPADDING=2 CELLSPACING=2>
819         <TR>
820                 <TD>
821                         <PRE>apache22_enable="YES"
822 apache22ssl_enable="YES"</PRE>
823                 </TD>
824         </TR>
825 </TABLE>
826 <P>If the system shows "Failed to
827 enable the 'httpready' Accept Filter", add the following to
828 /boot/loader.conf :</P>
829 <TABLE CELLPADDING=2 CELLSPACING=2>
830         <TR>
831                 <TD>
832                         <PRE>accf_http_load="YES"</PRE>
833                 </TD>
834         </TR>
835 </TABLE>
836 <P>Should the certificate require a PASSPHRASE, Apache will ask for it during
837 boot up.<BR> If you do not enter the passphrase (reboot due to
838 power outage, remote reboot, ,...), this will prevent <BR> the server from starting Apache normally, 
839 i.e. leaving you with a possible "crippled" server.</P>
840 <BLOCKQUOTE>
841 <P>
842 Easy fix:<BR>
843 1. create a simple script containing the following:<BR>
844 #!/bin/sh<BR>
845 echo "&lt;passphrase goes here&gt;"<BR>
846 <BR>2. add the following to     httpd.conf:<BR>
847 SSLPassPhraseDialog exec:/path/to/above/script
848 </P></BLOCKQUOTE>
849
850 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#apache0">back</A>&nbsp;<A href="#top">top</A></P>
851
852
853 <HR>
854 <H3><!-- Start:Opengate Install -->
855 <A href="#opengate0" name=opengate0>F&nbsp;Opengate Installation</A></H3>
856 <UL>
857         <LI><A href="#opengate1">Opengate Package</A> 
858         <LI><A href="#opengate2">Installation</A> </LI>
859         <LI><A href="#opengate3">Setting up Config File</A> </LI>
860         <LI><A href="#opengate4">Setting up IPFW</A> </LI>
861         <LI><A href="#opengate5">Setting up syslog</A> </LI>
862         <LI><A href="#opengate6">Checking Behavior</A> </LI>
863         <LI><A href="#opengate7">Modifying Pages</A> </LI>
864 </UL>
865
866
867 <H4><!-- ************1************* -->
868 <A href="#opengate1" name=opengate1>F.1&nbsp;Opengate
869 Package</A></H4>
870 <P>Unpack the Opengate compressed file: 
871 </P>
872 <TABLE CELLPADDING=2 CELLSPACING=2>
873         <TR>
874                 <TD>
875                         <PRE># tar xzvf opengatexxxx.tar.gz</PRE>
876                 </TD>
877         </TR>
878 </TABLE>
879 <P>It contains the following directories:</P>
880 <TABLE CELLPADDING=2 CELLSPACING=2>
881         <TR>
882                 <TD>
883                         <PRE>doc: Documentation
884 conf: Configuration files and firewall control Perl script sample
885 javahtml: Client Java Programs and  HTML files
886 opengatesrv: Server CGI programs
887 tools: Some related tools
888 ezxml: XML parser (Copyright Aaron Voisine)</PRE>
889                 </TD>
890         </TR>
891 </TABLE>
892 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
893
894
895 <H4><!-- ************2************* -->
896 <A href="#opengate2" name=opengate2>F.2&nbsp;Installation</A></H4>
897 <P>Check the settings in "opengatesrv/Makefile" and modify
898 if needed:</P>
899 <TABLE CELLPADDING=2 CELLSPACING=2>
900         <TR>
901                 <TD>
902                         <PRE>HTMLTOP = /usr/local/www/apache22
903 DOCDIR = /data
904 CGIDIR = /cgi-bin
905 OPENGATEDIR = /opengate
906 CONFIGPATH = /etc/opengate</PRE>
907                 </TD>
908         </TR>
909 </TABLE>
910 <P>Compile and Install:</P>
911 <TABLE CELLPADDING=2 CELLSPACING=2>
912         <TR>
913                 <TD>
914                         <PRE># make clean
915 # make install</PRE>
916                 </TD>
917         </TR>
918 </TABLE>
919 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
920
921
922 <H4><!-- ************ 3 ************** -->
923 <A href="#opengate3" name=opengate3>F.3&nbsp;Setting up Config File</A></H4>
924
925 <P>Copy the sample configuration file
926 "/etc/opengate/opengatesrv.conf.sample" to
927 "/etc/opengate/opengatesrv.conf" and modify. <BR>The
928 following settings must be changed:</P>
929 <TABLE CELLPADDING=2 CELLSPACING=2>
930         <TR>
931                 <TD>
932                         <PRE>        &lt;OpengateServerName&gt;opengate.og.saga-u.ac.jp&lt;/OpengateServerName&gt;
933
934         &lt;AuthServer&gt;
935                 &lt;Protocol&gt;pop3s&lt;/Protocol&gt;
936                 &lt;Address&gt;192.168.0.2&lt;/Address&gt;
937         &lt;/AuthServer&gt;</PRE>
938                 </TD>
939         </TR>
940 </TABLE>
941 <P>In &lt;OpengateServerName&gt;, set the
942 HOSTNAME(FQDN) or IP address of the opengate gateway server. If you
943 want to use IPv6, you need to set the FQDN corresponding to both IPv4
944 and IPv6 addresses.</P>
945 <P>In &lt;AuthServer&gt;, set the
946 information for the authentication server. Opengate supports various
947 authentication protocols. See the config file for details. <BR>To
948 differentiate between erorrs caused by authentication server or those
949 caused by the opengate server, try the following setting first. This
950 means that any userid and password combination is accepted.</P>
951 <TABLE CELLPADDING=2 CELLSPACING=2>
952         <TR>
953                 <TD>
954                         <PRE> ****Do not use this setting in real service****
955         &lt;AuthServer&gt;
956                 &lt;Protocol&gt;accept&lt;/Protocol&gt; 
957         &lt;AuthServer&gt;</PRE>
958                 </TD>
959         </TR>
960 </TABLE>
961 <P>The config file is XML. "#" marks in
962 the file do not represent the start of a comment. <BR>Use
963 XML-formatted comments like &lt;!-- Comment String --&gt; to disable
964 a description.</P>
965 <P>Opengate can pass authentication settings
966 in the form of "userid@extid". <BR>See the config file for
967 more details. <BR>By using this function, you can use different
968 authentication servers for many sections or guests.</P>
969 <P>When the primary authentication server
970 does not reply, Opengate can resend the request to other
971 authentication servers. See the config file for more details.</P>
972 <P>Caution: Do not delete the IPv6 related
973 settings in the config file! <BR>          The IPv6 access is executed when
974 the FQDN for IPv6 is prepared.</P>
975
976 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
977
978
979 <H4><!-- ************ 4 ************** -->
980 <A href="#opengate4" name=opengate4>F.4&nbsp;Setting up IPFW</A></H4>
981 <P>Write IPFW rules for Opengate. 
982 </P>
983 <P>a. For FreeBSD6.0 or earlier</P>
984 <P>IPv4 and Ipv6 rules are controlled by IPFW and IP6FW respectively
985 .</P>
986 <P>  Sample rule sets for both firewall
987 types are prepared as "/etc/opengate/rc.firewall4.sample"
988 and "/etc/opengate/rc.firewall6.sample"</P>
989 <P>Copy these scripts and modify according to your needs.</P>
990 <TABLE CELLPADDING=2 CELLSPACING=2>
991         <TR>
992                 <TD>
993                         <PRE># cd /etc/opengate
994 # cp rc.firewall4.sample rc.firewall4
995 # cp rc.firewall6.sample rc.firewall6
996 # vi rc.firewall4
997 # vi rc.firewall6</PRE>
998                 </TD>
999         </TR>
1000 </TABLE>
1001 <P>Modify the firewall settings in /etc/rc.conf as follows: <BR>  Be
1002 careful not to lock yourself out of the system after reloading the
1003 firewall.</P>
1004 <TABLE CELLPADDING=2 CELLSPACING=2>
1005         <TR>
1006                 <TD>
1007                         <PRE>firewall_enable="YES"
1008 firewall_script="/etc/opengate/rc.firewall4"
1009
1010 ipv6_firewall_enable="YES"
1011 ipv6_firewall_script="/etc/opengate/rc.firewall6"</PRE>
1012                 </TD>
1013         </TR>
1014 </TABLE>
1015 <P>For Ipv6 support, change the path in "/etc/opengatesrv.conf"
1016 from &lt;Ip6fwPath&gt;/sbin/ipfw&lt;/Ip6fwPath&gt; to
1017 &lt;Ip6fwPath&gt;/sbin/ip6fw&lt;/Ip6fwPath&gt; 
1018 </P>
1019 <P>b. For FreeBSD6.1 or later</P>
1020 <P>Both IPv4 and IPv6 packets are controlled by IPFW.</P>
1021 <P>A sample rule set for IPFW can be found in
1022 "/etc/opengate/rc.firewall.sample"</P>
1023 <P>Copy the script and modify to fit your needs. <BR>   If you are
1024 not familiar with Ipv6, set IPv6 addresses as localhost (*net6="0",
1025 *ip6="::1").</P>
1026 <TABLE CELLPADDING=2 CELLSPACING=2>
1027         <TR>
1028                 <TD>
1029                         <PRE># cd /etc/opengate
1030 # cp rc.firewall.sample rc.firewall
1031 # vi rc.firewall</PRE>
1032                 </TD>
1033         </TR>
1034 </TABLE>
1035 <P>Modify the firewall settings in /etc/rc.conf as follows:<BR>  Be
1036 careful not to lock yourself out of the system after reloading the
1037 firewall.</P>
1038 <TABLE CELLPADDING=2 CELLSPACING=2>
1039         <TR>
1040                 <TD>
1041                         <PRE>firewall_enable="YES"
1042 firewall_script="/etc/opengate/rc.firewall"</PRE>
1043                 </TD>
1044         </TR>
1045 </TABLE>
1046 <P>Familiarise yourself with the "ipfw" command. <BR>  The
1047 Opengate software sends out ipfw add/delete commands.</P>
1048 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
1049
1050
1051 <H4><!-- ************ 5 ************** -->
1052 <A href="#opengate5" name=opengate5>F.5&nbsp;Setting
1053 up syslog</A></H4>
1054 <P>Edit /etc/syslog.conf to save log entries for Opengate.</P>
1055 <TABLE CELLPADDING=2 CELLSPACING=2>
1056         <TR>
1057                 <TD>
1058                         <PRE>         | Separated by TAB code
1059          V
1060 local1.*   /var/log/opengate.log</PRE>
1061                 </TD>
1062         </TR>
1063 </TABLE>
1064 <P>Make the log file as follows: <BR>  Consider using log rotation to
1065 control the size of this log file.</P>
1066 <TABLE CELLPADDING=2 CELLSPACING=2>
1067         <TR>
1068                 <TD>
1069                         <PRE># touch /var/log/opengate.log</PRE>
1070                 </TD>
1071         </TR>
1072 </TABLE>
1073 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
1074
1075
1076 <H4><!-- ************ 6 ************** -->
1077 <A href="#opengate6" name=opengate6>F.6&nbsp;Checking
1078 Behavior</A></H4>
1079 <P>Connect a PC to the lower-side network
1080 and try to access a site in the upper-side network. <BR>If it does
1081 not work properly, consult doc/progflow.html and doc/protocol.txt to
1082 better understand the procedure. Also check the log files for
1083 Opengate, httpd, system and others. To dump more information from
1084 Opengate, set the &lt;Debug&gt; switch to "2" in
1085 opengatesrv.conf.  Also check the functions of related software. The
1086 error checking document (errcheck.html) and Q&amp;A documents
1087 (qa.html, recentqa.html on the web) can be used for problem solving.</P>
1088 <P ALIGN=right><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
1089
1090
1091 <H4><!-- ************ 7 ************** -->
1092 <A href="#opengate7" name=opengate7>F.7&nbsp;Modifying
1093 Pages</A></H4>
1094 <P>If you want to modify the contents of the
1095 web pages, edit the html files in the Opengate directories. The
1096 relative path cannot be used in httpkeep.html. Use the full URL
1097 description. The descriptions such as %%XXX%% are variables replaced
1098 by their proper values during CGI runtime. 
1099 </P>
1100 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#opengate0">back</A>&nbsp;<A href="#top">top</A></P>
1101 <HR>
1102
1103
1104
1105 <HR>
1106 <H3><!-- Start:Install MRTG -->
1107 <A href="#mrtg0" name=mrtg0>G&nbsp;MRTG Installion (Optional)</A></H3>
1108 <UL>
1109         <LI><A href="#mrtg1">Ports Installation</A> </LI>
1110         <LI><A href="#mrtg2">Setting up MRTG</A> </LI>
1111         <LI><A href="#mrtg3">Confirming proper startup</A>  </LI>
1112         <LI><A href="#mrtg4">Setting up crontab</A> </LI>
1113 </UL>
1114
1115 <H4><!-- ************ 1 ************** -->
1116 <A href="#mrtg1" name=mrtg1>G.1&nbsp;Ports Installation</A></H4>
1117
1118 <P>This section is optional. <BR>   If you want to graphically
1119 monitor the state of Opengate, MRTG can be used but is not required.</P>
1120 <P><A HREF="http://people.ee.ethz.ch/%7Eoetiker/webtools/mrtg/" TARGET="_blank">MRTG<SPAN STYLE="TEXT-DECORATION: none">
1121 </SPAN></A>(Multi Router Traffic Grapher) is a system to monitor
1122 network traffic. MRTG produces graphic images and HTML files. 
1123 </P>
1124 <P>You can install MRTG on the gateway
1125 server or another server. If you need to monitor multiple Opengate
1126 systems, it is advised to install MRTG on a separate server.</P>
1127 <TABLE CELLPADDING=2 CELLSPACING=2>
1128         <TR>
1129                 <TD>
1130                         <PRE># cd /usr/ports/net-mgmt/mrtg/
1131 # make clean
1132 # make install clean ; rehash</PRE>
1133                 </TD>
1134         </TR>
1135 </TABLE>
1136 <P ALIGN=right><A href="#mrtg0">back</A>&nbsp;<A href="#top">top</A></P>
1137
1138
1139 <H4><!-- ************ 2 ************** -->
1140 <A href="#mrtg2" name=mrtg2>G.2&nbsp;Setting up MRTG</A></H4>
1141 <P>MRTG creates
1142 "/usr/local/etc/mrtg/mrtg.cfg.sample" as the sample
1143 configuration file during installation. Copy mrtg.cfg.sample to
1144 opengate.cfg and edit the file:</P>
1145 <TABLE CELLPADDING=2 CELLSPACING=2>
1146         <TR>
1147                 <TD>
1148                         <PRE>##################################################
1149 #  opengate user counter
1150
1151 WorkDir: /usr/home/user/public_html/mrtg/opengate/
1152
1153 ##### Options
1154 Options[^]: growright,gauge,nopercent,integer
1155
1156 Target[opengate]:`/usr/home/user/bin/input.sh`
1157 Title[opengate]: Opengate user counter
1158
1159 PageTop[opengate]: &lt;h1&gt;Opengate user counter&lt;/h1&gt;
1160  &lt;p&gt;Show the number of people using Opengate&lt;/p&gt;
1161
1162 # Max Number
1163 MaxBytes[opengate]: 200
1164
1165 # Title of Y axis
1166 YLegend[opengate]: Opengate User
1167 # unit
1168 ShortLegend[opengate]: s
1169 # Title of graph LegendI: first line LegendO: second line
1170 LegendI[opengate]: IPv6 Users
1171 LegendO[opengate]: Total Users</PRE>
1172                 </TD>
1173         </TR>
1174 </TABLE>
1175 <P>Be sure to actually create the directory
1176 which you appointed in "WorkDir". MRTG creates its graphic
1177 images and HTML files in "WorkDir"</P>
1178 <P>"Target[opengate]" contains the
1179 path to the program that hands its data to MRTG. <BR>(details
1180 explained below)</P>
1181
1182 <H5>G.2.1&nbsp;Scenario 1: Running MRTG on the gateway server</H5>
1183 <P>Create the shell script "/usr/home/user/bin/input.sh"
1184 with the following contents:</P>
1185 <TABLE CELLPADDING=2 CELLSPACING=2>
1186         <TR>
1187                 <TD>
1188                         <PRE>#!/bin/sh
1189
1190 #######################################
1191 ##
1192 ## show opengate status for MRTG
1193 ##
1194 ##   1 line : IPv6 Users
1195 ##   2 line : Total Users
1196 ##   3 line : uptime
1197 ##   4 line : comment for data
1198 ##
1199 #######################################
1200
1201 LANG=C
1202 COLUMNS=256
1203
1204 export LANG
1205 export COLUMNS
1206
1207 ### IPv6 prefix
1208 prefix="2001:2f8:22:801:"
1209 ###opengateprocessname
1210 process="opengatesrv.cgi" 
1211
1212 ###tmp file  name
1213 tmp_all="/tmp/og_count_all.tmp"
1214 tmp_6="/tmp/og_count_6.tmp"
1215
1216 ######################################################
1217 psax | grep $process &gt; $tmp_all
1218 COUNT = `wc-l $tmp_all | awk '{print $1}'` 
1219 grep $prefix $tmp_all &gt;  $tmp_6
1220 COUNT6=`wc -l $tmp_6 | awk '{print $1}'`
1221 UPTIME=`uptime | awk '{print $3$4}' | sed -e "s/,//g"`
1222
1223 rm $tmp_all
1224 rm $tmp_6
1225
1226 echo "$COUNT6"
1227 echo "$COUNT"
1228 echo "$UPTIME"
1229 echo "Opengate User Counter"</PRE>
1230                 </TD>
1231         </TR>
1232 </TABLE>
1233 <P>Run this shell script as standalone and confirm that you can
1234 acquire the following data:</P>
1235 <TABLE CELLPADDING=2 CELLSPACING=2>
1236         <TR>
1237                 <TD>
1238                         <PRE>5
1239 48
1240 10days
1241 Opengate User Counter</PRE>
1242                 </TD>
1243         </TR>
1244 </TABLE>
1245 <H5>G.2.2&nbsp;Scenario 2: Running MRTG on a separate server</H5>
1246 <P>Create the shell script "/usr/home/user/bin/input.sh" on
1247 a separate server.</P>
1248 <TABLE CELLPADDING=2 CELLSPACING=2>
1249         <TR>
1250                 <TD>
1251                         <PRE>#!/bin/sh
1252
1253 #######################################
1254 ##
1255 ## input data for MRTG
1256 ##
1257 ##   1 line : IPv6 Users
1258 ##   2 line : Total Users
1259 ##   3 line : uptime
1260 ##   4 line : comment for data
1261 ##
1262 #######################################
1263
1264 # tmp file name
1265 file="/tmp/opengate.tmp"
1266
1267 # URL of output.sh at opengate
1268 url="http://opengate.saga-u.ac.jp/cgi-bin/output.sh"
1269
1270 fetch -o $file $url &amp;&gt; /dev/null
1271
1272 more $file</PRE>
1273                 </TD>
1274         </TR>
1275 </TABLE>
1276 <P STYLE="TEXT-INDENT: 0in">Create the shell script
1277 "/usr/local/apache2/cgi-bin/output.sh" on the Opengate
1278 (gateway) server, and set the URL to $url, as explained above.</P>
1279 <TABLE CELLPADDING=2 CELLSPACING=2>
1280         <TR>
1281                 <TD>
1282                         <PRE>#!/bin/sh
1283
1284 #######################################
1285 ##
1286 ## show opengate status for MRTG
1287 ##
1288 ##   1 line : IPv6 Users
1289 ##   2 line : Total Users
1290 ##   3 line : uptime
1291 ##   4 line : comment for data
1292 ##
1293 #######################################
1294
1295 LANG=C
1296 COLUMNS=256
1297
1298 export LANG
1299 export COLUMNS
1300
1301 ### IPv6 prefix
1302 prefix="2001:2f8:22:801:"
1303 ###opengateprocessname
1304 process="opengatesrv.cgi" 
1305
1306 ###tmp file name
1307 tmp_all="/tmp/og_count_all.tmp"
1308 tmp_6="/tmp/og_count_6.tmp"
1309
1310 ######################################################
1311 psax | grep $process &gt; $tmp_all 
1312 COUNT = `wc-l $tmp_all | awk '{print $1}'` 
1313 grep $prefix $tmp_all &gt;  $tmp_6
1314 COUNT6=`wc -l $tmp_6 | awk '{print $1}'`
1315 UPTIME=`uptime | awk '{print $3$4}' | sed -e "s/,//g"`
1316 rm $tmp_all
1317 rm $tmp_6
1318
1319 echo "Content-type: text/plain; charset=iso-8859-1"
1320 echo
1321
1322 echo "$COUNT6"
1323 echo "$COUNT"
1324 echo "$UPTIME"
1325 echo "Opengate User Counter"</PRE>
1326                 </TD>
1327         </TR>
1328 </TABLE>
1329 <P>Run "input.sh" on another server and confirm that you
1330 can acquire the following data:</P>
1331 <TABLE CELLPADDING=2 CELLSPACING=2>
1332         <TR>
1333                 <TD>
1334                         <PRE>5
1335 48
1336 10days
1337 Opengate User Counter</PRE>
1338                 </TD>
1339         </TR>
1340 </TABLE>
1341 <P ALIGN=right><A href="#mrtg0">back</A>&nbsp;<A href="#top">top</A></P>
1342
1343 <H4><!-- ************ 3 ************** -->
1344 <A href="#mrtg3" name=mrtg3>G.3&nbsp;Confirming MRTG Startup Operation:</A></H4>
1345
1346 <P>Use the following command to confirm MRTG is working with your
1347 config:</P>
1348 <TABLE CELLPADDING=2 CELLSPACING=2>
1349         <TR>
1350                 <TD>
1351                         <PRE># /usr/local/bin/mrtg /usr/local/etc/mrtg/opengate.cfg</PRE>
1352                 </TD>
1353         </TR>
1354 </TABLE>
1355 <P STYLE="TEXT-INDENT: 0in">Various WARNING messages are output the
1356 first and second time, this is normal behavior <BR>(as explained in
1357 the MRTG documentation)!<BR>Some files are created in "WorkDir".</P>
1358 <TABLE CELLPADDING=2 CELLSPACING=2>
1359         <TR>
1360                 <TD>
1361                         <PRE>&gt; ls -l
1362 -rw-r--r--  1 root  wheel    538 12 14 04:40 mrtg-l.png
1363 -rw-r--r--  1 root  wheel    414 12 14 04:40 mrtg-m.png
1364 -rw-r--r--  1 root  wheel   1759 12 14 04:40 mrtg-r.png
1365 -rw-r--r--  1 root  wheel   2941 12 20 15:15 opengate-day.png
1366 -rw-r--r--  1 root  wheel   2146 12 20 14:35 opengate-month.png
1367 -rw-r--r--  1 root  wheel   2867 12 20 14:55 opengate-week.png
1368 -rw-r--r--  1 root  wheel   1897 12 20 05:00 opengate-year.png
1369 -rw-r--r--  1 root  wheel   5961 12 20 15:15 opengate.html
1370 -rw-r--r--  1 root  wheel  48786 12 20 15:15 opengate.log
1371 -rw-r--r--  1 root  wheel  48784 12 20 15:10 opengate.old</PRE>
1372                 </TD>
1373         </TR>
1374 </TABLE>
1375 <P ALIGN=right><A href="#mrtg0">back</A>&nbsp;<A href="#top">top</A></P>
1376
1377 <H4><!-- ************ 4 ************** -->
1378 <A href="#mrtg4" name=mrtg4>G.4&nbsp;Registering to Crontab</A></H4>
1379
1380 <P>Add the following line to "/etc/crontab":</P>
1381 <TABLE CELLPADDING=2 CELLSPACING=2>
1382         <TR>
1383                 <TD>
1384                         <PRE>*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/opengate.cfg</PRE>
1385                 </TD>
1386         </TR>
1387 </TABLE>
1388 <P ALIGN=right><A href="#mrtg0">back</A>&nbsp;<A href="#top">top</A></P>
1389
1390
1391 <H3><!-- Start:Install rulechk -->
1392 <A href="#rulechk" name=rulechk>H&nbsp;rulechk Installation (Optional)</A></H3>
1393
1394 <P>This section is optional. <BR>When the
1395 Opengate process is not exited normally, superfluous rules might be
1396 left behind. <BR>Though it is 
1397 very rare, the tools/rulechk script is made to handle such situations. This 
1398 script compares the Opengate process list and the firewall rule list, and 
1399 deletes the obsolete rules.<BR>This script is compatible with Opengate Ver1.3.1 or above. 
1400 </P>
1401 <P ALIGN=right STYLE="MARGIN-BOTTOM: 0in"><A href="#rulechk">back</A>&nbsp;<A href="#top">top</A></P>
1402 </BODY>
1403 </HTML>