FreeBSD進入9.0版之後,雖然仍保留黑底白字的傳統畫面,但安裝程序上簡化很多,系統也會自行做最優判斷,像過去那樣要自己畫partition、label的情況,現在可以完全偷懶交給系統自己去做就可以了。
9.0的安裝程序與樣貌跟9.1一樣,所以以下只用9.0說明。
硬體型號:HP Compaq W4000
CPU: P4 1.8G
Dram: 2G
HD: SCSI 18G 7200轉
NIC: Intel Pro 100(fxp0)
外加NIC二片:Intel(fxp1), 3Com 3C905(xl0) //因為這台要當firewall和nat,所以至少二張網卡。
對外ip:1.2.3.4
對內ip:192.168.0.1
安裝程序:
1. 準備FreeBSD 9.0 release版CD一張。只要第一張就可以開機和安裝了,不用下載DVD版本,另外做USB開機失敗。
下載網址:ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/9.0/Freebsd-9.0-RELEASE-i386-disc1.iso
2. 由系統自行分割HD,因為這台只需要裝一種OS,所以系統自動把整顆硬碟劃成一顆:
9.0版的樣子:
> df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/da0p2 16503260 5275676 9907324 35% /
devfs 1 1 0 100% /dev
devfs 1 1 0 100% /var/named/dev
7.3版的樣子:
$ df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s1a 9123918 628234 7765772 7% /
devfs 1 1 0 100% /dev
/dev/ad0s1e 11776814 1546118 9288552 14% /usr
/dev/ad0s1d 9914318 357748 8763426 4% /var
devfs 1 1 0 100% /var/named/dev
3. 安裝完成後,請先設定/etc/rc.conf和dns解析,把網路設定成功(如果沒有在安裝程序中設定完的話)。設定程序一定要用root權限執行。
>vi /etc/rc.conf
# ----- General Settings ----- # //系統安裝時自加的設定
gateway_enable="YES"
inetd_enable="YES"
linux_enable="YES"
#moused_enable="YES" //只做Server,不上x-window,可以不用啟用mouse
sshd_enable="YES" //要開這個才能使用ssh連進來,telnet是不開的。
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
# ------ NIC Settings ----- # //網卡的IP設定
ifconfig_fxp0="inet 1.2.3.4 netmask 255.255.255.248"
ifconfig_fxp0_alias0="inet 1.2.3.5 netmask 255.255.255.248"
ifconfig_xl0="inet 192.168.0.1 netmask 255.255.255.0"
defaultrouter="1.2.3.1"
hostname="ns2.test.com"
# ------ NATD Settings ----- # //轉址用,但這個功能啟用前要先重編kernel。
natd_enable="Yes"
natd_interface="fxp0"
natd_flags="-f /etc/natd.conf"
# -- Firewall Settings -- # //防火牆設定,要跟NAT配合使用,並且啟用前要重編Kernel
firewall_enable="Yes"
firewall_type="simple"
#firewall_type="open" //以防萬一用的。
firewall_quiet="No"
firewall_logging="Yes"
# ----- 以下都是有用到才需要加入的設定,沒用到就不用寫。------ #
# ------ VPN Settings ----- # //VPN Server。
mpd_flags="-b"
mpd_enable="Yes"
# ----- DHCP Settings ----- # //DHCP用。
dhcpd_enable="Yes"
dhcpd_flags="-q"
dhcpd_conf="/usr/local/etc/dhcpd.conf"
dhcpd_ifaces="fxp0"
dhcpd_withumask="022"
# -- DNS Settings -- # //Domain Name Server的設定。
named_enable="Yes"
named_flags="-c /etc/namedb/named.conf"
#named_program="/usr/local/sbin/named"
# -- Time Settings -- # //系統自動校時。有另一種作法,請參閱:[工作記錄] ntp設定。
ntpdate_enable="YES" # Run ntpdate to sync time on boot (or NO).
ntpdate_program="ntpdate" # path to ntpdate, if you want a different one.
ntpdate_flags="clock.stdtime.gov.tw" # Flags to ntpdate (if enabled).
# ----- Apache Settings ----- # //Apache(www server)啟用。
apache22_enable="Yes"
# ------ MySQL Settings ----- # //MySQL啟用設定。
mysql_enable="Yes"
mysql_dbdir="home/mysql"
# -- MailScanner Settings -- # //Mail Scanner的設定。
sendmail_enable="No"
spamd_enable="Yes"
clamav_clamd_enable="Yes"
clamav_freshclam_enable="YES"
clamav_milter_enable="Yes"
mailscanner_enable="Yes"
mailscanner_configfile="/usr/local/etc/MailScanner/MailScanner.conf"
mailscanner_pidfile="/var/run/MailScanner.pid"
存檔退出。
4. 設定DNS解析:
> vi /etc/resolv.conf
#nameserver 127.0.0.1 //如果本機無dns功能,本行不用寫或是#
nameserver 168.95.192.1
nameserver 168.95.1.1
domain test.com
存檔退出。
5. 重開機啟動基本功能,以便進行後面的動作。
> reboot
6. 重開機後確定網卡的設定與網路是否正常:
>ifconfig -a //檢查有哪些網卡和是否接上線。列出來的樣子如下:
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 //對內的網卡,使用虛擬IP
options=82009<RXCSUM,VLAN_MTU,WOL_MAGIC,LINKSTATE>
ether 00:01:02:38:b9:b9
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
inet6 fe80::201:2ff:fe38:b9b9%xl0 prefixlen 64 scopeid 0x1
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 //對外的網卡,使用正式的IP
options=2009<RXCSUM,VLAN_MTU,WOL_MAGIC>
ether 00:08:02:35:64:83
inet 1.2.3.4 netmask 0xfffffff8 broadcast 1.2.3.255
inet6 fe80::208:2ff:fe35:6483%fxp0 prefixlen 64 scopeid 0x2
inet 1.2.3.5 netmask 0xfffffff8 broadcast 1.2.3.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
fxp1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 //沒用到的的網卡顯示是這樣。
options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
ether 00:02:b3:98:d7:16
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (none)
status: no carrier
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
ipfw0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 65536
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x8
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
可以ping一下自己、254和外部ip,或是nslookup一下,確定網路運作正常,以便進行ports更新。