|
OpenBSD 系列(四)
在前面的三篇中我们介绍了OpenBSD的安装, 在这篇中我们简单的介绍一下OpenBSD的网络设置和内核编译。
我自己是使用局域网, 所以只介绍这个方面的, 如果有人使用的是PPP方式, 可自行查看官方站点上的FAQ。
可能很多使用OpenBSD的人是从FreeBSD下转过来的, 但OpenBSD的网络设置与FreeBSD有所不同, 它的网络配置没有写进rc.conf, 而是作为单独的文件存放的。
网卡IP存放在/etc/hostname.网卡型号名, 网关存放在/etc/mygate
主机名存放在/etc/myname, 名字服务器地址没变, 存放在/etc/resolv.conf
我们使用ifconfig –a 查看网卡型号:(这个是我已配置好的)
[color="red"]
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, 与别的系统一样的, 这个就不用说了!
下面我们来配置内核吧!
首先查看开机信息: dmesg
[color="red"]
OpenBSD 3.3 (GENERIC) #44: Sat Mar 29 13:22:05 MST 2003
deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel Pentium III (Tualatin) ("GenuineIntel" 686-class) 1.01 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SYS,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SIMD
real mem = 133738496 (130604K)
avail mem = 118341632 (115568K)
using 1658 buffers containing 6791168 bytes (6632K) of memory
mainbus0 (root)
bios0 at mainbus0: AT/286+(73) BIOS, date 02/21/02, BIOS32 rev. 0 @ 0xfb190
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
pcibios0 at bios0: rev. 2.1 @ 0xf0000/0xdf94
pcibios0: PCI IRQ Routing Table rev. 1.0 @ 0xfded0/192 (10 entries)
pcibios0: PCI Exclusive IRQs: 5 9 11
pcibios0: PCI Interrupt Router at 000:31:0 ("Intel 82371SB PCI-ISA" rev 0x00)
pcibios0: PCI bus #2 is the last bus
bios0: ROM list: 0xc0000/0xa800
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel 82815 Hub" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel 82815 AGP" rev 0x02
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "Nvidia Riva TNT2" rev 0x15
wsdisplay0 at vga1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
ppb1 at pci0 dev 30 function 0 "Intel 82801BA AGP" rev 0x05
pci2 at ppb1 bus 2
ne3 at pci2 dev 2 function 0 "Realtek 8029" rev 0x00: irq 11
ne3: address 00:e0:4c:e0:45:0c
pcib0 at pci0 dev 31 function 0 "Intel 82801BA LPC" rev 0x05
pciide0 at pci0 dev 31 function 1 "Intel 82801BA IDE" rev 0x05: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: <ST33221A>
wd0: 32-sector PIO, LBA, 3077MB, 6253 cyl, 16 head, 63 sec, 6303024 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
atapiscsi0 at pciide0 channel 1 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <MIDA, M16XD, 3.15> SCSI0 5/cdrom removable
cd0(pciide0:1:1): using PIO mode 4, Ultra-DMA mode 2
uhci0 at pci0 dev 31 function 2 "Intel 82801BA USB" rev 0x05: irq 11
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: vendor 0x0000 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
"Intel 82801BA SMBus" rev 0x05 at pci0 dev 31 function 3 not configured
uhci1 at pci0 dev 31 function 4 "Intel 82801BA USB2" rev 0x05: irq 11
usb1 at uhci1: USB revision 1.0
uhub1 at usb1
uhub1: vendor 0x0000 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
auich0 at pci0 dev 31 function 5 "Intel 82801BA AC97 Audio" rev 0x05: irq 9, ICH2 AC97
ac97: codec id 0x414c4710 (Avance Logic ALC200)
ac97: codec features headphone, 18 bit DAC, 18 bit ADC, Realtek 3D
audio0 at auich0
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <C speaker>
sysbeep0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
npx0 at isa0 port 0xf0/16: using exception 16
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
biomask c840 netmask c840 ttymask d8c2
pctr: 686-class user-level performance counters enabled
mtrr: Pentium Pro MTRR support
dkcsum: wd0 matched BIOS disk 80
root on wd0a
rootdev=0x0 rrootdev=0x300 rawdev=0x302
现在我们依开机信息对/usr/src/sys/arch/i386/conf的GENERIC进行选择(这样出错少, 当然你对自己机配置很熟也不用这样做):
[color="red"]
machine i386 # architecture, used by config; REQUIRED
include "../../../conf/GENERIC"
option I686_CPU
option GPL_MATH_EMULATE # floating point emulation.
option USER_PCICONF # user-space PCI configuration
option APERTURE # in-kernel aperture driver for XFree86
option COMPAT_SVR4 # binary compatibility with SVR4
option COMPAT_LINUX # binary compatibility with Linux
option COMPAT_FREEBSD # binary compatibility with FreeBSD
option COMPAT_BSDOS # binary compatibility with BSD/OS
maxusers 32 # estimated number of users
config bsd swap generic
mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
pcibios0 at bios0 flags 0x0000 # use 0x30 for a total verbose
isa0 at mainbus0
isa0 at pcib?
pci* at mainbus0 bus ?
option PCIVERBOSE
pchb* at pci? dev ? function ? # PCI-Host bridges
ppb* at pci? dev ? function ? # PCI-PCI bridges
pci* at ppb? bus ?
pci* at pchb? bus ?
pcib* at pci? dev ? function ? # PCI-ISA bridge
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?
option WSDISPLAY_COMPAT_USL # VT handling
option WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
option WSDISPLAY_DEFAULTSCREENS=6
option WSDISPLAY_COMPAT_PCVT # emulate some ioctls
pckbc0 at isa? # PC keyboard controller
pckbd* at pckbc? # PC keyboard
pms* at pckbc? # PS/2 mouse for wsmouse
option PCIAGP
vga* at pci? dev ? function ?
wsdisplay* at vga? console ?
wskbd* at pckbd? console ?
wsmouse* at pms? mux 0
pcppi0 at isa?
sysbeep0 at pcppi?
pccom0 at isa? port 0x3f8 irq 4 # standard PC serial ports
pccom1 at isa? port 0x2f8 irq 3
fdc0 at isa? port 0x3f0 irq 6 drq 2 # standard PC floppy controllers
#fdc1 at isa? port 0x370 irq ? drq ?
fd* at fdc? drive ? flags 0x00
# IDE controllers
pciide* at pci ? dev ? function ? flags 0x0000
# IDE hard drives
#wd* at wdc? channel ? drive ? flags 0x0000
wd* at pciide? channel ? drive ? flags 0x0000
# Networking devices
ne* at pci? dev ? function ? # NE2000-compat ethernet
# Media Independent Interface (mii) drivers
auich* at pci? dev ? function ? # i82801 ICH AC'97 audio
# MIDI support
midi* at pcppi? # MIDI interface to the PC speaker
audio* at auich?
pseudo-device pctr 1
pseudo-device mtrr 1 # Memory range attributes control
pseudo-device sequencer 1
#pseudo-device raid 4 # RAIDframe disk driver
pseudo-device bio 1 # ioctl multiplexing device
# mouse & keyboard multiplexor pseudo-devices
pseudo-device wsmux 2
#pseudo-device crypto 1
这上面就是我依dmesg进行配置的, 用起来很好。
OpenBSD内核编译要用到两个文件, 下面我们还有一个文件要配置/usr/src/sys/conf/GENERIC
[color="red"]
# $OpenBSD: GENERIC,v 1.93 2003/02/28 21:29:08 tedu Exp $
#
# Machine-independent option; used by all architectures for their
# GENERIC kernel
#option INSECURE # default to secure
option DDB # in-kernel debugger
#option DDB_SAFE_CONSOLE # allow break into ddb during boot
#makeoptions DEBUG="-g" # compile full symbol table
#makeoptions PROF="-pg" # build profiled kernel
#option GPROF # kernel profiling, kgmon(8)
option DIAGNOSTIC # internal consistency checks
option KTRACE # system call tracing, a la ktrace(1)
option KMEMSTATS # collect malloc(9) statistics
option PTRACE # ptrace(2) system call
#option CRYPTO # Cryptographic framework
option SYSVMSG # System V-like message queues
option SYSVSEM # System V-like semaphores
option SYSVSHM # System V-like memory sharing
#option UVM_SWAP_ENCRYPT# support encryption of pages going to swap
#option COMPAT_23 # Kernel compatibility with OpenBSD 2.3,
option COMPAT_25 # 2.5,
option COMPAT_43 # and 4.3BSD
#option TCP_COMPAT_42 # TCP bug compatibility with 4.2BSD
option LKM # loadable kernel modules
option FFS # UFS
option FFS_SOFTUPDATES # Soft updates
option QUOTA # UFS quotas
#option EXT2FS # Second Extended Filesystem
option MFS # memory file system
#option XFS # xfs filesystem
option TCP_SACK # Selective Acknowledgements for TCP
option TCP_ECN # Explicit Congestion Notification for TCP
#option TCP_FACK # Forward Acknowledgements for TCP
#option TCP_SIGNATURE # TCP MD5 Signatures, for BGP routing sessions
#option NFSCLIENT # Network File System client
#option NFSSERVER # Network File System server
#option CD9660 # ISO 9660 + Rock Ridge file system
#option MSDOSFS # MS-DOS file system
option FDESC # /dev/fd
option FIFO # FIFOs; RECOMMENDED
option KERNFS # /kern
option PORTAL # dynamically created filesystem objects
option PROCFS # /proc
# layer filesystems. not yet functional
#option NULLFS # loopback file system
#option UMAPFS # NULLFS + uid and gid remapping
#option UNION # union file system
#option GATEWAY # packet forwarding
option INET # IP + ICMP + TCP + UDP
option ALTQ # ALTQ base
#option INET6 # IPv6 (needs INET)
#option PULLDOWN_TEST # use m_pulldown for IPv6 packet parsing
#option IPSEC # IPsec
#option KEY # PF_KEY (implied by IPSEC)
#option NS # XNS
#option NSIP # XNS tunneling over IP
#option IPX # IPX+SPX
#option IPXIP # IPX tunneling over IP
#option ISO,TPIP # OSI
#option EON # OSI tunneling over IP
#option NETATALK # AppleTalk
#option CCITT,LLC,HDLC # X.25
#option PPP_BSDCOMP # PPP BSD compression
#option PPP_DEFLATE
#option MROUTING # Multicast router
pseudo-device pf # packet filter
pseudo-device pflog # pf log if
pseudo-device pfsync # pf sync if
pseudo-device loop 2 # network loopback
pseudo-device bpfilter 8 # packet filter
#pseudo-device sl 2 # CSLIP
#pseudo-device ppp 2 # PPP
#pseudo-device sppp 1 # Sync PPP/HDLC
#pseudo-device tun 2 # network tunneling over tty
#pseudo-device enc 1 # option IPSEC needs the encapsulation interface
#pseudo-device bridge 2 # network bridging support
#pseudo-device vlan 2 # IEEE 802.1Q VLAN
#pseudo-device gre 1 # GRE encapsulation interface
#pseudo-device strip 1 # Starmode Radio IP interface
pseudo-device pty 64 # pseudo-terminals
pseudo-device tb 1 # tablet line discipline
pseudo-device vnd 4 # paging to files
#pseudo-device ccd 4 # concatenated disk devices
pseudo-device ksyms 1 # kernel symbols device
pseudo-device systrace 1 # system call tracing device
# for IPv6
#pseudo-device gif 4 # IPv[46] over IPv[46] tunnel (RFC1933)
#pseudo-device faith 1 # IPv[46] tcp relay translation i/f
option BOOT_CONFIG # add support for boot -c
这个是我的配置文件, 如果你对options有不了解的地方可以man options查看。我在配置pseduo-device时曾得到chinaunix.net的Zinx的帮助。这里表示感谢!
在上面这个文件里有时基本同FreeBSD差不多, 也可参考FreeBSD的内核配置文件。
这两个文件改好后, 我们进行下面操作:
[color="blue"]
# cd /usr/src/sys/arch/i386/conf
# config GENERIC
# cd ../compile/GENERIC
# make clean
# make
# cp /bsd /bsd.old (将以前的内核存为旧的, 在失败时使用)
# cp bsd /bsd
# reboot
现在我们就完成了。
在这里有个boot-time configuration, 是你可在启动时配置内核, 具体可参考官方FAQ:
http://www.openbsd.org/faq/faq5.html
说的比较简单, 如果你有问题可去www.linuxeden.com的FreeBSD版, 我同你一起讨论。
下一篇使用cvs ports, cvs src, 希望能一步一步走进OpenBSD世界! |
|