<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>温室小花.技术.博客 --纯粹的unix技术博客 &#187; samba</title>
	<atom:link href="http://www.evanjiang.net.cn/archives/category/apps/samba/feed" rel="self" type="application/rss+xml" />
	<link>http://www.evanjiang.net.cn</link>
	<description>红颜弹指老，刹那芳华，与其天涯思君，恋恋不舍，莫若相忘于江湖！</description>
	<lastBuildDate>Sun, 05 Sep 2010 14:51:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>File/pdc/samba文件打印共享服务器建设方案.</title>
		<link>http://www.evanjiang.net.cn/archives/1216.html</link>
		<comments>http://www.evanjiang.net.cn/archives/1216.html#comments</comments>
		<pubDate>Mon, 06 Jul 2009 14:43:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://www.evanjiang.net.cn/archives/1216.html</guid>
		<description><![CDATA[<p>


 <p>建立文件共享 / 打印系统：不得不重视的简单</p>
<p>    说起建立一个文件共享 / 打印系统，很多企业反应的是简单，但对于一个企业来说，无论大小与难易，都是不容忽视的。还是先来看看打印的应用吧，在公司内部，无论是销售人员的产品销售配置清单，或者技术人员的设计样图等资料都需要经常的通过打印机打印出来并存档备查，并且当前的商务往来信函也全部采用打印体以避免误会的产生。但是每个员工配备一个打印机显然是不可能的，那么唯一的解决方法就是配置一台共享的打印机供员工们在需要的时候方便的通过网络使用。</p>
<p>    在当前瞬息万变的商业环境中，信息的共享是提高员工工作效率，增加决策准确度和通过协作完成复杂工作的不二法门。有个承接国外客户广告设计的企业在使用了这种文件共享服务器后，工作效率得到了极大的提升。以前国外客户需要提供产品设计图给该公司时，常会遇到这样的状况：当档案太大无法用 email 寄送，选择使用快递通常还是得花上 3 天以上才够！公司收到后又需要 2 天以上的时间修改与确认，再额外地使用 2 天将定案的设计图快递给下游工厂生产，前前后后最快也要花上 8 天的时间！要是哪个环节不顺利可能还要更久。</p>
<p>    所谓时间就是金钱，究竟要怎么样改善呢 ? 采用远程文件共享服务器之后，国外客户将生产设计图 (500MB) 上传至文件共享服务器（节省 3 天的快递时间）；员工直接在文件共享服务器上修改并与客户确认设计图，并将最后版本的设计图放在文件共享服务器上让合作的工厂直接下载（ 2 天的作业时间）；大陆的工厂直接从文件共享服务器下载设计图进行生产（节省 3 天的快递时间）。从这个案例，我们就能发现使用文件共享服务器可以为公司节省 6 天的时间，以及快递费用，变相的创造了大量的经济效益。当然了，文件共享服务还有许多其他重要的应用，比如，要求所有员工需要定时将自己的工作文档备份到文件服务器上，这样就避免了员工电脑崩溃所带来的数据损失，以及克服了员工离职时所带来的交接困难。

    如果单独为打印设置一台共享服务器显得过于浪费，因此可以将打印与文件共享结合在一台服务器上提供服务。</p>
<p>选择真正的服务器只需一个理由：满足你的需求</p>
<p>    现在有很多的中小企业都使用高端 PC 机来作为打印共享使用，虽然 PC 机能够满足打印共享对于性能的要求，但是像打印共享这类简单的应用完全可以与远程文件共享一类的应用同时利用一台专用服务器提供服务，也就是合并应用，提高机器利用率。但是这样一来，普通 PC 就无法满足应用要求。</p>
<p>  [...]]]></description>
			<content:encoded><![CDATA[<p style="float: left;margin: 4px;"><script type="text/javascript"><!--
google_ad_client = "pub-8438729971248494";
/* 160x600, 创建于 10-2-7 */
google_ad_slot = "8970910006";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p> <p>建立文件共享 / 打印系统：不得不重视的简单</p>
<p>    说起建立一个文件共享 / 打印系统，很多企业反应的是简单，但对于一个企业来说，无论大小与难易，都是不容忽视的。还是先来看看打印的应用吧，在公司内部，无论是销售人员的产品销售配置清单，或者技术人员的设计样图等资料都需要经常的通过打印机打印出来并存档备查，并且当前的商务往来信函也全部采用打印体以避免误会的产生。但是每个员工配备一个打印机显然是不可能的，那么唯一的解决方法就是配置一台共享的打印机供员工们在需要的时候方便的通过网络使用。</p>
<p>    在当前瞬息万变的商业环境中，信息的共享是提高员工工作效率，增加决策准确度和通过协作完成复杂工作的不二法门。有个承接国外客户广告设计的企业在使用了这种文件共享服务器后，工作效率得到了极大的提升。以前国外客户需要提供产品设计图给该公司时，常会遇到这样的状况：当档案太大无法用 email 寄送，选择使用快递通常还是得花上 3 天以上才够！公司收到后又需要 2 天以上的时间修改与确认，再额外地使用 2 天将定案的设计图快递给下游工厂生产，前前后后最快也要花上 8 天的时间！要是哪个环节不顺利可能还要更久。</p>
<p>    所谓时间就是金钱，究竟要怎么样改善呢 ? 采用远程文件共享服务器之后，国外客户将生产设计图 (500MB) 上传至文件共享服务器（节省 3 天的快递时间）；员工直接在文件共享服务器上修改并与客户确认设计图，并将最后版本的设计图放在文件共享服务器上让合作的工厂直接下载（ 2 天的作业时间）；大陆的工厂直接从文件共享服务器下载设计图进行生产（节省 3 天的快递时间）。从这个案例，我们就能发现使用文件共享服务器可以为公司节省 6 天的时间，以及快递费用，变相的创造了大量的经济效益。当然了，文件共享服务还有许多其他重要的应用，比如，要求所有员工需要定时将自己的工作文档备份到文件服务器上，这样就避免了员工电脑崩溃所带来的数据损失，以及克服了员工离职时所带来的交接困难。<br />
<span id="more-1216"></span><br />
    如果单独为打印设置一台共享服务器显得过于浪费，因此可以将打印与文件共享结合在一台服务器上提供服务。</p>
<p>选择真正的服务器只需一个理由：满足你的需求</p>
<p>    现在有很多的中小企业都使用高端 PC 机来作为打印共享使用，虽然 PC 机能够满足打印共享对于性能的要求，但是像打印共享这类简单的应用完全可以与远程文件共享一类的应用同时利用一台专用服务器提供服务，也就是合并应用，提高机器利用率。但是这样一来，普通 PC 就无法满足应用要求。</p>
<p>    首先，我们的远程文件共享系统需要 24 小时提供服务，因为出差在外的员工可能随时随地的需要文件服务器上的数据来开展工作，还有远在海外的供货商也需要这个系统来共享一些大文件数据；而 PC 并不是按照 24 小时工作设计的，如果强行让其 24 小时工作，这台 PC 就可能因为常时间的不间断使用而发生故障，从而造成工作的延误，甚至出现硬盘故障导致数据损失，就更加无法估量这个损失了。而服务器所专用的 24 小时工作设计，冗余部件等等技术都保证了服务器能够不停息的工作。</p>
<p>    另外 PC 在磁盘的扩展性以及数据传输的可靠性方面都不如真正的服务器，所以在涉及这些关键数据的应用领域还是选择服务器为妙。</p>
<p>接下来要做的，只需选择</p>
<p>    其实选择的方式有很多，可以根据预算的多少来进行选择，也可以根据应用环境的复杂程度来选择，还可以根据你想拥有的某些特殊功能来进行选择。</p>
<p>    如果您的公司或者部门拥有的 PC 数量在 100 台以下；那么在文件共享服务器上的并发量一般不会超过 10 ，使用一台带 Linux/Unix 操作系统的服务器即可满足要求。配置一颗支持扩展 64 位内存寻址技术的 Pentium4 处理器或者 Xeon 处理器，另外 OS 一般会消耗掉 256MB 以上内存，所以最低要求配到 512MB ECC DDRII 双路交叉存取内存。而磁盘方面对于高速存取没有什么特别的要求，主要从经济角度考虑，可以使用 SATA 硬盘，在预算充足的情况下考虑使用 SCSI 硬盘，容量方面一般保证 200 个 GB 即够用了，如果考虑到数据的安全保护方面，还需要考虑使用 RAID 卡或者集成 RAID 进行数据保护。</p>
<p>    P4 3.0GHz( 或者 Xeon 2.8GHz EM64T) /512MB ECC DDRII SDRAM /2×120GB SATA( 或者热插拔 SCSI 硬盘 ) / 集成 SATA RAID / 1000M 服务器专用网卡 / 单电源<br />
    如果您的预算在 1 万以下；那么简单的配置就可以是：<br />
    P4 3.0GHz /512MB ECC DDRII SDRAM /2×80GB SATA 硬盘 / 集成 SATA RAID1 / 1000M + 100M 服务器专用网卡 / 单电源<br />
    如果您的预算在 1 万～ 2 万之间；可以配置 Xeon 处理器和 SCSI 磁盘的服务器：<br />
    Xeon 2.8GHz EM64T /512MB( 或者 1GB) ECC DDRII SDRAM /2×73GB 热插拔 SCSI 硬盘 /SCSI  RAID1 / 1000M 服务器专用网卡 / 单电源</p>
<p>怎么做，你决定<br />
从以上简单的分析不难看出，打印 / 文件共享系统虽然简单，但却是每一个企业正常运营的基础，而使用真正的服务器是进行文件 / 打印应用的坚实保障。它提供给我们的稳定和安全无疑让每一个心怀大志的企业领导者从无限琐碎且不必要的烦恼摆脱出来，以更充沛的精力去为企业发展开拓新的道路。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evanjiang.net.cn/archives/1216.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freebsd 安装带杀毒功能的samba文件服务器</title>
		<link>http://www.evanjiang.net.cn/archives/942.html</link>
		<comments>http://www.evanjiang.net.cn/archives/942.html#comments</comments>
		<pubDate>Tue, 21 Apr 2009 04:56:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[freebsd unix]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[Freebsd Samba]]></category>

		<guid isPermaLink="false">http://www.evanjiang.net.cn/?p=942</guid>
		<description><![CDATA[<p style="float: right;margin: 4px;">


</p> <p>安装Freebsd过程略</p>
<p>1.安装Samba 3</p>
<p># cd /usr/ports/net/samba3
# make install clean
安装完samba,请设置/usr/local/etc/smb.conf.并在/etc/rc.conf加入一句使Samba随系统一起启动.</p>
<p>samba_enable=&#8221;YES&#8221;
2.安装clamav</p>
<p># cd /usr/ports/security/clamav
# make install clean
手动更新病毒库到默认路径</p>
<p># freshclam
在/etc/rc.conf加一句让Clamav随系统一起启动.</p>
<p>clamav_clamd_enable=&#8221;YES&#8221;
clamav_freshclam_enable=&#8221;YES&#8221;        # 定时更新病毒库
3.安装samba-vscan</p>
<p># cd /usr/ports/security/samba-vscan
# make install clean
在/usr/local/etc/smb.conf的[global]加入</p>
<p>vfs object = vscan-clamav
vscan-clamav: config-file = /usr/local/etc/samba-vscan/vscan-clamav.conf
附简单的smb.conf
 </p>
<p># Samba config file created using SWAT
# from 127.0.0.1 (127.0.0.1)
# Date: 2005/08/06 10:55:55</p>
<p># Global parameters
[global]
    [...]]]></description>
			<content:encoded><![CDATA[<p>安装Freebsd过程略</p>
<p>1.安装Samba 3</p>
<p># cd /usr/ports/net/samba3<br />
# make install clean<br />
安装完samba,请设置/usr/local/etc/smb.conf.并在/etc/rc.conf加入一句使Samba随系统一起启动.</p>
<p>samba_enable=&#8221;YES&#8221;<br />
2.安装clamav</p>
<p># cd /usr/ports/security/clamav<br />
# make install clean<br />
手动更新病毒库到默认路径</p>
<p># freshclam<br />
在/etc/rc.conf加一句让Clamav随系统一起启动.</p>
<p>clamav_clamd_enable=&#8221;YES&#8221;<br />
clamav_freshclam_enable=&#8221;YES&#8221;        # 定时更新病毒库<br />
3.安装samba-vscan</p>
<p># cd /usr/ports/security/samba-vscan<br />
# make install clean<br />
在/usr/local/etc/smb.conf的[global]加入</p>
<p>vfs object = vscan-clamav<br />
vscan-clamav: config-file = /usr/local/etc/samba-vscan/vscan-clamav.conf<br />
附简单的smb.conf<br />
 <span id="more-942"></span></p>
<p># Samba config file created using SWAT<br />
# from 127.0.0.1 (127.0.0.1)<br />
# Date: 2005/08/06 10:55:55</p>
<p># Global parameters<br />
[global]<br />
        dos charset = GB2312<br />
        unix charset = GB2312<br />
        display charset = GB2312<br />
        workgroup = SAMBA<br />
        server string = Samba PDC running %v<br />
        log level = 2<br />
        log file = /var/log/samba/log.%m<br />
        max log size = 50<br />
        socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192<br />
        local master = No<br />
        dns proxy = No<br />
        ldap ssl = no<br />
        #hosts allow = 10.0., 127.<br />
        vfs object = vscan-clamav<br />
        vscan-clamav: config-file = /usr/local/etc/samba-vscan/vscan-clamav.conf<br />

<!-- Begin alimama Adserver code -->
<script type="text/javascript"><!--
google_ad_client = "pub-8438729971248494";
/* 728x90, ������ 10-2-7 */
google_ad_slot = "4752526529";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Alimama Adserver code -->
<br />
[homes]<br />
        comment = Home Directories<br />
        valid users = %S<br />
        write list = %S<br />
        read only = No<br />
        create mask = 0666<br />
        directory mask = 0777<br />
        browseable = No</p>
<p>[profiles]<br />
        path = /home/samba/profiles<br />
        read only = No<br />
        create mask = 0600<br />
        directory mask = 0700<br />
        browseable = No<br />
 
<!-- Begin alimama Adserver code -->
<script type="text/javascript"><!--
google_ad_client = "pub-8438729971248494";
/* 728x90, ������ 10-2-7 */
google_ad_slot = "4752526529";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End Alimama Adserver code -->
<br />
[netlogon]<br />
        comment = Network Logon Service<br />
        path = /home/netlogon<br />
        write list =<br />
        browseable = No</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evanjiang.net.cn/archives/942.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to OpenBSD  Firewall/Gateway  Unix Workstation</title>
		<link>http://www.evanjiang.net.cn/archives/849.html</link>
		<comments>http://www.evanjiang.net.cn/archives/849.html#comments</comments>
		<pubDate>Mon, 23 Mar 2009 14:34:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[It Tips]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[openbsd unix]]></category>
		<category><![CDATA[pf]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[Introduction to OpenBSD  Firewall/Gateway  Unix Workstation]]></category>

		<guid isPermaLink="false">http://www.evanjiang.net.cn/?p=849</guid>
		<description><![CDATA[<p>Abstract
This is a quick tutorial on how to set up an OpenBSD 3.1 system. The first part covers setting up a firewall, NAT proxy, time and DHCP server on a system connected to the Internet via broadband like DSL or cable. The second part covers things that would be installed on a desktop machine: graphical [...]]]></description>
			<content:encoded><![CDATA[<p>Abstract<br />
This is a quick tutorial on how to set up an OpenBSD 3.1 system. The first part covers setting up a firewall, NAT proxy, time and DHCP server on a system connected to the Internet via broadband like DSL or cable. The second part covers things that would be installed on a desktop machine: graphical window managers etc. </p>
<p>The reader is not expected to be a Unix expert (why would a Unix expert need this how-to?) &#8212; if you don&#8217;t understand something, or something looks intimidating, read on and come back to it. If something still doesn&#8217;t make sense, let me know. </p>
<p>I don&#8217;t cover what I consider &#8220;advanced&#8221; usage such as tracking -CURRENT or CVS snapshots. If you want to do that, I assume you know which FAQs to read! </p>
<p>This document may be freely reproduced and redistributed under the terms of the GNU Free Documentation License Version 1.1; with the invariant section being this entire document, with no Front-Cover Texts and no Back-Cover Texts. </p>
<p>In other words, if you want to copy this document in its entirety, feel free to do so; if you wish to modify it (as in providing a translation, or taking sections to include in other documents) please send me email. Needless to say, documents that this document links to will have their own copyrights. </p>
<p>New!<br />
I have a shell script that sets up everything mentioned here. This is still experimental but if you try it, please let me know how it goes. Save this file to disk and run it by typing &#8220;sh config31-fw.sh&#8221;. (Doesn&#8217;t handle PPPoE [the beast].) </p>
<p>There is a new section called Tips and Stuff where I put things I&#8217;ve found or written that are useful sysadmin tools. </p>
<p>Introduction<br />
Why OpenBSD? It&#8217;s simple and secure. Your firewall machine should not have lots of things installed on it; therefore no exotic hardware, graphical desktops, X11 servers etc. &#8212; put those on your desktop machine. A simpler system is more robust and more secure; this machine only offers SMTP (email), ssh, ping/traceroute and optionally HTTP (web) to the outside world. And since it&#8217;s running Unix, you can log in to it &#8212; securely &#8212; using ssh from anywhere on the Internet and make any changes you need to. (N.B.: never use telnet to connect to a machine over the Internet! Anyone can eavesdrop and grab important information like passwords. Only use ssh, which encrypts all communication so that eavesdroppers don&#8217;t get any information. And verify those key fingerprints or you leave yourself open to a man-in-the-middle attack. For information do a web search for public key cryptosystems; a good place to start is OpenSSH.) </p>
<p>The utility and security of having this kind of machine: a firewall protects your data and systems from the Big, Bad Internet. When the bad guys are out to vandalise machines on the Internet, MS-Windows machines of various kinds are prime targets because they suck. Er, I mean, Windows is really hard to secure. (Not that an incompetently run Unix machine is any better, of course.) When you dialled in on the phone, your machine was on the &#8216;net for brief periods; with DSL or cable it&#8217;s vulnerable all the time. </p>
<p>This document also describes how to set up an OpenBSD system as a Unix workstation. We will go over setting up X11 (the window system) etc. I assume that you will be using a different machine as your workstation. Important: Unix systems can be set up in various ways; I do things a certain way and that&#8217;s what this document will cover. Other people (wizards and newbies alike) may do things differently. In case it matters, I&#8217;ve been using Unix since 1982, have been a sysadmin on-and-off since 1986 (VAX/BSD, SunOS 4.x, Solaris 2.x, HP/UX, AT&#038;T 3B5 SVR6 etc.) I&#8217;ve been a C programmer since the early 80s. Today I design and implement back-end network servers on Solaris. </p>
<p>This tutorial assumes that you have some familiarity with using Unix: what filenames look like, how to copy and edit files etc. There&#8217;s a decent Unix tutorial on the web. The most important command to remember is man (short for &#8220;manual&#8221;) &#8212; if I say something like &#8220;read the documentation for foobar it means you should type man foobar. One other piece of Unix argot: if you hear someone write select(2) it indicates that the manual for select is in section 2, i.e. you would read the manpage by typing man 2 select. You should also read the OpenBSD documentation: particularly the OpenBSD FAQ. Bookmark that link right now.<br />
<span id="more-849"></span><br />
NAT (Network Address Translation) allows you to connect lots of PCs up to one network connection. When any of the machines inside the firewall wants to make a connection to some server out there on the internet, the firewall/NAT box intercepts that request, and sends the request off as though it came from the firewall/NAT machine. When the reply arrives, it is sent off to the machine that made the connection. Neither the server nor the machines on the inside know that all this is going on. </p>
<p>Aside: NAT is also called PAT, for &#8220;Port Address Translation.&#8221; Also, read this interesting article by HRH Prince Philip, Duke of Edinburgh, on setting up PAT and DHCP on Cisco routers. The whole routergod.com site features many celebrities offering helpful tips on various network issues. </p>
<p>Even if you don&#8217;t want plan on having more than one PC at home, NAT is useful, because it allows the machine running your firewall to be different from your main workstation. You probably want to install fancy hardware and software on your machine; but every additional package installed on a firewall makes it more vulnerable. </p>
<p>Network Address Translation (NAT)</p>
<p>Note: if you only have one machine on the &#8220;inside&#8221;, you don&#8217;t need an ethernet hub; use a crossover cable to connect the two machines directly. This also has the advantage that you can get a full-duplex connection between the machines (a hub only allows a half-duplex connection). </p>
<p>Note: you can buy little NAT/DHCP boxes from various manufacturers for about $150, but where&#8217;s the fun in that? Besides, who knows how strong the security is on those things. With OpenBSD you know you&#8217;re getting the best. </p>
<p>Building the machine<br />
The machine itself: I prefer to build these machines up from individual components rather than buying a pre-made box. That way I can get name-brand supported components, and it works out slightly cheaper since I don&#8217;t have to get exotic video cards, sound cards, CD-ROM drives etc. (Not to mention a Fisher-Price operating system that you will be required to pay for.) </p>
<p>Can you build a PC? Well, no one showed me how, but I&#8217;ve managed to put together about 10 or so systems, so it can&#8217;t be that hard. If you&#8217;ve assembed anything with screwdrivers etc. you&#8217;ll be fine. There are numerous sites on the web that walk you through building a PC. Go do a Google search and read those. I especially like the one at Acme Labs by Jef Poskanzer. There&#8217;s also an excellent motherboard finder at Acme. </p>
<p>Caveat: specific recommendations will be outdated as soon as I write them! I like to use AMD CPUs because I believe Intel is evil and as far as possible I&#8217;d like to not buy their products. I&#8217;d get the current not-top-of-the-line CPU i.e. the one that costs about $50 and a compatible motherboard that costs in the range of $70. I stay away from integrated components because they&#8217;re usually garbage. (For a server that I don&#8217;t use directly I might get integrated video.) Spend about $30-50 on RAM, $30 on ethernet, $60 on an IDE disk, $30 for a case (with power supply). I usually find the best prices on components at Directron and CompuVest (warning: uses Java). These have both been non-sleazy (everything was as described in their catalog and shipping was prompt) in all my dealings with them &#8212; but let me know if you find any evidence of sleaziness. </p>
<p>All these components add up to around $300 &#8212; and that&#8217;s brand-new stuff. If you have any old components lying around, they will be fine. You don&#8217;t need a keyboard, mouse or monitor when the system is up and running &#8212; all maintenance on it can be done over the network. (While you&#8217;re installing the OS on the machine you will need to hook up a keyboard, monitor and CD-ROM drive to it, of course.) </p>
<p>While installing the system, I plug in a spare CD-ROM drive, keyboard and monitor. Change the BIOS settings so that the machine will boot without a keyboard etc. Boot off the OpenBSD 3.1 CD and install the system. All the hardware should be recognised without any problems. (The installation guide booklet that comes with the CDs is excellent.) </p>
<p>The easiest way to install OpenBSD is to buy the distribution on CDs. Although you can install it via the network, buying the CD will help make sure that the OpenBSD project will continue to improve and better the system. If you can afford an outlay of US$40, please buy the CDs from the OpenBSD ordering site. </p>
<p>When you&#8217;re installing OpenBSD, the installer program will ask you for disklabel information (partitions). On a Unix system, a group of files organised together is called a filesystem. The disk is partitioned into various pieces each of which will hold one filesystem. This is the filesystem breakup and partition sizes I&#8217;d use for a 12GB disk (if your disk is bigger, you can just increase the size of /var (for web files) or /home (for your personal files) &#8212; the system will be more than happy with these sizes for /, /tmp and /usr):</p>
<p>/dev/wd0a      100M     /<br />
/dev/wd0d      400M     /tmp<br />
/dev/wd0e      4GB      /var<br />
/dev/wd0g      2GB      /usr<br />
/dev/wd0h      5GB      /home<br />
(The convention is that a is always /, b is swap and c is the whole disk.) Your web files will live in /var, and your other files in /home. </p>
<p>This is all overkill; /usr only needs about 600M or so. Say pad it to 1GB. A 2GB disk would be plenty for the system, but if the cheapest disk you can get is 13GB&#8230;. </p>
<p>Note for Unix newcomers: the disk is named /dev/wd0, and in this case it has 5 partitions with names /dev/wd0a, /dev/wd0d, /dev/wd0e, /dev/wd0g and /dev/wd0h. And the different partitions don&#8217;t get different &#8220;drive letters&#8221; as in some primitive operating systems; once the system is installed, it looks to the user that there is just one bunch of files; Unix will figure out the right thing to do. After the system has been installed and you&#8217;ve booted off the hard disk, log in and (this is important!) type man afterboot; it will remind of some things that you need to do to complete the installation &#8212; pick passwords, create user accounts, check network settings etc. Also, man hier will introduce you to the way the system is organised &#8212; which files live where. In fact, let me say that again: </p>
<p>After the first normal boot of the system, be sure to read these manpages:<br />
$  man afterboot<br />
$  man hier<br />
Also run dmesg(8) to learn more about your hardware and the driver names that OpenBSD uses for them. </p>
<p>Which packages to install? A good starting point would be to accept the defaults. For a desktop system (workstation), you will want all the X11 packages also. I install everything. </p>
<p>There! And make sure you keep reading the manpages &#8212; OpenBSD manpages are a thing of beauty, complete, up-to-date and informative. And also read the OpenBSD FAQ on the web &#8212; much of this information is also found there. </p>
<p>Configuring the network<br />
For my outside connection I have DSL and a static IP number (from Speakeasy &#8212; I recommend them over PacBell etc. &#8212; I&#8217;m so happy I switched). Other DSL options are PPPoE that PacBell likes to set people up with, or DHCP which is what you usually get over cable. A completely bogus DSL installation is the USB device they try to foist on customers with Windows. Danger, Will Robinson! They stink; they&#8217;re unsupported on any free O/S, and even on Windows they work about half the time. </p>
<p>In *BSD the network cards are named according to the driver used. For the Lite-On (DEC Tulip) cards, the driver is called dc, and the Intel EtherExpress Pro is fxp; so my two ethernet cards are dc0 and fxp0. (If you had two cards that both used the dc driver, they would be dc0 and dc1.) For the inside network I use the &#8220;private&#8221; (non-routable) IP numbers 192.168.1.* which will make the inward-facing network card 192.168.1.1. The OpenBSD initialization asks you for IP numbers for the two cards. Enter the appropriate ones &#8211; the IP number your ISP gave you for dc0, and 192.168.1.1 for fxp0. For PPPoE, the outside interface is tun0 and it will figure out its own IP address. If you&#8217;re supposed use DHCP on your DSL or cable connection, type in dhcp. </p>
<p>It is important to remember which network will be the outside and which the inside. If the two cards are identical, the easiest way is to look at the MAC number. Every ethernet card ever made has a unique ID called its MAC number. This will be printed on the card, usually as a sticker. When the kernel boots up, it will print the MAC numbers of each card it finds:</p>
<p>fxp0 at pci0 dev 9 function 0 &#8220;Intel 82557&#8243; rev 0x0c: irq 11, address 00:02:b3:a0:3a:50<br />
dc0 at pci0 dev 10 function 0 &#8220;Lite-On PNIC&#8221; rev 0&#215;20: irq 10 address 00:a0:cc:55:ab:1c<br />
So the card that has a MAC number ending ab1c is dc0; the other is fxp0. (If the two network cards you have are different types, as in this case, there&#8217;s no problem, of course. The kernel bootup messages is still be useful to tell you what names the system is using for them.) </p>
<p>(There&#8217;s some rule about where the cards are plugged in so which one gets number 0 and which no. 1, but I can never remember that.) </p>
<p>PPPoE<br />
The beast! PPPoE is a pain in the ass but ISPs like it because it makes things simpler for them &#8212; they don&#8217;t have to maintain lists of IP numbers. Also, they can run a crappy service and keep dropping the connection and that&#8217;s ok, you&#8217;re expected to reconnect. It&#8217;s the Micros**t philosophy of &#8220;make something really crappy and expect people to just re-start the whole system a couple of times a day.&#8221; It&#8217;s a pain in the ass for us because its MTU is 1492 instead of 1500 which used to require changes on every machine inside the network &#8212; but now thanks to the &#8220;mssfixup&#8221; flag we don&#8217;t have to any more. </p>
<p>The files you will need to change for PPPoE all live in /etc/ppp/. </p>
<p>Configure system files<br />
To set up the system, the files you will be editing are:/etc/rc.conf, /etc/myname, /etc/mygate, /etc/pf.conf, /etc/nat.conf, /etc/*.conf, /etc/hostname.interface, /var/named/*. </p>
<p>Edit /etc/rc.conf. On my servers I run SMTP, Apache, and ssh. In other words, from the outside it handles email, web acess and secure shell for remote logins. For convenience, on the inside I have a private name server (DNS) and NTP server for accurate time. To get sendmail, NTP, httpd, and NAT to work, these are the lines to change: </p>
<p>sendmail_flags=&#8221;-bd -q30m&#8221;      # for normal use: &#8220;-bd -q30m&#8221;<br />
named_flags=&#8221;"                  # for normal use: &#8220;&#8221;<br />
ntpdate_flags=&#8221;put.server.here&#8221; # for normal use: NTP server; run before ntpd starts<br />
httpd_flags=&#8221;"                  # for normal use: &#8220;&#8221; (or &#8220;-DSSL&#8221; after reading ssl(8))<br />
dhcpd_flags=-q                  # for normal use: &#8220;-q&#8221;<br />
pf=YES                          # Packet filter / NAT<br />
ntpd=YES                        # run ntpd if it exists<br />
pf_rules=/etc/pf.conf           # Packet filter rules file<br />
nat_rules=/etc/nat.conf         # NAT rules file<br />
Make sure that /etc/sysctl.conf has this line in it:</p>
<p>net.inet.ip.forwarding=1        # 1=Permit forwarding (routing) of packets<br />
Get the names of NTP servers close to where you are and put that name in the ntpdate value. Here&#8217;s a list of public NTP servers. </p>
<p>Update ssh<br />
Warning: ssh in OpenBSD 3.1 has a bug!<br />
Upgrading openssh to 3.4 is strongly recommended. See the OpenSSH for OpenBSD page for details. In brief, you will download ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/openssh-3.4.tgz and execute the following steps (as root): </p>
<p># cd /usr/src/usr.bin<br />
# tar xvfz &#8230;/openssh-3.4.tgz<br />
# cd ssh<br />
# make obj<br />
# make cleandir<br />
# make depend<br />
# make<br />
# make install<br />
# cp ssh_config sshd_config /etc/ssh<br />
# mkdir /var/empty<br />
Using vipw(8) you will add this line to your password file: </p>
<p>sshd:*:27:27::0:0:sshd privsep:/var/empty:/sbin/nologin<br />
Then add this line to /etc/group: </p>
<p>sshd:*:27:<br />
NAT and firewall rules<br />
OpenBSD 3.1 has a new packet filter &#8212; 2.9 used ipf but 3.x has a re-written from scratch one called pf. The details are not important; pf config files are much simpler. I decided that my outside interface would be dc0, and the inside one fxp0. (If you&#8217;re using PPPoE, the outside interface will be tun0.) Firewall rules (they tell the gateway what kind of network traffic should be allowed into the internal network) live in /etc/pf.conf; NAT configuration is in /etc/nat.conf. </p>
<p>Here&#8217;s a sample /etc/pf.conf &#8212; very little is accessible from the outside, but machines on the inside can go out with no restrictions. In your files you&#8217;d replace dc0 and fxp0 with the names of your outward- and inward-facing ethernet cards, respectively.</p>
<p>#####################################################################<br />
#<br />
# IP packet filtering rules (firewall)<br />
# Shamim Mohamed 3/2002</p>
<p># See pf.conf(5) for syntax and examples</p>
<p># If you change this file, run<br />
#    pfctl -R /etc/pf.conf<br />
# to update kernel tables (also run &#8220;pfctl -e&#8221; if pf was not running)</p>
<p># Network interfaces<br />
internal = &#8220;fxp0&#8243;<br />
external = &#8220;dc0&#8243;</p>
<p># Services visible from the outside &#8212; remove any you&#8217;re not using<br />
services = &#8220;{ ssh, http, https, smtp }&#8221;</p>
<p># You shouldn&#8217;t need to change anything below this line<br />
#####################################################################</p>
<p># Non-routable IP numbers<br />
nonroutable = &#8220;{ 192.168.0.0/16, 127.0.0.0/8, 172.16.0.0/12, 10.0.0.0/8,<br />
    0.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24, 204.152.64.0/23, 224.0.0.0/3,<br />
    255.255.255.255/32 }&#8221;</p>
<p># All rules are &#8220;quick&#8221; so go strictly top to bottom</p>
<p># Fix fragmented packets<br />
scrub in all</p>
<p># Don&#8217;t bug loopback<br />
#<br />
pass out quick on lo0 from any to any<br />
pass in quick on lo0 from any to any</p>
<p># Don&#8217;t bother the inside interface either<br />
#<br />
pass out quick on $internal from any to any<br />
pass in quick on $internal from any to any</p>
<p>#####################################################################<br />
#<br />
# First, we deal with bogus packets.<br />
#</p>
<p># Block any inherently bad packets coming in from the outside world.<br />
# These include ICMP redirect packets and IP fragments so short the<br />
# filtering rules won&#8217;t be able to examine the whole UDP/TCP header.<br />
#<br />
block in log quick on $external inet proto icmp from any to any icmp-type redir</p>
<p># Block any IP spoofing atempts.  (Packets &#8220;from&#8221; non-routable<br />
# addresses shouldn&#8217;t be coming in from the outside).<br />
#<br />
block in quick on $external from $nonroutable to any</p>
<p># Don&#8217;t allow non-routable packets to leave our network<br />
#<br />
block out quick on $external from any to $nonroutable</p>
<p>#<br />
#####################################################################</p>
<p>#####################################################################<br />
#<br />
# Now the normal filtering rules<br />
#</p>
<p># ICMP: allow incoming ping and traceroute only<br />
#<br />
pass in quick on $external inet proto icmp from any to any icmp-type { \<br />
    echorep, echoreq, timex, unreach }<br />
block in log quick on $external inet proto icmp from any to any</p>
<p># TCP: Allow ssh, smtp, http and https incoming. Only match<br />
# SYN packets, and allow the state table to handle the rest of the<br />
# connection.<br />
#<br />
pass in quick on $external inet proto tcp from any to any port $services flags S/SA keep state</p>
<p># Of course we need to allow packets coming in as replies to our<br />
# connections so we keep state. Strictly speaking, with packets<br />
# coming from our network we don&#8217;t have to only match SYN, but<br />
# what the hell.<br />
#<br />
pass out quick on $external inet proto tcp  from any to any flags S/SA keep state<br />
pass out quick on $external inet proto udp  all keep state<br />
pass out quick on $external inet proto icmp from any to any keep state</p>
<p># End of rules. Block everything to all ports, all protocols and return<br />
# RST (TCP) or ICMP/port-unreachable (UDP).<br />
#<br />
block return-rst in log quick on $external inet proto tcp from any to any<br />
block return-icmp in log quick on $external inet proto udp from any to any<br />
block in quick on $external all</p>
<p>#<br />
# End of file<br />
#<br />
#####################################################################<br />
Read the pf documentation and understand these rules. </p>
<p>This is the NAT config /etc/nat.conf &#8212; this allows machines on the inside network to transparently make connections to the outside world:</p>
<p>#####################################################################<br />
#<br />
# NAT rules<br />
# Shamim Mohamed 3/2002</p>
<p># See nat.conf(5) for syntax and examples</p>
<p># replace dc0 with external interface name, 192.168.1.0/24 with internal<br />
# network (if different)</p>
<p># nat: packets going out through dc0 with source address 192.168.1.0/24 will<br />
# get translated as coming from 12.34.56.78 (or whatever the external IP no.<br />
# is). State is created for such packets, and incoming packets will be<br />
# redirected to the internal address.</p>
<p>nat on dc0 from 192.168.1.0/24 to any -> dc0</p>
<p># End of file<br />
#####################################################################<br />
The system should already have setup /etc/hostname.dc0 and /etc/hostname.fxp0 (or whatever your network device names are) for you. Each file will have the IP number and netmask. This is what these files would look like:</p>
<p>$ cat /etc/hostname.fxp0<br />
inet 192.168.1.1 255.255.255.0 NONE<br />
$ cat /etc/hostname.dc0<br />
inet 123.45.67.89 255.255.255.0 NONE<br />
(The $ is the prompt; cat types a file out to the output.) If you&#8217;re using DHCP, the outside interface&#8217;s hostname file will say dhcp. </p>
<p>Other important files are /etc/myname &#8212; your hostname &#8212; and /etc/mygate &#8212; your default gateway to the outside world (your ISP told you what this should be &#8212; it&#8217;s usually the same as your IP number except that the last number is replaced with a 1 or 254.) </p>
<p>PPPoe<br />
If you have PPPoE (you unfortunate soul!) things are different. You shouldn&#8217;t have /etc/mygate; and the file describing the outside interface, /etc/hostname.dc0 in my example, will only have one word in it: up. This tells the system to bring up the interface at boot time, but to do nothing else &#8212; pppoe will do the rest. </p>
<p>The main file is /etc/ppp/ppp.conf and this is what it should look like:</p>
<p>default:<br />
 set log Phase Chat LCP IPCP CCP tun command<br />
 set redial 15 0<br />
 set reconnect 15 10000</p>
<p>pppoe:<br />
 set device &#8220;!/usr/sbin/pppoe -i dc0&#8243;<br />
 disable acfcomp protocomp<br />
 deny acfcomp<br />
 set mtu 1492<br />
 set speed sync<br />
 enable lqr<br />
 set lqrperiod 5<br />
 set cd 5<br />
 set dial<br />
 set login<br />
 set timeout 0<br />
 set authname login<br />
 set authkey password<br />
 enable dns<br />
 enable mssfixup<br />
Use your login name and password where indicated. The &#8220;set device&#8221; line tells ppp which physical device to use to talk to the outside world. You also have to tell the system to start PPPoE at boot time. That can be done with this little snippet of shell script: </p>
<p>echo -n &#8220;Trying to establish PPPoE DSL&#8221;; ppp -ddial pppoe<br />
for i in 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0; do<br />
    sleep 5<br />
    echo -n.$i&#8221;<br />
    if /usr/local/sbin/adsl-status>/dev/null; then<br />
        break<br />
    fi<br />
done<br />
echo<br />
/usr/local/sbin/adsl-status<br />
Where adsl-status is a little shell-script that tests to see whether the PPP link has come up properly: </p>
<p>#!/bin/sh</p>
<p>IP=$(/sbin/ifconfig tun0 | awk &#8216;/netmask/{print $2}&#8217;)</p>
<p>if [ -z "$IP" ]; then<br />
   echo &#8220;ADSL link is down.&#8221;<br />
   exit 1<br />
else<br />
   echo &#8220;ADSL is up, IP address $IP&#8221;<br />
   exit 0<br />
fi<br />
Now the question is: where should we put the little loop that tries to get ppp going? The right place to put all these is in /etc/rc.local. However this has the drawback that the outside network hasn&#8217;t been initialised while the rest of the system is coming up, which causes some scary-looking error messages from NAT to be printed at boot time. So I do something a little un-kosher: I put the ppp initialisation in /etc/netstart right at the end: </p>
<p>&#8230;<br />
echo -n &#8216; ADSL&#8230; &#8216;; ; ppp -ddial pppoe<br />
for i in 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0; do<br />
    sleep 5<br />
    echo -n.$i&#8221;<br />
    if /usr/local/sbin/adsl-status>/dev/null; then<br />
        break<br />
    fi<br />
done<br />
echo<br />
/usr/local/sbin/adsl-status<br />
Now remember that each time the PPP link goes up or down, the IPF and NAT rules must be re-done. The files /etc/ppp/ppp.linkup and /etc/ppp/linkdown are scripts that get run by ppp. Here&#8217;s /etc/ppp/ppp.linkup: </p>
<p>MYADDR:<br />
 ! sh -c &#8220;/sbin/route del default&#8221;<br />
 ! sh -c &#8220;/sbin/route add default HISADDR -mtu 1492&#8243;<br />
 ! sh -c &#8220;/sbin/pfctl -F all -R /etc/pf.conf -N /etc/nat.conf -e&#8221;<br />
 ! sh -c &#8220;/usr/local/sbin/ntpd -p /var/run/ntpd.pid&#8221;<br />
And this is /etc/ppp/linkdown: </p>
<p>MYADDR:<br />
 ! sh -c &#8220;/sbin/pfctl -F all -d&#8221;<br />
Configuring email<br />
Sendmail should have been setup automatically since you edited /etc/rc.conf but I&#8217;ve occasionally had to make one change in /etc/mail/sendmail.cf: </p>
<p>Djmy-domain-name.com<br />
(If you don&#8217;t own a domain, or plan on having it point to your DSL machine, you don&#8217;t need sendmail.) </p>
<p>You should have a normal user account that you&#8217;re going to use (never log in as root! Always use su or sudo). Administrative email should be forwarded to you; if your normal username is zippy edit /etc/mail/aliases and make sure you make the appropriate lines look like this:</p>
<p># Well-known aliases &#8212; these should be filled in!<br />
root: zippy<br />
manager: zippy<br />
dumper: zippy<br />
One thing you should consider is being an email handler for friends. My DSL service goes down too often &#8212; every few months. This is too unreliable for my tastes. What I do is collaborate with friends to accept and queue email for them, and they do the same for me. Example: for my domain foo.com the primary mail exchanger is gateway.foo.com, the OpenBSD firewall/gateway. A friend of mine has bar.com, and his email gateway is gateway.bar.com. I set up a secondary mail exchanger in my domain records as gateway.bar.com. If my DSL line gateway.foo.com goes down and someone out there wants to send email to me at foo.com, her machine will use gateway.bar.com instead and email will wait on that machine until my machine is back on the network. I want to perform the same service for my friend &#8212; if gateway.bar.com is down, I want people to be able to send my machine the email destined for bar.com and fubar.org (another friend&#8217;s domain). This goes in the file /etc/mail/relay-domains on my gateway box: </p>
<p>bar.com<br />
fubar.org<br />
Now the machine will accept email for my friends&#8217; domains bar.com and fubar.org as well as for itself and forward their messages on. If the machine it&#8217;s trying to forward to is down, it will put them in the queue and keep re-trying for a while. (My friend at bar.com does similar things to his /etc/mail/relay-domains.) </p>
<p>Setting up DNS<br />
You probably shouldn&#8217;t be running the primary DNS server for your domain on your DSL box; DSL may not be reliable enough for that. Get someone else to do it for you for free, like http://www.zoneedit.com/. </p>
<p>However, it is nice to have a local private DNS because lots of daemons (services that run in the background, like the web server) like to do reverse lookups of IP numbers, so we should have a DNS server for the private network. Also, this installation will give you a caching nameserver which should improve your browsing speed. </p>
<p>The files live in /var/named. Assuming your domain is called fake-domain.org, edit named.boot and add these lines:</p>
<p>primary fake-domain.org                 fake-domain.db<br />
primary 1.168.192.in-addr.arpa          fake-domain.rev</p>
<p>; your static IP number, reversed<br />
primary 89.67.45.123.in-addr.arpa      dsl.rev</p>
<p>; remember to add your ISP&#8217;s nameservers here!<br />
forwarders			1.2.3.4 5.4.3.2<br />
(Anything starting with a semicolon is a comment.) Here fakedomain.org can be a real domain you have or a fake; and instead of 89.67.45.123 use your static IP but reversed i.e. you would use that line if your IP number were 123.45.67.89. And change the IP numbers on the forwarders line to the nameservers your ISP told you to use. </p>
<p>There are three files you need to create. The first is /var/named/namedb/fake-domain.db:</p>
<p>@       IN      SOA     gateway.fake-domain.org.     root.fake-domain.org.<br />
(<br />
                                14      ; Serial<br />
                                10800   ; Refresh<br />
                                3600    ; Retry<br />
                                604800  ; Expire<br />
                                86400 ) ; Minimum</p>
<p>        IN      NS      gateway.fake-domain.org.</p>
<p>gateway IN      A       192.168.1.1<br />
libelle IN      A       192.168.1.2<br />
discus  IN      A       192.168.1.4<br />
ventus  IN      A       192.168.1.3<br />
wander  IN      A       192.168.1.5<br />
brad    IN      A       192.168.1.12<br />
jack    IN      A       192.168.1.13</p>
<p>; your static IP number<br />
dsl     IN      A       123.45.67.89</p>
<p>www     IN      CNAME   dsl<br />
mail    IN      CNAME   dsl<br />
In this network, there are six machines on the inside and those are their names and IP Number assignments. The OpenBSD gateway machine is named &#8220;gateway&#8221;. Change these entries to names of the machines on your private network. You can give them any IP number that starts with 192.168.1. Of course if you have three machines on your network, there will only by three entries.) </p>
<p>This is the second file you need to create, /var/named/fake-domain.rev:</p>
<p>@       IN      SOA     gateway.fake-domain.org.     root.fake-domain.org.<br />
(<br />
                                14      ; Serial<br />
                                10800   ; Refresh<br />
                                3600    ; Retry<br />
                                604800  ; Expire<br />
                                86400 ) ; Minimum</p>
<p>        IN      NS      gateway.fake-domain.org.</p>
<p>1       IN      PTR     gateway.fake-domain.org.<br />
2       IN      PTR     libelle.fake-domain.org<br />
3       IN      PTR     ventus.fake-domain.org<br />
4       IN      PTR     discus.fake-domain.org.<br />
5       IN      PTR     wander.fake-domain.org.<br />
12      IN      PTR     brad.fake-domain.org.<br />
13      IN      PTR     jack.fake-domain.org.<br />
(Those trailing dots are important.) And here&#8217;s the third, /var/named/namedb/dsl.rev:</p>
<p>@       IN      SOA     gateway.fake-domain.org.     root.fake-domain.org.<br />
(<br />
                                14      ; Serial<br />
                                10800   ; Refresh<br />
                                3600    ; Retry<br />
                                604800  ; Expire<br />
                                86400 ) ; Minimum</p>
<p>        IN      NS      gateway.fake-domain.org.</p>
<p>        IN      PTR     dsl.fake-domain.org.<br />
PPPoE<br />
Yes, again more stupid special cases for PPPoE. For one thing, your IP address from the outside keeps changing so all the stuff about dsl.rev doesn&#8217;t apply. However, more important: you don&#8217;t know what your ISP&#8217;s DNS servers are! And they could change which machines you&#8217;re supposed to use each time you connect! What you have to do is: connect &#8220;by hand&#8221; one time, and see which DNS servers you got. After ppp.conf has been written, you can run ppp -ddial pppoe and pray. If all goes well, ifconfig tun0 should show you two lines: </p>
<p>$  /sbin/ifconfig tun0<br />
tun0: flags=11<UP,POINTOPOINT> mtu 1492<br />
        inet 63.201.32.40 &#8211;> 63.201.39.254 netmask 0xff000000<br />
That means everything worked. Now look at /etc/resolv.conf &#8212; there should be one or more lines in there that say which nameservers should be used. Put these IP numbers in the forwarders line in /var/named/named.boot. </p>
<p>One other wrinkle: the /etc/resolv.conf that ppp makes for you doesn&#8217;t know about your domain, or that you&#8217;re running a nameserver on your machine. To get around these problems, I created another file /etc/resolv.conf-working: </p>
<p>nameserver 192.168.1.1<br />
lookup file bind<br />
search fake-domain.org<br />
In /etc/ppp/ppp.linkup I tell it to overwrite the created resolv.conf with this one: </p>
<p> ! sh -c &#8220;cp /etc/resolv.conf-working /etc/resolv.conf&#8221;<br />
(Add that to the end of the file that you&#8217;ve already created.) This allows all programs running on the machine to be able to use all the good things about a local caching nameserver &#8212; things like being able to refer to internal hosts by short name etc. </p>
<p>Other machines on the internal network<br />
Go to the other machines on your network (the ones inside your firewall) and set them up with the static IP numbers you assigned above, e.g. the machine wander gets an IP number of 192.168.1.5. All the machines should use 192.168.1.1 for the gateway and use 192.168.1.1 for the DNS server. For more details on DNS, read the excellent O&#8217;Reilly book &#8220;DNS and BIND&#8221;; for more on setting up slightly more complex DNS servers than the one described here, go to the OpenBSD &#8212; DNS site maintained by Samiuela LV Taufa. </p>
<p>Setting up DHCP<br />
Above in the DNS setup all internal machines are assigned their own IP numbers. Running DHCP allows guest machines to hook up to the network without fuss. Depending on your comfort level with setting up your other machines, you might also prefer to use DHCP over assigning static IPs.This is what /etc/dhcpd.conf should look like:</p>
<p>#       $OpenBSD: dhcpd.conf,v 1.1 1998/08/19 04:25:45 form Exp $<br />
#<br />
# DHCP server options.<br />
# See dhcpd.conf(5) and dhcpd(8) for more information.<br />
#</p>
<p># Network:              192.168.1.0/255.255.255.0<br />
# Domain name:          my.domain<br />
# Name servers:         192.168.1.3 and 192.168.1.5<br />
# Default router:       192.168.1.1<br />
# Addresses:            192.168.1.32 &#8212; 192.168.1.127<br />
#<br />
shared-network LOCAL-NET {<br />
        option  domain-name &#8220;fake-domain.org&#8221;;<br />
        option  domain-name-servers 192.168.1.1;</p>
<p>        subnet 192.168.1.0 netmask 255.255.255.0 {<br />
                option routers 192.168.1.1;</p>
<p>                range 192.168.1.32 192.168.1.127;<br />
        }<br />
}<br />
This will allow up to 96 machines on your internal network, which should be more than sufficient. Create an empty temporary file for dhcpd to use:<br />
# touch /var/db/dhcpd.leases<br />
If you make any changes to this file, run dhcpd fxp0 (or whatever your inside network is). (Or you can reboot the machine &#8212; but that&#8217;s the Windows way, in the Unix world we prefer to never reboot any machines.)<br />
Install &#8220;ports&#8221;<br />
&#8220;Ports&#8221; is a *BSD term for a tree of Makefiles for all the software out there that&#8217;s not part of the standard install. I recommend this highly. It is on CD No. 3 of the OpenBSD 3.1 CD-ROM set as ports.tar.gz. Please read the Ports and Packages page on the OpenBSD web site. You install it by typing (as root) </p>
<p># mount /dev/cd0a /mnt<br />
# cd /usr<br />
# tar xzf /mnt/ports.tar.gz<br />
Once you&#8217;ve done this, if you want to install a package, you cd to the appropriate directory and simply type make all install &#8212; it will ftp the source from the appopriate site, handle all dependencies, apply any required patches, configure, build and install the tool. </p>
<p>How do you find the appropriate directory to go to? You can guess at where it might be (look around in /usr/ports to get an idea for the layout etc.). But remember: locate(1) is your friend. </p>
<p>If you have the disk space (about 500 MB), I strongly recommend that you install the source code to the system also. (The source is also on CD No. 3.) </p>
<p># mount /dev/cd0a /mnt<br />
# cd /usr/src<br />
# tar xzf /mnt/src.tar.gz<br />
Getting time from the Internet<br />
Set up NTP so that your machine will always have accurate time. Pick two servers from the public NTP server list and make sure /etc/ntp.conf looks like this: </p>
<p>server ntp.server.first<br />
server ntp.server.second<br />
Since xntpd is not part of the standard install, you have to compile xntpd from source. </p>
<p># cd /usr/ports/sysutils/xntpd<br />
# make all install<br />
The tools will be installed into /usr/local/sbin/ntpd. </p>
<p>Run ntpdate -b server where you pick a server from the list &#8212; this will perform a coarse adjustment of the system clock. The next time the machine reboots, it will sync your clock and record how much your clock drifts. </p>
<p>Setting up other hosts with NTP<br />
On Unix hosts, use the appropriate NTP client; on Linux, it&#8217;s xntpd. Set them up to use 192.168.1.1 as the NTP server. On Windows, use AboutTime &#8212; a free NTP client. In its configuration make sure it uses only SNTP as the protocol, with 192.168.1.1 as the server. Put AboutTime in the Startup folder so it&#8217;s started automatically. </p>
<p>For more details, go to Robert Mooney&#8217;s OpenBSD NTP site. </p>
<p>Tips and Stuff<br />
I have a useful shell script called pkg_install that&#8217;s a front-end to pkg_add &#8212; here&#8217;s an example of it being used:<br />
# pkg_install tex<br />
These files match:<br />
gettext-0.10.40.tgz<br />
jadetex-3.11.tgz<br />
latex2html-97.1.tgz<br />
php4-4.0.6p1-gettext-imap-mhash-no_x11-mcrypt-mysql.tgz<br />
php4-4.0.6p1-gettext-imap-mhash-no_x11-mcrypt-postgresql.tgz<br />
php4-4.0.6p1-gettext.tgz<br />
teTeX_texmf-1.0.2.tgz<br />
texi2html-1.64.tgz<br />
textutils-2.0.tgz<br />
# pkg_install -n 4 texi<br />
Using ftp5.usa.openbsd.org/pub/OpenBSD<br />
+ pkg_add -v ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.1/packages/i386//texi2html-1.64.tgz<br />
Trying to fetch ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.1/packages/i386//texi2html-1.64.tgz.<br />
Extracting from FTP connection into /var/tmp/instmp.BVMJM29414<br />
>>> ftp -o &#8212; ftp://ftp5.usa.openbsd.org/pub/OpenBSD/3.1/packages/i386//texi2html-1.64.tgz<br />
&#8230;<br />
It has a list of all the pre-compiled packages that are available. You type in a string and it installs the package. If more than one name matches, it shows you their names. (It uses egrep(1) so you can use regular expressions.) Save it to /usr/local/bin. It handles dependencies by recursively installing them also. </p>
<p>New in this version is in -n flag. The script has a list of mirrors, and this option picks one of the mirrors. (Currently in progress: it needs bash, and it needs some error checking but it works.) Don&#8217;t forget to edit the file &#8212; read http://www.openbsd.org/ftp.html and choosea list of mirrors closest to you. </p>
<p>Setting up a CVS server<br />
(This section is probably not of interest to most people; you only need this if you want to set up a cvs server so you can put files you&#8217;re working on under source control. So it&#8217;s a little terse too.) </p>
<p>The changes I made: added a user and group named cvs. All users of CVS should be in the cvs group. Create a directory for the repository: I put it in /var/cvsroot, you might put it in /home or wherever. This directory should be group writable (group cvs). Add a line to /etc/services: </p>
<p>      cvspserver	2401/tcp		# CVS pserver<br />
Add this line to /etc/inetd.conf:<br />
      cvspserver	stream	tcp	nowait	root	/usr/bin/cvs cvs -f &#8211;allow-root=/var/cvsroot -T /var/tmp pserver<br />
The server uses /var/tmp as its temp directory instead of /tmp since my root partitions are small, but I always make /var large. Now run cvs init in the cvs repository and restart inetd. Voila! Import your directory of files from a client machine, using a pserver CVSROOT and cvs import. </p>
<p>When importing a large set of files, you might want to put a .cvswrappers file in the directory you&#8217;re importing so CVS won&#8217;t try to put RCS ID strings inside your JPEG files etc. The syntax is: </p>
<p>      *.jpg -k &#8216;b&#8217;<br />
      *.png -k &#8216;b&#8217;<br />
      *.tgz -k &#8216;b&#8217;<br />
Coming soon: using ssh for CVS_RSH.<br />
Setting up X11<br />
You did select the packages xbase, xshare, xfont, and xserv when you installed OpenBSD, I hope? If not, never fear; you can install them directly off the CD: </p>
<p># mount /dev/cd0a /mnt<br />
# cd /<br />
# tar xzvpf /mnt/3.1/i386/xbase31.tgz<br />
# tar xzvpf /mnt/3.1/i386/xserv31.tgz<br />
# tar xzvpf /mnt/3.1/i386/xshare31.tgz<br />
# tar xzvpf /mnt/3.1/i386/xfont31.tgz<br />
etc. The X11 package for ix86 systems is called XFree86; visit their website for more information. Now run xf86cfg. (If the command is not found, you probably don&#8217;t have /usr/X11R6/bin in your PATH environment variable.) Of course this is not something you can do over a network login; you have to be sitting at the machine, with a monitor, keyboard and mouse actually plugged in. You should have your video card and monitor specs available. Follow the instructions to setup XFree86. More information is on the Configuring XFree86 page on the Xfree86 site.<br />
Installing a Desktop<br />
Many people also install a desktop suite such as KDE or Gnome. I prefer KDE of the two. There is nothing special about KDE (or Gnome); it&#8217;s just a set of packages to be installed. There are two versions of KDE available, KDE 2.2 and KDE 3.0. Decide which one you want to run, and install those packages. (KDE2 and KDE3 cannot co-exist on the same system.) </p>
<p>These are the KDE2 packages: </p>
<p>$ pkg_info -a | egrep kde<br />
kdelibs-2.2.2      X11 toolkit, libraries<br />
kdeartwork-2.2.2   X11 toolkit, additional artwork<br />
kdegraphics-2.2.2  X11 toolkit, graphics applications<br />
kdelibs-doc-2.2.2  X11 toolkit, libraries documentation<br />
kdebase-2.2.2      X11 toolkit, basic applications<br />
kdenetwork-2.2.2   X11 toolkit, network applications<br />
kdetoys-2.2.2      some useless kde applications<br />
And for KDE3, the corresponding packages are:<br />
kdeaddons-3.0.tgz<br />
kdeartwork-3.0.tgz<br />
kdebase-3.0.tgz<br />
kdeedu-3.0.tgz<br />
kdegames-3.0.tgz<br />
kdegraphics-3.0.tgz<br />
kdelibs-3.0.tgz<br />
kdenetwork-3.0.tgz<br />
kdetoys-3.0.tgz<br />
kdeutils-3.0.tgz<br />
koffice-1.1.1-kde3.tgz<br />
There are lots of I18N packages also, kde-i18n-*-3.0.tgz.<br />
Display managers xdm and kdm<br />
You may want to run a display manager like xdm or kdm. (A display manager is the program that gives you a graphical login display instead of a plain text message.) The config file for kdm is /usr/local/share/config/kdm/kdmrc; the xdm config file lives in /etc/X11/xdm/xdm-config. Edit /etc/rc.conf and set xdm_flags to an empty string (in quotes) to make xdm run on startup. (If you installed KDE, it will be kdm that&#8217;s started.) If you installed KDE3, add it to the list of available logins in kdmrc: in the [X-*-Greeter] section, look for the SessionTypes line and add &#8220;KDE3&#8243; to the list. </p>
<p>Setting up XDMCP<br />
If you have an X-Terminal (like the Sun Ray, or the ones NCD used to make) or run eXceed on Windows platforms, you may want to allow X11 logins to your OpenBSD machine from eXceed or the X-Terminal. The protocol that allows this is called XDMCP; to enable it: if using xdm, edit /etc/X11/xdm/Xaccess and remove the &#8216;#&#8217; from the first column of this line:</p>
<p>#*                                      #any host can get a login window<br />
Note: we don&#8217;t allow any X11 or XDMCP messages to go across our firewall. Only hosts inside the firewall can get a login screen.<br />
Also edit xdm-config and comment out this line by putting a &#8216;!&#8217; character in the first column:</p>
<p>DisplayManager.requestPort:     0<br />
If using kdm, edit /usr/local/share/config/kdm/kdmrc and look for the [Xdmcp] section. Uncomment lines so it looks like this:<br />
[Xdmcp]<br />
# Whether KDM should listen to XDMCP requests. Default is true.<br />
Enable=true<br />
# The UDP port KDM should listen on for XDMCP requests. Don&#8217;t change the 177.<br />
Port=177<br />
(followed by other stuff.)<br />
Amusements<br />
People like to do things like rip CDs to Ogg Vorbis or MP3 and listen to those files. I use grip as a front-end to rip music to Ogg Vorbis files, and xmms (package name xmms-vorbis) to listen to them. I use Gnu LilyPond and TeX/LaTeX (package teTeX_texmf) to typeset documents and music. The LaTeX files can be converted to HTML with latex2html. You can run Linux programs if you install the redhat_base, redhat_motif, and rpm packages. (The Linux version of Opera, the web browser, runs fine.) </p>
]]></content:encoded>
			<wfw:commentRss>http://www.evanjiang.net.cn/archives/849.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
