顯示具有 FreeBSD 標籤的文章。 顯示所有文章
顯示具有 FreeBSD 標籤的文章。 顯示所有文章

2016年7月16日 星期六

FreeBSD Portsnap 升級(在FreeBSD上架設IMAP/POP3)

想到以前UNIX系統剛開始的時候,是Redhat及FreeBSD,所以必須二選一的學習,因為FreeBSD的小魔鬼比紅色帽子的企鵝可愛,就選擇了FreeBSD。

但是這2年大多使用CentOS的系統,FreeBSD已經很少用,有些指令已經變得很陌生了。

剛好最近因為一些問題,必須使用FreeBSD系統,但是發覺以前用的Port指令不能用,而且CSV的程式不能更新,上網查了一下才知道FreeBSD在2013年之後就改用Portsnap的方式,原先的CVSUP已經停止使用了,所以又要重新學習。


Ports Collection 更新工具

#cd /var/db/portsnap/
# portsnap fetch 
 (第一次使用,必須先執行這個指令)

# portsnap extract
(第一次使用,必須先執行這個指令)

# portsnap fetch update
(更新全部的Ports程式)

# portsnap update
(日後要更新Ports的程式的指令)
=================================
在FreeBSD上架設IMAP/POP3 Server

#cd /usr/ports/mail/dovcot/ && make install clean
出現下列的問題

To switch to pkg:
    1) Install ports-mgmt/pkg
       cd ports-mgmt/pkg && make UPGRADEPKG=1 install clean
    2) Convert your package database by running pkg2ng


#cd /usr/ports/ports-mgmt/pkg
#make UPGRADEPKG=1 install clean
完成後,再執行dovcot的程式安裝

#cd /usr/ports/mail/dovcot/ && make install clean
#cd /usr/ports/mail/dovecot-sieve && make install clean
#cd /usr/ports/mail/dovecot-managesieve && make install clean

修改/etc/rc.conf加上:
dovecot_enable="YES"

# /usr/local/etc/rc.d/dovecot start

2014年8月12日 星期二

FreeBSD VMware Tools 原廠手冊安裝版


For FreeBSD virtual machines, you manually install or upgrade VMware Tools by using the command line.

Install the latest version of VMware Tools to enhance the performance of the virtual machine's guest operating system and improve virtual machine management. When you power on a virtual machine, if a new version of VMware Tools is available, you see a notification in the status bar of the guest operating system.

■
Power on the virtual machine.
■
Verify that the guest operating system is running.
■
Because the VMware Tools installer is written in Perl, verify that Perl is installed in the guest operating system.
■
For vSphere virtual machines, to determine whether you have the latest version of VMware Tools, in the vSphere Client inventory, select the virtual machine and click the Summary tab.

1

Select the menu command to mount the VMware Tools virtual disc on the guest operating system.

VMware Product
Menu Command
vSphere Client
Inventory > Virtual Machine > Guest > Install/Upgrade VMware Tools
vSphere Web Client
All Actions icon > Configuration > Install/Upgrade VMware Tools
Fusion
Virtual Machine > Install (or Upgrade) VMware Tools
Workstation
VM > Manage > Install (or Upgrade) VMware Tools
Player
Virtual Machine > Install (or Upgrade) VMware Tools
2

In the virtual machine, log in to the guest operating system as root and open a terminal window.
3

If the distribution does not automatically mount CD-ROMs, mount the VMware Tools virtual CD-ROM image.
For example, type mount /cdrom.
4

Change to a working directory (for example, /tmp).
cd /tmp
5

Untar the VMware Tools tar file.
tar zxpf /cdrom/vmware-freebsd-tools.tar.gz
6

If the distribution does not use automounting, unmount the VMware Tools virtual CD-ROM image.
umount /cdrom
7

Run the installer and configure VMware Tools.
cd vmware-tools-distrib
./vmware-install.pl
Usually, the vmware-config-tools.pl configuration file runs after the installer file finishes running.
8

Respond to the prompts by pressing Enter to accept the default values, if appropriate for your configuration.
9

Follow the instructions at the end of the script.
Depending on the features you use, these instructions can include restarting the X session, restarting networking, logging in again, and starting the VMware User process. You can alternatively reboot the guest operating system to accomplish all these tasks.

If you are using vCenter Server, the VMware Tools label on the Summary tab changes to OK.

資料來源 vSphere 

FreeBSD ZFS修正

由於伺服器的記憶體大於8GB,所以系統會一直出現下面的訊息
ZFS NOTICE: Prefetch is disabled by default if less than 4GB of RAM is present;gdns2 kernel: to enable, add "vfs.zfs.prefetch_disable=0" to /boot/loader.conf.

要求在/boot/loader.conf檔案裡新增一行
vfs.zfs.prefetch_disable=0
重新開機就可以了。

2014年7月8日 星期二

FreeBSD Pkg 指令

可以用從本機上或者透過網路來安裝任一 FreeBSD package。

若手邊沒有 package 來源(像是 FreeBSD 光碟)的話, 那麼建議使用 pkg_add(1) 時,
加上【 -r 】 選項來更輕鬆安裝 package。如此一來,就會自動判斷正確的 package 格式、 以及所搭配的作業系統 release 版本, 然後會自己從 FTP 站抓回、安裝相對應的 package。
# pkg_add -r lsof

上面這例子會自動下載正確的 package 並安裝。 若想改換用其他 FreeBSD Packages Mirror 站,那麼就要設定PACKAGESITE 環境變數, 如此一來才會取代預設設定。 pkg_add(1) 會用 fetch(3) 指令來下載檔案,而 fetch(3) 本身則會使用相關環境變數的設定, 像是: FTP_PASSIVE_MODE、FTP_PROXY 以及 FTP_PASSWORD。 如果你網路環境處於 firewall 後面,或者需要用 FTP/HTTP proxy 的話,那麼就需要設定。 設定細節請參閱 fetch(3)。 請注意:上面所說的例子是寫 lsof 而非 lsof-4.56.4。 當使用遠端抓取功能時,該 package 版號就不必加上去了。 pkg_add(1) 會自動下載該軟體的最新版回來安裝。

perl安裝:pkg_add -r perl
compat6x-amd64安裝:pkg_add -r compat6x-amd64
wget安裝:pkg_add -r wget

舊的 pkg_* 工具會在 2014/09/01 正式停止支援。

2014年4月11日 星期五

FreeBSD DNS 設定及指令

記得在86年的時候剛退伍,也第一次到電腦公司上班,那時候公司內部就2個部門「硬體維修部」跟「系統部」我在硬體部門的工作就是什麼都做,因為只要跟電腦有關的硬體通通都要修連帶還要搬,還好那時體力不錯,不然一天搬三間教室還要拆箱跟裝機會死人哦,但是系_部的人就什麼也不要搬跟裝,所以就覺得系統部真的不錯,所以就努力學系統,從此就完蛋了,UNIX系統之中我最喜歡FreeBSD。

查看Bind版本指令
named -V
BIND 9.8.4-P2 built with....後面省略

BIND設定檔案是在 /etc/namedb

#----------------------------------------
options {
// All file and path names are relative to the chroot directory,
// if any, and should be fully qualified.
directory "/etc/namedb/working";
pid-file "/var/run/named/pid";
dump-file "/var/dump/named_dump.db";
statistics-file "/var/stats/named.stats";
minimal-responses yes;
//回應查詢時,僅回應ANSWER部分
allow-query {any;};  
//幫查詢不是自己的domain
listen-on       { 112.105.100.41; };
//填入你主機的IP
forwarders {
8.8.8.8;
};
zone "example.com" { type master; file "/etc/namedb/master/example.db";     };
//查詢example.com的正解時,會依據這邊的檔案回應
#---------------------------------------

#cd /etc/namedb/master
#vi example.db
#--------------------------------------
$TTL 60
@          IN SOA example.com. root.example.com. (
                                   2013112713 ; Serial
                                   172800 ; Refresh
                                   60 ; Retry
                                   360 ; Expire
                                   60 ) ; Minimum
             IN   NS                    example.com.
             IN   A                      112.105.100.41
www      IN   A                      173.194.72.94
www1    IN   CNAME              www.google.com.tw.
ftp         IN   CNAME              www
mail       IN   A                      123.44.55.227
mail       IN   MX 10               www.twbsd.org
             IN   MX  20              mail.def.net
=======================================
BIND啟動方式
 ee /etc/rc.conf
#-------------------------
named_enable="YES"
#-------------------------
/etc/rc.d/named start
/usr/sbin/named –c /etc/namedb/namedb.conf
就可以用了

2014年3月16日 星期日

FreeBSD Fsck修復

首先先開機進入 Single Mode ,開機選單按 4 即可進入 Single Mode
接下來進去後先按一下 Enter ,以我的系統為例,輸入下列指令
# mount -a
# df
/dev/da0s1a   10154158      70668   9271158     1%    /
devfs                1          1         0   100%    /dev
/dev/da1s1d 2055518950 1106617646 784459788    59%    /home
/dev/da0s1e   10154158    1037240   8304586    11%    /tmp
/dev/da0s1f   80729226   30448924  43821964    41%    /usr
/dev/da0s1d   81245672     800846  73945174     1%    /var
先確認有哪些目錄後,就一個一個 umont 做 fsck 修復的動作,修復完再 mount 回來
# umount /home
# fsck -y /home
# mount /home
但是一開始連 / 都 mount 不起來的話,記得要先 fsck 根目錄才行唷!

2013年9月3日 星期二

FreeBSD 安裝 SmbFTPD

【方式一】
# cd /usr/ports/ftp/smbftpd
# make install clean

【方式二】
# cd /usr/ports/ftp/smbftpd
# make fetch
# cd /tmp
# cp /usr/ports/distfiles/smbftpd-0.96.tar.gz .
# tar zxvf smbftpd-0.96.tar.gz
# cd smbftpd-0.96
# ./configure
# make
# make certs ( 如果需要 SSL 加密的話,可以在此製作憑證)
# make install

接下來切換到 /usr/local/etc/smbftpd/ 裡面,來設定一下 smbftpd.conf 就可以讓它 work 了,詳細的設定可請參考 twbsd.org,再也沒有比這還詳細的說明 XD


Server 運作的模式選用 standalone 方式,只要編輯 /etc/rc.conf,並加入下列二行,以在開機時啟動 SmbFTPD

smbftpd_enable="Yes"
smbftpd_flags="-D"

若要啟動|關閉的話,就用這行指令

# /usr/local/etc/rc.d/smbftpd.sh start or stop

2013年8月27日 星期二

FreeBSD Samba 無法啟動問題

有一天早上我的客戶的網管小姐突然打電話給我講,怎麼辦我們公司的Samba Server無法使用,我心裡應該是小問題吧,結果我搞了一天挫屎

在FreeBSD使用測試指令檢查Samba Config 是否有問題

# testparm
發現到問題的一行
Load smb config files from /usr/local/etc/smb.conf
max_open_files: sysctl_max (11095) below minimum Windows limit (16384)
rlimit_max: rlimit_max (11095) below minimum Windows limit (16384)
ERROR: pid directory /var/run/samba does not exist
Processing section "[printers]"
WARNING: You have some share names that are longer than 12 characters.
These may not be accessible to some older clients.
(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

上網找了一下都是國外的網站解答找到原因
因為 Sever 中的 /var/run/samba 這個目錄不見了
所以只要下個指令就可以了
mkdir /var/run/samba
在重新啟動一下Samba Server 就可以了。



2013年8月19日 星期一

FreeBSD Root 密碼更改

由於之前的一個客戶發生了一個慘案,就是整個公司的網路原本是外包給某一個不知名公司,結果因為某些溝通上的問題發生一些不愉快的事結果就找上了我,可是在這之前我原本就不知道,只是儘本份解決網路,結果我一直希望他們提供密碼在一直無法拿到的情況下才了解了這個問題,所以我也只好更改了密碼,所以網路是一個公司對外的命脈,所以說「網路不是萬能的,但是沒有網路是萬萬不能」的。

所以說在忘記 FreeBSD Root 密碼時,就可以在開機時等待的那10秒鐘進入 Single user mode 重新設定密碼:

1. 按下Crtl+alt+del 重新開啟 FreeBSD 主機。

2. 在 「Welcome to FreeBSD」的選單中按趕點按下「4」 選擇 「Boot FreeBSD in single user mode」。

3. 然後經過一系列的開機過程後就會看到 「When prompted Enter full pathname of shell or RETURN for /bin/sh:」,在直接按 Enter。

4. 這時便會直接進入 Single user mode,就可以輸入指令重新掛載根目錄 "/" 為可讀寫:

# mount -u /
# mount -a

5. 用 passwd 重新設定 root 密碼:

# passwd root

6. 最後重新啟動即可:

# sync;sync;sync;reboot

2013年8月15日 星期四

FreeBSD_Squid認證

#ee /usr/local/etc/squid/squid.conf

【認證時出現的提示】
auth_param basic realm 【歡迎來 XXX 認證伺服器】

【指定是由 ncsa_auth 認證,帳號密碼檔為 squid-passwd】
auth_param basic program /usr/local/libexec/squid/ncsa_auth /usr/local/etc/squid/squid-passwd

【設定使用 proxy_auth】
acl squid-passwd proxy_auth REQUIRED

【允許通過認證的者用者使用用 Proxy】
http_access allow squid-passwd


【新增一個使用者】
#cd /usr/local/etc/squid
#htpasswd -c squid-passwd kou
New password: your_password <- p="">Re-type new password: your_password <- p="">Adding password for user kou

上面這樣下指令,系統會連續問兩次密碼已確認,如果覺得煩,可以這樣:
#htpasswd -b squid-passwd tchcvs 22223307

FreeBSD VMware Tools 安裝

開啟 vSphere Client >> 開啟 Console >> 選擇【VM \ Guest \ Install/Upgrade VMware Tools】掛載相對應的 ISO 檔給 VM 虛擬主機

 #mkdir /media/cdrom
 #mount -t cd9660 /dev/cd0 /media/cdrom
 #cp /media/cdrom/vmware-freebsd-tools.tar.gz /tmp
 #cd /tmp ; umount /media/cdrom
 #tar zxvf vmware-freebsd-tools.tar.gz
 #cd vmware-tools-distrib/
 #./vmware-install.pl

 參考文件 不自量力

2010年3月28日 星期日

BSD的帳號轉移

BSD的帳號轉移
主機甲上的帳號轉移至主機乙上面,該怎麼做?
先將乙的/etc/master.passwd 及 /etc/group 備份好(以防萬一)
複製甲的/etc/master.passwd 及 /etc/group 檔到乙機器中
在乙電腦中以root 身份執行
#pwd_mkdb -p -d /etc /etc/master.passwd

Bandwidthd 安裝

在FreeBSD底下安裝請直接使用Port,安裝後會在/usr/local建立一個bandwidthd的
目錄,請將bandwidthd.conf-dist複製成bandwidthd.conf並且修改內容,

(1)cd /usr/ports/net-mgmt/bandwidthd/
(2)make install
(3)mv /usr/local/bandwidthd/etc/bandwidthd.conf-dist /usr/local/bandwidthd/etc/bandwidthd.conf
(4)ee /usr/local/bandwidthd/etc/bandwidthd.conf

####################################################
# Bandwidthd.conf
#
# Commented out options are here to provide
# documentation and represent defaults

# Subnets to collect statistics on
#subnet 10.0.0.0 255.0.0.0
subnet 163.19.105.0 255.255.255.0 #你的區網

# Device to listen on
#dev "eth0"
dev "xl0" #你的網路介面卡
####################################################

cd /usr/local/etc/rc.d
mv bandwidthd.sh-sample bandwidthd.sh
然後執行/usr/local/etc/rc.d/bandwidthd.sh start

cd /var/www/html
ln -s /usr/local/bandwidthd/htdocs bandwidthd

再把 /usr/local/bandwidthd/htdocs link網頁伺服器能讀取到的地方