- 論壇徽章:
- 0
|
linux學(xué)習(xí)心得
Liunx內(nèi)部主機(jī)規(guī)劃
一、目的和用途
a, 作為代理服務(wù)器使用。(使用squid代理,軟體為:squid-2.5.STABLE11.tar.gz)
b, 作為RD的內(nèi)部E-mail服務(wù)器使用。(使用軟體為posfix)
c, 作為文件傳輸使用。(使用軟件為proftpd-1.2.10.tar.gz)
二、安全全考慮。
眾所周知,一臺電腦的安全性至關(guān)重要。對于本服務(wù)器的安全性方面,對于本機(jī)的服務(wù)器安全性上。擬有以下規(guī)劃:
a. 火墻和ip filter進(jìn)行ftp和telnet和ssh服務(wù);
b. 開發(fā)的端口方面目前先開放21,23,25,110作為其基本的服務(wù);
c. 以及到rpm組件上網(wǎng)更新最新檔;
d.另外,對一些重要的安全性檔案,設(shè)為只讀權(quán)限(如/var/log/secure,/var/log/messages,/var/log/messages等)。
e. 對于UINX的programe先開放的如下:atd, crond,iptables,network,random,sshd,telnetd,syslog,xinetd.
三,安裝及使用。
一節(jié)中,可是重頭戲,下面會從軟件的分區(qū),安裝用各套件的安裝,使用上一步一步的詳細(xì)的步聚,將記錄于些,給自己以下作為改進(jìn)和參考用。
1, 軟件的安裝。本服務(wù)器安裝的為RedHat 9.0, 因服務(wù)器的硬盤也夠大(35G)哦,以及給以后延伸性的使用。還是安裝所有的套件。分區(qū)如下:
/ 分區(qū),容量為:10G (其他的文件目錄分配)
/var 分區(qū) 容量:18G (主要是存改用戶的E-mail)
/home 分區(qū) 容量:3G (當(dāng)然是用來存放用戶文件啰)
/usr 分區(qū) 容量:2G (主要是要來安裝軟體,如proftpd,squid等)
swap 分區(qū) 容量:500M
2, 開放telnet服務(wù):
[root@Randyliu root]# vi /etc/xinetd.d/telnet 之后會出現(xiàn)如下:
service telnet
{
# disable = yes 或 disable=no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
以上,只要把上面紅色項即disable=yes(即表示默認(rèn)為不可用)。把其改為disable=no。 或是前面用注解掉即可,如上紅字。
然后要重新開一下xinetd這個Daemon,運行:
[root@Randyliu root]# /etc/rc.d/init.d/xinetd restart .
在系統(tǒng)初始狀態(tài),因安全性問題,不能以root登錄。須以普通用戶登錄后用su切換。如果只是自己試驗用,則可以做如下修改:
[root@Randyliu root]# vi /etc/pam.d/login (把下面這句話用#注解,后重新啟動xinetd即可)
# auth required pam_securetty.so
3,開放ssh服務(wù)。
其實ssh服務(wù),在初始安裝的時候,即可開啟這個服務(wù)。用windows 的putty這個軟件即可。如果真的沒有的話,可以:
[root@Randyliu root]# /etc/rc.d/init.d/sshd start
之后,要netstat –tlp即可查看對應(yīng)ssh的21端口正在listen …..
因為,ssh這個軟件在網(wǎng)絡(luò)上傳輸密碼時是以加密方式傳輸。所以,默認(rèn)情況下,ssh是允許以root登錄的。
具體關(guān)于ssh的設(shè)置可在 /etc/ssh/sshd_config上更改。里面的設(shè)置,可以增加端口、更改用戶可登錄的IP、是否可以以root這用戶登錄等信息、拒絕某戶和某組登錄等
4、利用/etc/hosts.allow 和 /etc/host.deny來拒絕某些IP地址。
[root@Randyliu root]# vi /etc/hosts.allow
sshd: yourIPaddress : allow
sshd: 192.168.1.0\255.255.255.0 : allow
[root@Randyliu root]# vi /etc/hosts.deny
sshd: ALL : deny
5、代理上網(wǎng)的要求,安裝及設(shè)置:(squid-2.5.STABLE11.tar.gz)
要求:a,只是針對RD的59和60網(wǎng)段的電腦可代理上網(wǎng)。
b,squid的使用版本為squid-2.5.STABLE11.tar.gz
安裝及設(shè)置:
[root@Randyliu root]# mkdir /usr/local/software (建立一個安裝目錄)
[root@Randyliu root]#cd /usr/local/software
[root@Randyliu software]# tar –zvxf /root/squid-2.5.STABLE11.tar.gz
(squid初始文件在root目錄下)
[root@Randyliu software]#cd squid-2.5.STABLE11
[root@Randyliu squid-2.5.STABLE11]# export CFLAGES=’-02 –mcpu=i686’ [root@Randyliu squid-2.5.STABLE11]# ./configure --prefix=/usr/local/squid \
>; --enable-async-io=80 --enable-icmp --enable-kill-parent-hack \
>; --enable-snmp --disable-ident-lookups --enable-cache-digests \
>; --enable-poll --enable-linux-netfilter
[root@Randyliu squid-2.5.STABLE11]# pwd
/usr/local/software/squid-2.5.STABLE11(現(xiàn)在所在的絕對路徑)
[root@Randyliu squid-2.5.STABLE11] make && make install
OK,安裝已完成!
接下來就叫設(shè)定吧,還記得剛才安裝的目錄嗎,在/usr/local/squid下面。
[root@Randyliu root]# cd /usr/local/squid/etc/
[root@Randyliu etc]# vi squid.conf
http_port 3128 (53)
icp_port 3130 (115)
cache_mem 32MB (486)
cache_swap_low 85
cache_swap_high 95
max_object_size 65536kB
maximum_object_size_in_memory 8kB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fdncache_size 1024
cache_dir aufs /usr/local/squid/var/cache 3000 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/cache.log
cache_store_log /usr/local/squid/var/store.log
pid_filename /usr/local/squid/var/logs/squid.pid
acl rd1 src 192.168.59.0/255.255.255.0
acl rd2 src 192.168.60.0/255.255.255.0
http_access deny all
http_access allow rd1
http_access allow rd2
cache_mgr webmaster
cache_effective_user nobody
[root@Randyliu etc]# /usr/local/squid/sbin/squid -z
Creating Swap Directories
[root@Randyliu etc]# su root -c "/usr/local/squid/bin/RunCache &"
Running: squid -sY >;>; /usr/local/squid1/var/squid.out 2>;&1(本來想以nobody這個用戶去啟動的,不過系統(tǒng)提示。此用戶不適用,隨便找一個用戶又運行不了,所以就以root了。不知大家還有其他的說法,例他不以root身份來啟動便是了。)
Ok,這下,我們就可以到客戶端去測試一下了(IE里面去測試一下吧)。哇塞!太帥了。成功。!
另外,在運行過程中如何有去改動squid.conf這個檔案的話。只要運行以下即可讀取squid.conf的設(shè)定:
[root@Randyliu etc]# /usr/local/squid1/sbin/squid -k reconfigure
以上,關(guān)于squid就OK了,總之是覺得太帥了~~至于分析使用情況的分析,就只能等到下一步去做了.
D.維護(hù),
下面兩件事是必須注意的。
1. 若 squid 內(nèi)設(shè)定的使用空間滿了,則 squid 將不會運作!
2. 若 squid 的紀(jì)錄文件太大了,則工作效率會變慢!
對于記錄檔即(cache檔),即/usr/local/squid/cache,我們每隔一段時間有整理一下,即可。至于何時整理,等試運行后定。
9、ftp的要求,安裝及設(shè)置:
A. 要求。
1. 作為內(nèi)部ftp文件傳輸用。開一個用戶要求為不能使用ssh和telnet等服務(wù)。
2. 使用的軟體為:proftpd-1.2.10.tar.gz
B. 安裝
[root@Randyliu root]# mkdir /usr/local/software (建立一個安裝目錄)
[root@Randyliu root]#cd /usr/local/software
[root@Randyliu software]# tar –zvxf /root/proftpd-1.2.10.tar.gz
[root@Randyliu software]# cd proftpd-1.2.10
[root@Randyliu proftpd-1.2.10]#./configure --prefix=/usr/local/proftpd \
--enable-shadow –enable-autoshadow \
--with-modules=mod_ratio:mod_readme:mod_wrap
[root@Randyliu proftpd-1.2.10]# make && make install
設(shè)定以 xinetd 來啟動 proftpd :
事實上,目前大部分的 FTP daemon 多是以 super daemon 來啟動的!所以這裡我們也直接以 xinetd 來設(shè)定 proftpd 吧!
[root@Randyliu proftpd-1.2.10]# vi /etc/xinetd.d/proftpd
service ftp
{ disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/local/proftpd/sbin/proftpd
server_args = -c /usr/local/proftpd/etc/proftpd.conf
log_on_success += DURATION USERID
log_on_failure += USERID
Ok,對于剛才安裝完的proftpd。其設(shè)定檔在/usr/local/proftpd/etc/proftpd.conf
其說明檔在/usr/local/proftpd/man,我們編輯一下設(shè)定檔。如下:
[root@Randyliu proftpd-1.2.10]# vi /usr/local/proftpd/etc/proftpd.conf
ServerName "this is the ftp server for RD department"
ServerType inetd
DefaultServer on
Port 21
Umask 022
MaxInstances 10
User nobody
Group nobody
TimesGMT off
MaxClients 20
MaxClientPerHost 2
AllowStoreRestart on
AllowOverwrite on
<Limit SITE_CHMOD>;
DenyAll
</Limit>;
<Anonymous ~ftp>;
User ftp
Group ftp
UserAlias anonymous ftp
MaxClients 5
DisplayLogin welcome.msg
DisplayFirstChdir .message
TransferRate STOR 100 user anonymous,ftp
TransferRate RETR 50 user anonymous,ftp
<Limit WRITE>;
DenyAll
</Limit>;
<Directory /var/ftp/upload/*>;
<Limit READ>;
Denyall
</Limit>;
<Limit WRITE>;
Allowall
</Limit>;
</Directory>;
/Anonymous>;
OK,上面的服務(wù)根據(jù)要求輯完之后,就可以啟動服務(wù)了。如下:
[root@Randyliu proftpd-1.2.10]# /etc/rc.d/init.d/xinetd restart
Stopping xinetd: OK ]
Starting xinetd: OK ]
[root@Randyliu proftpd-1.2.10]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
10097/xinetd(看著了沒有,21端口開改著呢)
OK,測試一下:
[root@Randyliu proftpd-1.2.10]# ftp localhost
Connected to localhost (127.0.0.1).
220 ProFTPD 1.2.10 Server (this is the ftp server for RD department) [127.0.0.1]
Name (localhost:root): ftp
331 Anonymous login ok, send your complete email address as your password.
Password:
230 Anonymous access granted, restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>; ls
227 Entering Passive Mode (127,0,0,1,128,7).
150 Opening ASCII mode data connection for file list
226 Transfer complete.
注:上面的<Anonymous ~ftp>;表示以匿名登錄后。默認(rèn)目錄的位置在/var/ftp下面。
而且,拒絕寫入的權(quán)限,即denywrite.
以實名用戶登錄之后即可有允許寫的權(quán)力。其文件在其home目錄下。
OK,對以匿名登錄的用戶,編輯信息如下:
[root@Randyliu ftp]# vi /var/ftp/welcome.msg
Welcome to our ftp Server.thanks for using this ftp server and this is only for RD Deapartment for File Translate!
Your machine is : %R
The current time is : %T
The maxclients is :%M
The present connection number is : %N
Your account is : %U
And your current directory is : %C
在 /var/ftp/upload 裡面建立一個特殊訊息
[root@Randyliu ftp]# vi /var/ftp/upload/.message
Attention: the directory that what you access can be upload, but it can't be download;
and your identity is anonymous!
建立 upload 的權(quán)限:
[root@Randyliu ftp]# chown ftp:ftp /var/ftp/upload
[root@Randyliu ftp]# chmod 755 /var/ftp/upload
5. 重新啟動!
[root@Randyliu ftp]# /etc/rc.d/init.d/xinetd restart |
|