- 论坛徽章:
- 0
|
linux学习心得
Liunx内部主机规划
一、目的和用途
a, 作为代理服务器使用。(使用squid代理,软体为:squid-2.5.STABLE11.tar.gz)
b, 作为RD的内部E-mail服务器使用。(使用软体为posfix)
c, 作为文件传输使用。(使用软件为proftpd-1.2.10.tar.gz)
二、安全全考虑。
众所周知,一台电脑的安全性至关重要。对于本服务器的安全性方面,对于本机的服务器安全性上。拟有以下规划:
a. 火墙和ip filter进行ftp和telnet和ssh服务;
b. 开发的端口方面目前先开放21,23,25,110作为其基本的服务;
c. 以及到rpm组件上网更新最新档;
d.另外,对一些重要的安全性档案,设为只读权限(如/var/log/secure,/var/log/messages,/var/log/messages等)。
e. 对于UINX的programe先开放的如下:atd, crond,iptables,network,random,sshd,telnetd,syslog,xinetd.
三,安装及使用。
一节中,可是重头戏,下面会从软件的分区,安装用各套件的安装,使用上一步一步的详细的步聚,将记录于些,给自己以下作为改进和参考用。
1, 软件的安装。本服务器安装的为RedHat 9.0, 因服务器的硬盘也够大(35G)哦,以及给以后延伸性的使用。还是安装所有的套件。分区如下:
/ 分区,容量为:10G (其他的文件目录分配)
/var 分区 容量:18G (主要是存改用户的E-mail)
/home 分区 容量:3G (当然是用来存放用户文件啰)
/usr 分区 容量:2G (主要是要来安装软体,如proftpd,squid等)
swap 分区 容量:500M
2, 开放telnet服务:
[root@Randyliu root]# vi /etc/xinetd.d/telnet 之后会出现如下:
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(即表示默认为不可用)。把其改为disable=no。 或是前面用注解掉即可,如上红字。
然后要重新开一下xinetd这个Daemon,运行:
[root@Randyliu root]# /etc/rc.d/init.d/xinetd restart .
在系统初始状态,因安全性问题,不能以root登录。须以普通用户登录后用su切换。如果只是自己试验用,则可以做如下修改:
[root@Randyliu root]# vi /etc/pam.d/login (把下面这句话用#注解,后重新启动xinetd即可)
# auth required pam_securetty.so
3,开放ssh服务。
其实ssh服务,在初始安装的时候,即可开启这个服务。用windows 的putty这个软件即可。如果真的没有的话,可以:
[root@Randyliu root]# /etc/rc.d/init.d/sshd start
之后,要netstat –tlp即可查看对应ssh的21端口正在listen …..
因为,ssh这个软件在网络上传输密码时是以加密方式传输。所以,默认情况下,ssh是允许以root登录的。
具体关于ssh的设置可在 /etc/ssh/sshd_config上更改。里面的设置,可以增加端口、更改用户可登录的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、代理上网的要求,安装及设置:(squid-2.5.STABLE11.tar.gz)
要求:a,只是针对RD的59和60网段的电脑可代理上网。
b,squid的使用版本为squid-2.5.STABLE11.tar.gz
安装及设置:
[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(现在所在的绝对路径)
[root@Randyliu squid-2.5.STABLE11] make && make install
OK,安装已完成!
接下来就叫设定吧,还记得刚才安装的目录吗,在/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这个用户去启动的,不过系统提示。此用户不适用,随便找一个用户又运行不了,所以就以root了。不知大家还有其他的说法,例他不以root身份来启动便是了。)
Ok,这下,我们就可以到客户端去测试一下了(IE里面去测试一下吧)。哇塞!太帅了。成功!!!
另外,在运行过程中如何有去改动squid.conf这个档案的话。只要运行以下即可读取squid.conf的设定:
[root@Randyliu etc]# /usr/local/squid1/sbin/squid -k reconfigure
以上,关于squid就OK了,总之是觉得太帅了~~至于分析使用情况的分析,就只能等到下一步去做了.
D.维护,
下面两件事是必须注意的。
1. 若 squid 内设定的使用空间满了,则 squid 将不会运作!
2. 若 squid 的纪录文件太大了,则工作效率会变慢!
对于记录档即(cache档),即/usr/local/squid/cache,我们每隔一段时间有整理一下,即可。至于何时整理,等试运行后定。
9、ftp的要求,安装及设置:
A. 要求。
1. 作为内部ftp文件传输用。开一个用户要求为不能使用ssh和telnet等服务。
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
設定以 xinetd 來啟動 proftpd :
事實上,目前大部分的 FTP daemon 多是以 super daemon 來啟動的!所以這裡我們也直接以 xinetd 來設定 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。其设定档在/usr/local/proftpd/etc/proftpd.conf
其说明档在/usr/local/proftpd/man,我们编辑一下设定档。如下:
[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,上面的服务根据要求辑完之后,就可以启动服务了。如下:
[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>;表示以匿名登录后。默认目录的位置在/var/ftp下面。
而且,拒绝写入的权限,即denywrite.
以实名用户登录之后即可有允许写的权力。其文件在其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 的權限:
[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 |
|