歡迎您光臨本站 註冊首頁

關於伺服器的配置,急急急

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

關於伺服器的配置,急急急

我想做個安裝LIUNUX的伺服器.然後其他機器就可以通過網路安裝了.謝謝.
《解決方案》

kickstart,看官方手冊,裡面有配置指南,比如redhat就有的,網上也很多
《解決方案》

http://linux.chinaunix.net/bbs/viewthread.php?tid=591787&extra=
《解決方案》




區域網網路安裝Linux



1。本帖操作環境是Redhat 9.0,VSFTPD的版本是Redhat 9.0所帶的vsftpd-1.1.3-8.i386.rpm,在安裝盤的第三張中

2。VSFTPD實現的最基本的目的:用系統中存在的真實用戶能登入FTP,能用匿名訪問。

3。伺服器的IP和和DNS設定

第一塊網卡
IP:192.168.0.1
子掩碼:255.255.255.0
網關不設置:
第二塊網卡:
IP:192.168.0.2
子掩碼:255.255.255.0
網關不設置

因為我的操作環境是一個小型的區域網,所以其它的機器的IP都是在192.168.0這個網段上。ADSL是接在伺服器的第一個網卡上。伺服器的第二個網卡是接集線器,其它的客戶機都是接在集線器上。為了能讓ADSL訪問internet,因為自己手動設置了IP,所以DNS也要自己來設置,DNS如下:

202.96.134.133
202.96.168.68

設置工具是:

# redhat-config-network

一。用VSFTP來架設FTP伺服器,VSFTP伺服器是目前最好的FTP伺服器軟體,優點是體積小,可定製強,效率高

1。查看是否安裝了vsftpd軟體
# rpm -qa | grep vsftpd
如果沒有任何顯示,說明沒有把vsftpd安裝上,如果出現的是下面的這樣的提示,就證明已經安裝上了。

# rpm -qa | grep vsftpd
vsftpd-1.1.3-8

我以Redhat 9.0,以其自帶的vsftpd包vsftpd-1.1.3-8版本來為本帖約定。

# rpm -ivh vsftpd*.rpm

2。打開VSFTP伺服器。

# ntsysv

把vsftpd伺服器打開,也就是在運行 ntsysv命令后,把vsftpd服務選中。


vsftpd

3。運行/etc/init.d/vsftpd start

# /etc/init.d/vsftpd start
為 vsftpd 啟動 vsftpd: [ 確定 ]
#

4。配製VSFTP,FVSFTP的運行有兩種模式,一種是stardard "initd模式,另外一種是xinetd模式,上面我們所說的就是stardard initd運行模式。兩種模式運行機制不是相同的,stardard initd模式,適合專業FTP,且FTP總是一直有人訪問,佔用資源也是比較大,如果您的FTP總是有人訪問和登入。就要用這種模式。如果您的FTP訪問人數比較小,建議您用xinetd模式。xinetd模式,是當用戶請求時,vsftpd才會啟動。

不同的環境,當然得用不同的啟動模式。

如果想了解更多的,請在本帖後面跟帖,我會慢慢補充xinetd模式,以及虛擬用戶如何設置方面的問題。


1]我們主要把vsftp的配製文件改一下就行了。配製文件在/etc/vsftpd/vsftpd.conf,用您喜歡的編輯器打開。請參考下面的配製文件。


# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are very paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
#
# Allow anonymous FTP?
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES

pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES

2]更改完配製文件后,我們可以用下面的命令來重啟VSFTPD伺服器

# /etc/init.d/vsftpd restart
關閉 vsftpd: [ 確定 ]
為 vsftpd 啟動 vsftpd: [ 確定 ]
#

3]以匿名方式來訪問測試,在text模式下:

注意:在text模式下,要用用戶名ftp,密碼ftp來訪問,這才是在text中匿名訪問FTP。看如下的操作:

# ftp 192.168.0.1
Connected to 192.168.0.1.
220 (vsFTPd 1.1.3)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.0.1:root): ftp 這裡寫上ftp
331 Please specify the password.
Password:[這裡添寫ftp的密碼],匿名登入密碼也是ftp
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,0,1,137,151)
150 Here comes the directory listing.
drwxr-xr-x 6 0 0 4096 May 25 13:54 RedHat90
drwxr-xr-x 2 0 0 4096 Feb 28 19:21 pub
226 Directory send OK.
ftp>
那匿名用戶所訪問的是哪個目錄?是/var/ftp這個目錄

出現問題的解決:有時出錯,是因為沒有ftp和nobody用戶,所以要在系統中添加這兩個用戶,一般的情況下,這兩個用戶在系統中是存在的。看下面的操作。
# adduser ftp
adduser: user ftp exists
# adduser nobody
adduser: user nobody exists

從上面的操作中可知ftp和nobody用戶是存在的,所以沒有必要添加ftp和nobody用戶了。如果不存在,一定要添加這兩個用戶,否則會出現匿名用戶不能訪問的情況。

4]如果要以系統中存在的普通用戶登入FTP,也沒有什麼可以設置的,添加一個用戶就行。比如我要添加beinan這個用戶,就要用下面的辦法

# adduser beinan
# passwd beinan
Changing password for user beinan.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.
#

這樣的話,就在/home目錄中出現一個beinan的用戶目錄:如下:

# ls /home/
beinan


如果我們想讓beinan這個用戶作為虛擬用戶,也就是說,beinan這個用戶是不能登入系統的,只能是登入FTP。 那這樣的用戶應該如何添加呢??

# adduser -g ftp -s /sbin/nologin beinan
# passwd beinan
Changing password for user beinan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
#

註:這僅僅是VSFTP添加虛擬用戶的一個方法,還有更好的辦法需要我們去學習!另外的辦法也在測試之中。嚴格上來說,這種辦法不能算虛擬用戶。還有另外的一個辦法,就是通過pam認證,用db_load來添加用戶,目前我也弄成功了,不過相對要複雜一點。正在測試之中。


如果我們想把用戶目錄定位到別的目錄應該怎麼辦呢??這個也比較簡單,看一下useradd就比較明白了。比如我想添加beinan這個用戶,並把目錄放在/opt目錄中:如下操作:

# adduser -d /opt/beinan beinan
# passwd beinan
Changing password for user beinan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

如果是添加虛擬用戶,也就是不讓用戶登入系統,只能登入FTP的用戶。如果我們想把beinan這個用戶目錄定位在/opt/beinan這個目錄中,根據上面的方法。我們應該如下操作
# adduser -d /opt/beinan -g ftp -s /sbin/nologin beinan
# passwd beinan
Changing password for user beinan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
#

看一下是不是已經成功添加到了beinan這個用戶,並把beinan的家目錄放在了/opt目錄中呢??

# ls /opt/
beinan

證明已經成功。

我們可以在text模式下以beinan用戶登入,然後來訪問ftp。

# ftp 192.168.0.1
Connected to 192.168.0.1.
220 (vsFTPd 1.1.3)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.0.1:root): beinan
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

是不是成功了???

我們也可以用gftp來訪問beinan用戶,並上傳相應的東西,所傳上的東西就放在beinan用戶所在的家目錄中,普通用戶的家目錄在哪裡,寫您所用的添加用戶的方法有關。我在前面已經說了兩種辦法,一種是默認的添加方法,就是放在/home目錄中。

在本例中,我是採用默認的添加用戶的方法。也就是不特別指定用戶用戶,這樣的話,用戶目錄就在/home目錄中。比如用beinan登入FTP時,訪問的就是/home/beinan這個目錄。讓傳的東西也在這個目錄中。

那匿名用戶所訪問的是哪個目錄呢???

應該是:/var/ftp這個目錄


5]訪問ftp的幾種方法

第一種方法就是text訪問,也就是用ftp命令來訪問。這個前面已經說過了。

第二種方法是以客戶端FTP軟體來訪問,在linux中有gftp。在本例中,我的FTP地址是通過區域網訪問的。地址欄中,添上192.168.0.1,埠是21,用戶名和密碼的添寫,如果您是用匿名登入,請不要添寫用戶名和密碼。如果用普通用戶登入,這個是必須要用用戶名和密碼的。

第三種辦法是和瀏覽器訪問:如果匿名登入,就直接用下面的方法:
ftp://192.168.0.1
如果是用戶登入方式,應該是
ftp://beinan@192.168.0.1

如果想讓在互聯網上的用戶能訪問到,如果您是用ADSL來訪問互聯網,要查找到您的動態IP,用下面的辦法
# ifconfig ppp0
ppp0 Link encapoint-to-Point Protocol
inet addr:218.61.7.23 P-t-P:218.61.7.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:24245 errors:0 dropped:0 overruns:0 frame:0
TX packets:20411 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:23103297 (22.0 Mb) TX bytes:3588337 (3.4 Mb)

從上面的可以知道,能讓在internet訪問的地址是:218.61.7.23


二。如何讓區域網通過這個FTP安裝Linux呢??以Redhat 9.0為例:

1。我們要在/var/ftp中,為每個發行版建一個目錄,然後把每個發行版的每個版本再建一個目錄。把每個版本的ISO都解壓到相應的目錄里。舉個例子:

比如我想讓其它的客戶機,通過我的伺服器來安裝Redhat9.0,我就要在/var/ftp目錄中建一個RedHat90的目錄,然後把RedHat 9.0的三個ISO都解到這個目錄中。

這樣伺服器的設置就完成了。

2。客戶機方面如何引導及設置???我們可以做一個系統的引志盤,但有的發行版也沒有必要。這也要以各個發行版的情況而定。比如Redhat 9.0的安裝,如果您的客戶機上有windows,就直接通過區域網的FTP,dosutils images isolinux三個目錄放到一個在fat32分區中建的目錄中,比如說在客戶機上建一個Redhat9的目錄,然後把三個文件拷到客戶機中的fat32分區中的Redhat9的目錄中。

3.客戶機安裝及操作:

以DOS盤引導,不要載入CDROM,直接進入客戶機中fat32分區Redhat9\dosutils目錄,執行下面的命令。

autoboot

這樣就開始了安裝:

4.出現的畫面中,我們要選ftp安裝。在設置網路環境時,我們要設置好IP和網關之類的。

以我的區域網為例:

客戶機的IP設置成192.168.0.5,掩碼也是2552555.255.0,網關設置成192.168.0.1。name 服務可以不設置。以匿名方式訪問FTP。

下一步會出現讓我們添寫FTP,及安裝源的地址,還是以我的區域網為例:

地址:192.168.0.1
路徑:因為我是把三個ISO放在了/var/ftp/RedHat90的目錄下,我應該寫如下的

/RedHat90

這樣就OK了,一切和其它的安裝方式都是一樣的了。


因為每個發行版不太一樣,所以通過網路安裝,有的要做引導盤,如何做引導盤,我想大家早就知道了。如果不知道這方面的,請用搜索來找這方面的帖子。


vsFTP伺服器,相關的一系統補充

補充一:如何把用戶限制在家目錄中呢?

我們要自己建一個文件,在/etc目錄中
#touch /etc/vsftpd.chroot_list
以beinan這個用戶為例

在vsftpd.chroot_list這個文件中,把beinan添上去就行。

然後改/etc/vsftpd/vsftpd.conf文件,找如下的兩行

#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd.chroot_list

把前面的#號去掉,也就是這樣的
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list

如果沒有這樣的兩行,就可以自己添加上去也是一樣的。

設置好后,重新vsFTPD伺服器。

# /etc/init.d/vsftpd restart
關閉 vsftpd: [ 確定 ]
為 vsftpd 啟動 vsftpd: [ 確定 ]
#

補充二:打開vsFTP伺服器的日誌功能:

把下面xferlog_file前面的#號對掉,也就是把vsftp的log功能打開,這樣我們就能在/var/log目錄下查看vsftpd.log。這是vsFTP的日誌功能,這對於我們來說是極為重要的。
#xferlog_file=/var/log/vsftpd.log

補充三:如何讓綁定IP到vsFTP?也就是說,如何讓用戶只能通過某個IP來訪問FTP。其實這個功能很有意思。如果綁定的是內網的IP,外部是沒有辦法訪問的。如果綁定的是對外服務的IP,內網也只能通過對外服務的IP來訪問FTP

在/etc/vsftpd/vsftpd.conf中加一行,以我的區域網為例,請看第一帖中的操作環境,這樣外網就不能訪問我的FTP了,內網也可能通過192.168.0.2來訪問FTP
listen_address=192.168.0.2

加完后,要重啟vsFTP伺服器

# /etc/init.d/vsftpd restart
關閉 vsftpd: [ 確定 ]
為 vsftpd 啟動 vsftpd: [ 確定 ]
#

補充四:如何讓vsFTP伺服器限制鏈接數,以及每個IP最大的鏈接數??

答:應該改vsFTP伺服器的配製文件vsftpd.conf,加入下面的兩行:

max_clients=數字
max_per_ip=數字

舉例:我想讓我的vsFTP最大支持鏈接數為100個,每個IP,最多能支持5個鏈接,所以我應該在vsftpd.conf中加上如下的兩行:
max_clients=100
max_per_ip=5

改好了配製文件,不要忘記啟動vsftp伺服器。


補充五:如何限制下載的速度?

anon_max_rate=數字 註:這是匿名的下載速度
local_max_rate=數字 註:這是vsFTP伺服器上普通用戶的下載速度

註:這個數字的單位是位元組,所以我們要計算一下。比如我想讓匿名用戶和vsFTP上的用戶都以80KB下載,所以這個數字應該是1024x80=81920
所以我們要在vsftpd.conf中加入下面的兩行
anon_max_rate=81920
local_max_rate=81920

不要忘記重啟vsftpd服務

補充六:我的硬碟空間有限,如何把帳號ftp默認的路徑/var/ftp更改到別處?或者是,我的linux所有的目錄都放在/根分區,因為空間緊張,我能否把ftp這個用戶的默認路徑放到別的分區??

可以,應該如下操作!

首先要把ftp這個用戶刪除
#userdel -r ftp
會有錯誤信息,不過不用理,這是正常的。

然後我們再把這個用戶添加上,比如我想為帳號ftp的家目錄設置在/mnt/LinG/ftp,我們就可以如下操作

# adduser -d /mnt/LinG/ftp -g ftp -s /sbin/nologin ftp

僅僅是這樣做還不行,因為這樣還是不能讓匿名用戶找到它的家目錄,所以我們必須改變/mnt/LinG/ftp這個目錄的許可權。

# chmod 755 /mnt/LinG/ftp/

# chown -R root.root /mnt/LinG/ftp/

[火星人 ] 關於伺服器的配置,急急急已經有700次圍觀

http://coctec.com/docs/service/show-post-32534.html