关于BSD下的Samba服务配置过程资料搜集 - [采摘]
1、安装samba(如果需要使用swat安装ldap才能使用)
--------------------------------------------------------------
OpenBSD%una...
好久没有Study了,今天去NetBSD & OpenBSD中文用户组看了看,发现了一篇文章关于OpenBSD编译内核的,收藏之:
原著: Brian Schonhorst
翻译: Linyin QQ:731582
内核是操作系统的核心.他是电脑最先启动的二进制文件,并将其加载到内存中.因为他是寄存在内存中,所以他需要尽可能的小.内核文件通常在ROOT目录里('/'),默认名为'bsd'.
拥护如果希望能为他们的系统添加特定的功能或者硬件,他们需要定制内核.在别的系统里,如Linux,原来的内核过于笼肿,所以重新编译内核是十分受欢迎的.对于大部分的用户来说,系统默认的内核已经足够;但是,你仍然需要安装内核补丁,需要重新编译安装系统内核.
你首先要获得系统源代码和补丁.现在我们假定这俩项目已经安装.如果没有,检查我的OpenBSD打补丁指示.你会得到很多有关系统内核源代码的补丁,但确定你是否真的需要他们!
编译一个新的内核
1. 使用合适的工作目录
首先你要进入工作目录,他依赖你所使用的系统平台.以下是个针对MACPPC的列子,但你需要你所使用的系统平台的目录来代替(e.g., i386, alpha,等等...).
$ cd /usr/src/sys/arch/macppc/conf
2. 配置
现在你可以通过MACPPC的配置文件来培植您的内核
$ sudo /usr/sbin/config GENERIC
3. 编译
下一步,我们将使用make(1)来编译新的内核.make程序重新编译其他的程序.我们必须进入正确的目录并运行make程序.第二步会花费点时间.
$ cd /usr/src/sys/arch/macppc/compile/GENERIC
$ sudo make clean && sudo make depend && sudo make
安全新内核
我们已经创建了新内核,但他并不在正确的位置.如果你重启你的电脑,他将默认使用'/'目录下的内核文件.我们刚刚所编译的内核文件存在目录于/usr/src/sys/arch/macppc/compile/GENERIC/.
4. 备份
我们要制作一份备份以防系统无法正常引导新内核.
$ sudo cp /bsd /bsd.old
5.放置内核
现在我们拷贝新内核到'/'下.并允许其执行.
$ sudo cp /usr/src/sys/arch/macppc/compile/GENERIC/bsd /bsd
$ sudo chown root:wheel /bsd
全部完毕
现在内核已经编译并安装,你可以重启电脑并引导它!
$ sudo reboot
指令名称 : chmod
使用权限 : 所有使用者
使用方式 : chmod [-cfvR] [--help] [--version] mode file...
说明 : Linux/Unix 的档案存取权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所存取。
把计 :
mode : 权限设定字串,格式如下 : [ugoa...][[+-=][rwxX]...][,...],其中u 表示该档案的拥有者,g 表示与该档案的拥有者属于同一个群体(group)者,o 表示其他以外的人,a 表示这三者皆是。
+ 表示增加权限、- 表示取消权限、= 表示唯一设定权限。
r 表示可读取,w 表示可写入,x 表示可执行,X 表示只有当该档案是个子目录或者该档案已经被设定过为可执行。
-c : 若该档案权限确实已经更改,才显示其更改动作
-f : 若该档案权限无法被更改也不要显示错误讯息
-v : 显示权限变更的详细资料
-R : 对目前目录下的所有档案与子目录进行相同的权限变更(即以递回的方式逐个变更)
--help : 显示辅助说明
--version : 显示版本
范例 :将档案 file1.txt 设为所有人皆可读取 :
chmod ugo+r file1.txt
chmod a+r file1.txt
将档案 file1.txt 与 file2.txt 设为该档案拥有者,与其所属同一个群体者可写入,但其他以外的人则不可写入 :
chmod ug+w,o-w file1.txt file2.txt
将 ex1.py 设定为只有该档案拥有者可以执行 :
chmod u+x ex1.py
将目前目录下的所有档案与子目录皆设为任何人可读取 :
chmod -R a+r *
此外chmod也可以用数字来表示权限如 chmod 777 file 语法为
chmod abc file
其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。
r=4,w=2,x=1
若要rwx属性则4+2+1=7;
若要rw-属性则4+2=6;
若要r-x属性则4+1=7。
范例:
chmod a=rwx file 和 chmod 777 file 效果相同
chmod ug=rwx,o=x file 和 chmod 771 file 效果相同
若用chmod 4755 filename可使此程式具有root的权限
指令名称 : chown 使用权限 : root
范例 :
将档案 file1.txt 的拥有者设为 users 群体的使用者 jessie :
chown jessie:users file1.txt
将目前目录下的所有档案与子目录的拥有者皆设为 users 群体的使用者 lamport :
chmod -R lamport:users *
-rw------- (600) -- 只有属主有读写权限。
-rw-r--r-- (644) -- 只有属主有读写权限;而属组用户和其他用户只有读权限。
-rwx------ (700) -- 只有属主有读、写、执行权限。
-rwxr-xr-x (755) -- 属主有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
-rwx--x--x (711) -- 属主有读、写、执行权限;而属组用户和其他用户只有执行权限。
-rw-rw-rw- (666) -- 所有用户都有文件读、写权限。这种做法不可取。
-rwxrwxrwx (777) -- 所有用户都有读、写、执行权限。更不可取的做法。
以下是对目录的两个普通设定:
drwx------ (700) - 只有属主可在目录中读、写。
drwxr-xr-x (755) - 所有用户可读该目录,但只有属主才能改变目录中的内容。
suid的代表数字是4,比如4755的结果是-rwsr-xr-x
sgid的代表数字是2,比如6755的结果是-rwsr-sr-x
sticky位代表数字是1,比如7755的结果是-rwsr-sr-t
当然7755这个chmod设置没多大意义
chmod xxxx
四位数是标准写法,在有些语言编程里比如php里0755和755的意义就可能不一样
For Korn/Bourne shells:
# export CVS_RSH=/usr/bin/rsh
For csh/tcsh:
# setenv CVS_RSH /usr/bin/rsh
#setenv CVSROOT=anoncvs@anoncvs.jp.openbsd.org:/cvs
下载最初的当前sys源码树:
# setenv CVSROOT anoncvs@anoncvs.jp.openbsd.org:/cvs
# cd /usr
# cvs -q get -P src
下载当前3.7版本的源码树:
# setenv CVSROOT anoncvs@anoncvs.jp.openbsd.org:/cvs
# cd /usr
# cvs -q get -rOPENBSD_3_7 -P src
在以后更新当前sys源码树:
# cd /usr/src
# cvs -q up -Pd
在以后更新3.7sys源码树:
# cd /usr/src
# cvs -q up -rOPENBSD_3_7 -Pd
如果更新一不同服务器或CD上的源码,必须加 -d $CVSROOT 选项
# cd /usr/src
# cvs -d $CVSROOT -q up -Pd
后面提示输入: yes
这里就等着下载源码吧.
编译内核
# cp /bsd /bsd.old 备份下先
# cd /usr/src/sys/conf/
# cp cp GENERIC Chole1
# vi Chole1
# cd /usr/src/sys/arch/i386/conf
# cp GENERIC Chole
# vi Chole
# config Chole
# cd ../compile/Chole
# make clean && make depend && make [...10分钟不到...]
# make install
# reboot
# $OpenBSD: dot.cshrc,v 1.13 2005/02/13 00:56:13 krw Exp $
#
# csh initialization
umask 022
#alias mail Mail
set history=100
set path=(/sbin /usr/sbin /bin /usr/bin /usr/X11R6/bin /usr/local/sbin /usr/local/bin /usr/local/emul/redhat/usr/bin)
set filec
set SGML_CATALOG_FILES=/usr/local/share/sgml/catalog
set XML_CATALOG_FILES=/usr/local/share/xml/catalog
setenv LANG zh_CN.GB2312
setenv LC_ALL zh_CN.GB2312
setenv LC_CTYPE zh_CN.GB2312
setenv BLOCKSIZE 1k
#setenv LSCOLORS ExFxCxDxBxEgDxDEhGAcHd
setenv SITE ftp://OpenBSD:OpenBSD@ftp.cnfug.org/OpenBSD/snapshots/packages/i386
#setenv SITE ftp://ftp.iij.ad.jp/pub/OpenBSD/3.7/packages/i386
alias ls gls --color --show
alias df df -h
alias du du -h
alias cd 'set old="$cwd"; chdir \!*'
alias h history 25
alias j jobs -l
alias la ls -a
alias ll ls -lA
alias l ls -alF
alias back 'set back="$old"; set old="$cwd"; cd "$back"; unset back; dirs'
alias jj openjade -E O -t sgml -V nochunks -d /usr/local/share/sgml/docbook/dsssl/modular/html/docbook.dsl
alias z suspend
alias x exit
alias pd pushd
alias pd2 pushd +2
alias pd3 pushd +3
alias pd4 pushd +4
if ($?prompt) then
# set prompt="`hostname -s`# "
set prompt="%{\e[0;35m%}[%t]%{\e[0;36m%}[%~]%{\e[0;32m%}>>> "
set filec
set nobeep
set autolist
set rmstar
set history=100
set savehist=100
if ( $?tcsh ) then
bindkey "'W'" backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
endif
安装前的准备
一、 下载所需要的文件:floppy33.fs, 这可从一般的OpenBSD FTP站点上下载!
国内的OpenBSD很少, 我一个都没找到! 在安装时从国外的站点上下载文件很慢, 我上次晚上安装时到了那里就不管理它了, 到第二天早上才去继续安装!
下面说说启动盘的镜像文件:floppy33.fs, floppyB33.fs, floppyC33.fs
floppy33.fs 桌面PC版本, 它支持一般的PCI, ISA NICs, IDE, SCSI接口, 还有一些PCMCIA接口。
floppyB33.fs 服务器版本, 支持很多的RAID, 和一些SCSI。但一些基本的SCSI, ISA NICs, EISA都删除了!
floppyC33.fs 笔记本电脑版本, 支持Cardbus, PCMCIA.
我想, 一般都是桌面PC, 我自己的就是, 下载floppy33.fs.
下面是安装所需要的一些基本文件, 我把它下载下来放到内部网的FTP上了, 这样安装起来快一些:
bsd, bsd.rd, base33.tgz, etc33.tgz, comp33.tgz, man33.tgz, misc33.tgz, game33.tgz, xbase33.tgz,xfont33.tgz, xserv33.tgz, xshare33.tgz.
我还下载了ports.tar.gz, src.tar.gz, sys.tar.gz, 系统安装后这些ports tree, 内核源码都没安装, 要自己手动安装的。
二、制作启动盘
现在我们已下载了软盘镜像, 开始制作启动盘
1. Unix 下:
我是在slackware上制作的, 我在windows 下用rawrite2.exe没作成功!
# fdformat /dev/fd0
# dd if=floppy33.fs of=/dev/fd0 bs=32k
2. windows下(请参考OpenBSD主站上的安装指南)
主要工具都放在FTP站点上的TOOLS目录里, 主要有: rawrite, fdimage, ntrw, rawrite不能在windows NT, windows 2000 or XP下使用!
相关操作可自己找资料, 都很简单, 在DOS下操作!
现在我们要收集自己计算机上的信息:什么平台, 硬盘上的资料要不要备份?, 网卡信息(IP,subnet masks, gateway, DNS) 一些isa卡可以安装时以dmesg查看!
已下载了安装所需要的文件!现在我们进行的是FTP安装, 我将下载的文件放在FTP上, 目录是openbsd/OpenBSD下!这样安装快很多!
安装过程
用软盘启动系统!我们会看到蓝色背景的字!这里是OpenBSD的开机信息!然后我们会看到下面的这个:
erase ^?, werase ^W, kill ^U, intr ^C, status ^T
(I)nstall, (U)pgrade or (S)hell? I
选择I, 安装新系统, 如果是从原来的系统上升级则选择U, 或者你可以选择S, 在SHELL下操作, 其实当你在安装过程序中自己有某些设置错误Ctrl + c中止后, 也是回到这个SHEEL下操作的!在SHEEL下执行install就是安装系统。
Welcome to the OpenBSD/i386 3.3 install program.
This program will help you install OpenBSD in a simple and rational way. At
any prompt except password prompts you can run a shell command by typing
'!foo', or escape to a shell by typing '!'. Default answers are shown in []'s
and are selected by pressing RETURN. At any time you can exit this program by
pressing Control-C and then RETURN, but quitting during an install can leave
your system in an inconsistent state.
Specify terminal type: [vt220] Enter
Do you wish to select a keyboard encoding table? [n] y
选择键盘类型, 一些都是US。
IS YOUR DATA BACKED UP? As with anything that modifies disk contents, this
program can cause SIGNIFICANT data loss.
It is often helpful to have the installation notes handy. For complex disk
configurations, relevant disk hardware manuals and a calculator are useful.
Proceed with install? [n] y
下面我们继续安装:
Cool! Let's get to it...
You will now initialize the disk(s) that OpenBSD will use. To enable all
available security features you should configure the disk(s) to allow the
creation of separate filesystems for /, /tmp, /var, /usr, and /home.
选择从哪个硬盘上安装, 我的系统只挂了一个小硬盘, 所以只一个!
Available disks are: wd0.
Which one is the root disk? (or done) [wd0] Enter
是否整个硬盘都安装OpenBSD, 是.
Do you want to use *all* of wd0 for OpenBSD? [no] yes
Treating sectors 63-6303024 as the OpenBSD portion of the disk.
You can use the 'b' command to change this.
Initial label editor (enter '?' for help at any prompt)
> ?
现在我们来进行硬盘分区, 这里打入?寻求帮助!
Available commands:
p [unit] - print label.
M - show entire OpenBSD man page for disklabel.
e - edit drive parameters.
a [part] - add new partition.
b - set OpenBSD disk boundaries.
c [part] - change partition size.
d [part] - delete partition.
D - set label to default.
g [d|b] - Use [d]isk or [b]ios geometry.
m [part] - modify existing partition.
n [part] - set the mount point for a partition.
r - recalculate free space.
u - undo last change.
s [path] - save label to file.
w - write label to disk.
q - quit and save changes.
x - exit without saving changes.
X - toggle expert mode.
z - zero out partition table.
? [cmnd] - this message or command specific help.
Numeric parameters may use suffixes to indicate units:
'b' for bytes, 'c' for cylinders, 'k' for kilobytes, 'm' for megabytes,
'g' for gigabytes or no suffix for sectors (usually 512 bytes).
Non-sector units will be rounded to the nearest cylinder.
Entering '?' at most prompts will give you (simple) context sensitive help.
>
我分了五个区, a 根分区 200M, b 交换分区 300M , d 100M /tmp, e 100M /var , f 最后的全给 /usr,
使用 d删除分区,a 创建分区,p 查看分区情况,q 退出!
d a 删除a分区
a a 创建a分区
p g 查看分区, 大小以G显示
p m 查看分区, 大小以M显示
下面我们挂载分区:
The root filesystem will be mounted on wd0a.
wd0b will be used for swap space.
Mount point for wd0d (size=122976k), none or done? [/tmp] Enter
Mount point for wd0e (size=82152k), none or done? [/var] Enter
Mount point for wd0g (size=2097144k), none or done? [/usr] Enter
Mount point for wd0h (size=4194288k), none or done? [/home] Enter
Mount point for wd0d (size=122976k), none or done? [/tmp] done
Done - no available disks found.
You have configured the following partitions and mount points:
wd0a /
wd0d /tmp
wd0e /var
wd0g /usr
wd0h /home
格式化分区:
The next step creates a filesystem on each partition, ERASING existing data.
Are you really sure that you're ready to proceed? [n] y
/dev/rwd0a: 307440 sectors in 305 cylinders of 16 tracks, 63 sectors
200MB in 20 cyl groups (16 c/g, 7.88MB/g, 1920 i/g)
/dev/rwd0b: 245952 sectors in 244 cylinders of 16 tracks, 63 sectors
300MB in 16 cyl groups (16 c/g, 7.88MB/g, 1920 i/g)
/dev/rwd0d: 164304 sectors in 163 cylinders of 16 tracks, 63 sectors
100MB in 11 cyl groups (16 c/g, 7.88MB/g, 1920 i/g)
/dev/rwd0e: 4194288 sectors in 4161 cylinders of 16 tracks, 63 sectors
100MB in 261 cyl groups (16 c/g, 7.88MB/g, 1920 i/g)
/dev/rwd0f: 8388576 sectors in 8322 cylinders of 16 tracks, 63 sectors
2300MB in 521 cyl groups (16 c/g, 7.88MB/g, 1920 i/g)
/dev/wd0a on /mnt type ffs (rw, asynchronous, local, ctime=Thu Oct 10 21:
50:36 2 002)
/dev/wd0h on /mnt/home type ffs (rw, asynchronous, local, nodev, nosuid,
ctime=Thu Oct 10 21:50:36 2002)
/dev/wd0d on /mnt/tmp type ffs (rw, asynchronous, local, nodev, nosuid,
ctime=Thu Oct 10 21:50:36 2002)
/dev/wd0g on /mnt/usr type ffs (rw, asynchronous, local, nodev, ctime=Th
u Oct 10 21:50:36 2002)
/dev/wd0e on /mnt/var type ffs (rw, asynchronous, local, nodev, nosuid,
ctime=Th u Oct 10 21:50:36 2002)
配置主机名
Enter system hostname (short form, e.g. 'foo'): OpenBSD
配置网络:
Configure the network? [y] Enter
Available interfaces are: ne3.
Which one do you wish to initialize? (or 'done') [ne3] Enter
Symbolic (host) name for fxp0? [puffy] Enter
The default media for fxp0 is
media: Ethernet autoselect (100baseTX full-duplex)
Do you want to change the default media? [n] Enter
IP address for fxp0? (or 'dhcp') 202.116.92.235
Netmask? [255.255.255.0] 255.255.254.0
Done - no available interfaces found.
DNS domain name? (e.g. 'bar.com') [my.domain] OpenBSD.localhost
DNS nameserver? (IP address or 'none') [none] 202.116.64.1
Use the nameserver now? [y] Enter
Default route? (IP address, 'dhcp' or 'none') 202.116.92.1
add net default: gateway 202.116.92.1
Edit hosts with ed? [n] Enter
Do you want to do any manual network configuration? [n] Enter
设置root密码, 不会显示出来的!
Password for root account? (will not echo)
Password for root account? (again)
现在我们选择安装方式, 我是FTP安装!硬盘安装就设置相应的东西就行了!
You will now specify the location and names of the install sets you want to
load. You will be able to repeat this step until all of your sets have been
successfully loaded. If you are not sure what sets to install, refer to the
installation notes for details on the contents of each.
Sets can be located on a (m)ounted filesystem; a (c)drom, (d)isk or (t)ape
device; or a (f)tp, (n)fs or (h)ttp server.
Where are the install sets? f
下面我们设置FTP服务器的地址! 是否要设置代理? FTP, HTTP安装都一样, 如果需要设置一下!
HTTP/FTP proxy URL? ( e.g. ‘http://proxy.8080’, or ‘none’ ) [ none ] Entry
查看FTP列表:
Do you want to see a list of potential ftp servers? [ y ] n
设置FTP的地址
Server IP address, or hostname ? 我的FTP地址
Does the server support passive mode ftp? [ y ]
设置放置安装文件的目录, 根据自己的设置写目录
Server directory? [ pub/OpenBSD/3.3/i386 ] openbsd/OpenBSD
是否匿名登陆, 不是, 则输入用户名, 密码!
Login? [ anonymous ] usernme
Password? [ will no echo ] password
下面是选择要安装的软件包:我试过, 如果你的FTP上有几个包它会显示几个包, 但有几个包是一定要的:bsd, base33.tgz, etc33.tgz, comp33.tgz, man33.tgz. 打入all将选择全部安装:
The following sets are available. Enter a filename, 'all' to select
all the sets, or 'done'. You may de-select a set by prepending a '-'
to its name.
[X] bsd
[ ] bsd.rd
[X] base33.tgz
[X] etc33.tgz
[X] misc33.tgz
[X] comp33.tgz
[X] man33.tgz
[X] game33.tgz
[ ] xbase33.tgz
[ ] xshare33.tgz
[ ] xfont33.tgz
[ ] xserv33.tgz
File Name? (or 'done') [bsd.rd] all
The following sets are available. Enter a filename, 'all' to select
all the sets, or 'done'. You may de-select a set by prepending a '-'
to its name.
[X] bsd
[X] bsd.rd
[X] base33.tgz
[X] etc33.tgz
[X] misc33.tgz
[X] comp33.tgz
[X] man33.tgz
[X] game33.tgz
[X] xbase33.tgz
[X] xshare33.tgz
[X] xfont33.tgz
[X] xserv33.tgz
File Name? (or 'done') [done] doen
选择好包后, 开始下载安装:
Ready to install sets? [y] Enter
Getting bsd ...
100% |**************************************************| 4472 KB 00:03
Getting bsd.rd ...
100% |**************************************************| 4190 KB 00:02
Getting base33.tgz ...
100% |**************************************************| 30255 KB 00:21
Getting etc33.tgz ...
100% |**************************************************| 1469 KB 00:01
Getting misc33.tgz ...
100% |**************************************************| 1828 KB 00:01
Getting comp33.tgz ...
100% |**************************************************| 16207 KB 00:13
Getting man33.tgz ...
100% |**************************************************| 5921 KB 00:04
Getting game33.tgz ...
100% |**************************************************| 2545 KB 00:01
Getting xbase33.tgz ...
100% |**************************************************| 9073 KB 00:06
Getting xshare33.tgz ...
100% |**************************************************| 1574 KB 00:02
Getting xfont33.tgz ...
100% |**************************************************| 30666 KB 00:21
Getting xserv33.tgz ...
100% |**************************************************| 14948 KB 00:11
Sets can be located on a (m)ounted filesystem; a (c)drom, (d)isk or (t)ape
device; or a (f)tp, (n)fs or (h)ttp server.
Where are the install sets? (or 'done')done
现在基本包安装完成!设置一下时区, 还有你以后要不要运行X:
Extract more sets? [n] Enter
Do you expect to run the X Window System? [y] y
Saving configuration files......done.
Generating initial host.random file ......done.
What timezone are you in? ('?' for list) [US/Pacific] ? 寻求帮助!
Africa/ Chile/ GB-Eire Israel NZ-CHAT Turkey
America/ Cuba GMT Jamaica Navajo UCT
Antarctica/ EET GMT+0 Japan PRC US/
Arctic/ EST GMT-0 Kwajalein PST8PDT UTC
Asia/ EST5EDT GMT0 Libya Pacific/ Universal
Atlantic/ Egypt Greenwich MET Poland W-SU
Australia/ Eire HST MST Portugal WET
Brazil/ Etc/ Hongkong MST7MDT ROC Zulu
CET Europe/ Iceland Mexico/ ROK posix/
CST6CDT Factory Indian/ Mideast/ Singapore posixrules
Canada/ GB Iran NZ SystemV/ right/
What timezone are you in? ('?' for list) [US/Pacific] Asia
然后输入:Shanghai,
Making all device nodes...done.
Installing boot block...
boot: /mnt/boot
proto: /usr/mdec/biosboot
device: /dev/rwd0c
/usr/mdec/biosboot: entry point 0
proto bootblock size 512
room for 12 filesystem blocks at 0x16f
Will load 7 blocks of size 8192 each.
Using disk geometry of 63 sectors and 240 heads.
0: 9 @(203 150 55) (3078864-3078872)
1: 63 @(203 151 1) (3078873-3078935)
2: 24 @(203 152 1) (3078936-3078959)
3: 16 @(203 8 47) (3069910-3069925)
/mnt/boot: 4 entries total
using MBR partition 1: type 166 (0xa6) offset 3069360 (0x2ed5b0)
...done.
CONGRATULATIONS! Your OpenBSD install has been successfully completed!
To boot the new system, enter halt at the command prompt. Once the
system has halted, reset the machine and boot from the disk.
# reboot
现在重启, 系统已安装完成!
安装后配置
我们安装了基本的系统,但只有最基本的东西, 像内核源代码, ports tree都没安装!
在安装时我们安装了X, 现在我们配置X-windows, 运行xf86cfg设置!OpenBSD的默认桌面是fvwm。
现在我们给系统添加新用户adduser, 在第一次使用时会有一些基本的设置, 如密码使用什么加密, 有好几种, 我选择了最常用的md5。
首先, 我们开始安装内核源代码, 为以后编译内核作准备!
如果你有CD,则只需要从CD中取出src.tar.gz,cd /usr/src 然后tar xvzf src.tar.gz, 上篇, 我们是从FTP安装的, 因此, 我们要下载两个包:src.tar.gz, sys.tar.gz.
ftp://ftp.ca.openbsd.org/pub/OpenBS...i386/src.tar.gz
ftp://ftp.ca.openbsd.org/pub/OpenBS...i386/sys.tar.gz
安装ports tree, 下载ports.tar.gz, 然后copy /usr/ , tar xzvf ports.tar.gz .
ftp://ftp.ca.openbsd.org/pub/OpenBS...86/ports.tar.gz
安装cvsup,
下载cvsup-16.1f.tar.gz, 如果没安装X则下载 cvsup-16.1f-no_X.tar.gz
#ftp://ftp.ca.openbsd.org/pub/OpenBS...p-16.1f..tar.gz
#pkg_add cvsup-16.1f.tar.gz
编辑cvsup-supfile, OpenBSD里的编辑器是mg, 类似于emacs。
#Defaults that apply to all the collections
*default release=cvs
*default delete use-rel-suffix
*default umask=002
*default host=cvsup.uk.openbsd.org
*default base=/cvsup
*default prefix=/cvsup
#If your network link is T1 or faster, comment out the following line.
*default compress
OpenBSD-all
#OpenBSD-src
#OpenBSD-www
#OpenBSD-ports
#OpenBSD-x11
#OpenBSD-xf4
保存,
# mg cvsup-supfile
# cd /
# mkdir cvsup
# cd
# cvusp –g –L 2 cvsup-supfile
就可升级ports tree等了!
安装软件同FreeBSD下一样, 以后再说说编译内核吧!
主要cvsup站点:
cvsup.uk.openbsd.org]
cvsup.de.openbsd.org
cvsup2.de.openbsd.org
cvsup.hu.openbsd.org
cvsup.fr.openbsd.org
cvsup.ca.openbsd.org
cvsup.usa.openbsd.org
cvsup.kr.openbsd.org
cvsup.no.openbsd.org
cvsup.pt.openbsd.org
anoncvs.de.openbsd.org
rt.fm
skeleton.phys.spbu.ru
cvsup.jp.OpenBSD.org
mirror.osn.de
openbsd.informatik.uni-erlangen.de
OpenBSD-src - The src repository
OpenBSD-ports - The ports repository
OpenBSD-www - The www repository
OpenBSD-x11 - The XFree86-3 repository
OpenBSD-xf4 - The XFree86-4 repository
OpenBSD-all - All OpenBSD repositories
网络配置
因为与FreeBSD等配置有点出入, 所以我在这里指出来!
我自己是使用局域网, 所以只介绍这个方面的, 如果有人使用的是PPP方式, 可自行查看官方站点上的FAQ。
可能很多使用OpenBSD的人是从FreeBSD下转过来的, 但OpenBSD的网络设置与FreeBSD有所不同, 它的网络配置没有写进rc.conf, 而是作为单独的文件存放的。
网卡IP存放在/etc/hostname.网卡型号名, 网关存放在/etc/mygate
主机名存放在/etc/myname, 名字服务器地址没变, 存放在/etc/resolv.conf
我们使用ifconfig –a 查看网卡型号:(这个是我已配置好的)
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33224
inet 127.0.0.1 netmask 0xff000000
lo1: flags=8008<LOOPBACK,MULTICAST> mtu 33224
ne0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:e0:4c:e0:45:0c
media: Ethernet autoselect (10baseT)
inet ***.***.***.*** netmask 0xfffffe00 broadcast ***.***.***.***
pflog0: flags=0<> mtu 33224
pfsync0: flags=0<> mtu 2020
我的网卡是ne0, 但不知怎么的, 系统安装好后, 在/etc/中建立的文件却是hostname.ne3, 我只好自己手动改成 hostname.ne0,
关于这个hostname.*文件的格式:
inet 192.168.0.1 netmask 255.255.255.0 NONE
inet 指定ip地址, netmask指定网络掩码。
当然你也可以指定详细的网卡说明:
inet 10.0.0.38 255.255.255.0 NONE media 100baseTX mediaopt full-duplex
现在指定网关, 修改/etc/mygate, 写入网关IP就行了。
主机名, 写入/etc/myname.
/etc/resolv.conf, 与别的系统一样的, 这个就不用说了!
2003 年 7 月, OpenBSD 的防火墙, 也就是常说的 PF 被成功地移植到了 FreeBSD 上, 并可以通过 FreeBSD Ports Collection 来安装了; 第一个将 PF 集成到基本系统中的版本是 2004 年 11 月发行的 FreeBSD 5.3。 PF 是一个完整的提供了大量功能的防火墙软件, 并提供了可选的 ALTQ (交错队列, Alternate Queuing) 功能。 ALTQ 提供了服务品质 (QoS) 带宽整形功能, 这个功能能够以基于过滤规则的方式来保障不同服务的带宽。 OpenBSD Project 在维护 PF 用户指南方面已经做了非常卓越的工作,因此我们不打算在这本使用手册中进行更进一步的阐述, 以避免不必要的重复劳动。
PF 在各种 FreeBSD 发行版上的可用情况如下所示:
| FreeBSD 版本 | PF 可用情况 |
|---|---|
| 4.X 之前的版本 | PF 在 FreeBSD 4.X 之前的版本分支上不可用。 |
| 所有 4.X 版本分支上的版本 | PF 作为 KAME 的一部分提供。 |
| 5.X 在 5.3-RELEASE 之前的版本 | security/pf port 可以用来在这些 FreeBSD 版本上安装 PF。这些版本主要是供开发人员, 以及预览早期的 5.X 版本上使用的。 强烈建议升级到 5.3-RELEASE 或更新的 FreeBSD 版本。 |
| 5.3-RELEASE 以及之后的版本 | PF 已经成为了基本系统的一部分。 请 不要 尝试使用 security/pf port 在这些 FreeBSD 版本上安装它,因为这样做是没有作用的。 请使用基本系统中的 pf(4) 支持。 |
更多的详细信息, 可以在 FreeBSD 版本的 PF 网站上找到: http://pf4freebsd.love2party.net/。
OpenBSD PF 用户指南可以在这里找到:http://www.openbsd.org/faq/pf/。
警告: 在 FreeBSD 5.X 上的 PF 相当于 OpenBSD 3.5 版本。 以 port 形式出现在 FreeBSD Ports Collection 的版本相当于 OpenBSD 的 3.4 版。 在阅读用户指南时,请注意这样的区别。
PF 作为 FreeBSD 5.3 和更高版本基本系统安装的一部分, 作为一个可以动态加载的模块出现。如果在 rc.conf 中配置了 pf_enable="YES" 则系统会自动加载对应的内核模块。 可加载内核模块在构建时启用了 pflog(4)。
注意: 这个模块假定 options INET 和 device bpf 是存在的。 除非编译时指定了 NOINET6 (例如在 make.conf(5) 中) 则还需要 options INET6。
将下面这些选项加入到 FreeBSD 内核的编译配置文件中并不是启用 PF 的强制性要求。这里列出它们主要是为了介绍一些背景信息。 将 PF 编译到内核中之后,就不再需要使用可加载内核模块了。
如何在内核编译配置中加入对于 PF 选项的例子可以在内核源代码中的 /usr/src/sys/conf/NOTES 这个文件中找到。 这里列举如下:
device pf device pflog device pfsync
device pf 用于启用 “Packet Filter” 防火墙的支持。
device pflog 启用可选的 pflog(4) 伪网络设备,用以通过 bpf(4) 描述符来记录流量。 pflogd(8) 服务可以用来存储信息, 并把它们以日志形式记录到磁盘上。
device pfsync 启用可选的 pfsync(4) 伪网络设备,用以监视 “状态变更”。 由于这不是那个可加载内核模块的一部分, 因此如果需要使用它,就必须自行编译定制的内核了。
这些设置只有在您使用它们构建和安装新内核之后才会生效。
您需要在 /etc/rc.conf 中添加如下配置, 以便在启动时激活 PF:
pf_enable="YES" # 启用 PF (如果需要的话, 自动加载内核模块) pf_rules="/etc/pf.conf" # pf 使用的规则定义文件 pf_flags="" # 启动时传递给 pfctl 的其他选项 pflog_enable="YES" # 启动 pflogd(8) pflog_logfile="/var/log/pflog" # pflogd 用于记录日志的文件名 pflog_flags="" # 启动时传递给 pflogd 的其他选项
如果您的防火墙后面有一个 LAN, 而且需要通过它来转发 LAN 上的包, 或进行 NAT,还必须同时启用下述选项:
gateway_enable="YES" # 启用作为 LAN 网关的功能
ALTQ 只有在作为编译选项加入到 FreeBSD 内核时,才能使用。 ALTQ 目前还不是所有的可用网卡驱动都能够支持的。 请参见 altq(4) 联机手册了解您正使用的 FreeBSD 版本中的驱动支持情况。 下面这些选项将启用 ALTQ 以及一些附加的功能。
options ALTQ options ALTQ_CBQ # Class Bases Queuing (CBQ) options ALTQ_RED # Random Early Detection (RED) options ALTQ_RIO # RED In/Out options ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC) options ALTQ_PRIQ # Priority Queuing (PRIQ) options ALTQ_NOPCC # Required for SMP build
options ALTQ 将启用 ALTQ 框架的支持。
options ALTQ_CBQ 用于启用基于分类的队列 (CBQ) 支持。 CBQ 允许您将连接分成不同的类别, 或者说, 队列, 以便在规则中为它们指定不同的优先级。
options ALTQ_RED 将启用随机预检测 (RED)。 RED 是一种用于防止网络拥塞的技术。 RED 度量队列的长度,并将其与队列的最大和最小长度阈值进行比较。 如果队列过长, 则新的包将被丢弃。 如名所示, RED 从不同的连接中随机地丢弃数据包。
options ALTQ_RIO 将启用出入的随机预检测。
options ALTQ_HFSC 启用层次式公平服务平滑包调度器。 要了解关于 HFSC 进一步的信息, 请参见 http://www-2.cs.cmu.edu/~hzhang/HFSC/main.html。
options ALTQ_PRIQ 启用优先队列 (PRIQ)。 PRIQ 首先允许高优先级队列中的包通过。
options ALTQ_NOPCC 启用 ALTQ 的 SMP 支持。 如果是 SMP 系统, 则必须使用它。