ftp服务
安装vsftpd服务 :#yum install vsftpd* -y
查看vsftdd安装 :#getsebool –tl |grep ftp
匿名用户
#vi /etc/vsftpd/vsftpd.conf
去#号anon_mkdir_write_enable=YES
其后添加anon_other_write_enable=YES
去#号anon_upload_enable=YES
重启服务:/etc/init.d/vsftpdrestart
或Service vsftpd restart
创建目录 :mkdir /pub
改其属主/组为ftp :chmod ftp:ftp /pub
改bool值:setsebool –P allow_ftpd_ano+n_writeon
查看bool值:getsebool –a |grep ftp
修改上下文:chcon –R–t public_content_rw_t /var/ftp/pub
重启服务:/etc/init.d/vsftpdrestart
或Service vsftpd restart
查看:ll –Z
本地用户限制上传下载速度
创建用户:useraddaaa
Passwd aaa
123
修改bool值:setsebool –P allow_home_dir on
#vi /etc/vsftpd/vsftpd.conf
在local_umask=22后添加user_config_dir=/etc/vsftpd
限制用户aaa的速度:echo “local_max_rate=1024”>> /etc/vsftpd/aaa
重启服务:/etc/init.d/vsftpdrestart
或Service vsftpd restart
虚拟用户
#vi /etc/vsftpd/vsftpd.conf
Anonymous_wnable=NO关闭匿名用户
添加:guest_enable=YES
Guest_username=vtest
在cd/etc/vstpd下创建
#Vivuser
User1用户名
123密码
User2
123
db_load –T –t hash –f vuser /etc/vsftpd/vuser.db
修改权限:chmod 600/etc/vsftpd/vuser.db
#vi /etc/pam.d/vsftpd
内容全部用#注释
加 auth required pam_userdb.so db=/etc/vsftpd/vuser
account required pam_userdb.so db=/etc/vsftpd/vuser
支持进程:useradd –s/sbin/nologin vtest
常见文件:touch/home/vtest/vtest
修改权限:chmod 704/home/vtest
重启服务:/etc/init.d/vsftpdrestart
或Service vsftpd restart
Nfs服务
服务器上:
创建目录:mkdir /filepub
#vi /etc/exports
/filepub 192.168.1.0/24(rw,no_root_squash)服务器ip
重启服务:/etc/init.d/nfs restart
重新输入配置文件:exportfs -rv
客户端访问nfs
showmount –e 192.168.1.111(服务器ip)
mount.nfs 192.168.1.111:/filepub /mnt
df –h /mnt 查询
在/mnt下的文件就是服务器上的文件
查看时服务器上在/filepub中,客户端在/mnt中
Nis服务
Nis服务器上:
#vi /etc/hosts
192.168.0.100(服务器ip) abc.com abc
查看ping abc.com
Domainname abc,com
eho “domainname abc.com” >> /etc/rc.local
#vi /etc/sysconfig/network
NIS_DOMAIN=abc.com
安装nis
yum install yp* -y
#vi /etc/ypserv.conf
最后加192.168.0.0/24 : * :* : none
添加用户useradd aaa
Passwd 123
升级为域户:/usr/lib/yp/ypinit –m
启动服务
/etc/init.d/ypserv start
/etc/init.d/yppasswddrestart
将host 文件发放
#vi /etc/exports
/home192.168.1.0/24(rw,no_root_squash)服务器ip
重启服务:/etc/init.d/nfs restart
重新输入配置文件:exportfs -rv
客户端
vi /etc/hosts
192.168.0.100 abc.com abc
vi /etc/yp.conf
domain abc.com server abc.com
nisdomainname abc.com
echo “nisdomainname abc.com” >> /etc/rc.local
echo “NIS_DOMAIN=abc.com”>> /etc/sysconfig/network
修改客户端认证方式nis
#vi /etc/nsswitch.conf
改 passwd file nis
chadow file nis
group file nis
启动服务:/etc.init.d/ypbind start
echo “/etc.init.d/ypbind start” >> /etc/rc.local
echo “nisdomainname abc.com ” >> /etc/rc.local
chkconfig ypbind on
调用host文件
showmount –e 192.168.0.100(服务器ip)
mount.nfs 192.168.0.100:/home /home
df –h /mnt 查询
echo “mount.nfs 192.168.0.100:/home /home ”>> /etc/rc.local
samba服务
windows上共享文件abc,linux访问
window共享后查询共享:net share
linux上
查看:smbclient –L //192.168.1.111( windows ip) –U administrator
打开文件:mount.cifs //192.168.1.111/abc /mnt –ousername=administrator
df -h /mnt
或法2
Smbclient //192.168.1.111/abc –U administrator
Smb :/
Linux共享 windows访问
Linux
安装:yum install samba* -y
永久 chkconfig smb on
查看 chkconfig amb – -list
修改bool值:setsebool –P samba_enable_home_dirs on
创建smb用户
Useradd aaa
Smbopasswd –a 123
重启服务:/etc/init.d/smb restart
Windows
运行输入//192.168.1.123(linux ip) 输入用户名密码 会看到自己的家目录
用匿名用户nobody登陆
#vi /etc/samba/smb.conf
[public]后每句前:去掉
改Path=/pub
删Write list=+staff
创建目录:Mkdir /pub
改属主/组:Chown nobody:nobody /pub
重启服务:etc/init.d/smb restart
权限:chmod 700 /pub
改上下文:chcon –t samba_share_t /pub
#vi /etc/samba/smb.conf
改Security=share
重启服务:/etc/init.d/smb restart
此时在windows上可用匿名用户登录 会看见自己的public
要想用用户即能看见自己的家目录又能看见public
#vi /etc/samba.smb.conf
改Security=user
最后在[public]中加browseable=yes
#chmod o+rwx /pub
在windows上清空口令记录 net use * /delete
DHCP服务
安装 yum install dhcp* -y
#Vi /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 network 255.255.255.0
{
Option routers 192.168.0.1;
Option subnet-mask 255.255.255.0;
Option nis-domain “abc.com”;
Option domain-name “abc.com”;
Option domain-name-server 202.99.166.4;
Option time-offset -18000;
Range dynamic-bootp 192.168.0.10 192.168.0.100;
Default-lease-time 21600;
Max-lease-time 43200;
(保留)host jingli
{
Hardware Ethernet00:0c:29:63:ac:1c;(主机max)
Fixed-address192.168.1.11(保留ip)
}
}
Vpn-pptp
安装:Rpm –ivh pptpd-1.3.4-2.el6.i686
#i /etc/sysctl.conf
改:nex.ipv4_forward=1
#i /etc/pptpd.conf
Localip 192.168.1.1(外网)
Remoteip 192.168.0.12-123(内网)
#vi /etc/ppp/chap-secert
Aaa(用户) pptp 123(密码) * (所有中任选一)/192.168.0.23(保留)
/etc/init.d/pptpd restart
附:
添加网卡
Cd/etc/sysconfig/network-scripts
Cpifcfg-eth0 ifcfg-eth1
#viifcfg-eth1
改 eth0 为eth1 去max 改ip
DNS
安装:Yum installbind* -y
#Vi /etc/named.conf
改:Lliten-on port { 192.168.0.100; }服务器ip
Allow-query{ any; }
#vi /etc/named.rfc1912.zone
添加 正向 zone “abc.com” zn {
Type master;
Fiel “abc.com.zone”;
};
反向 zone “0.168.192.in-adar arpa” zn{
Type master;
Fiel “abc.com”;
};
Cd /var/named
Cp named.localhost abc.com.zone
Cp named.loopback abc.com
Vi abc.com.zone
改 Mx10 mail(针对邮件)
A 192.168.0.100
www A 192.168.0.100(web服务器ip)
ftp A 192.168.0.100(ftp服务器ip)
mail A 192.168.0.100(邮件服务器)
vi abc.com
改: A 192.168.0.100
100 PTR www.abc.com
100 PTR ftp.abc.com
100 PTR mail.abc.com
Chown root:named abc.com
Chown root:named abc.com.zone
/etc/init.d/named restart
/etc/init.d/named reload
#Vi /etc/resolv.conf(配DNS)
Nameserver 192.168.0.100
辅助DNS
Yum install bind* -y
Vi /etc/named.conf
改:Lliten-onport { 192.168.0.1; }辅助服务器ip
Allow-query{ any; }
#vi /etc/named.rfc1912.zone
添加 正向 zone “abc.com” zn {
Type slave;
Fiel “slave/abc.com.zone”;
Masters { 192.168.0.100; }(主dns ip)
};
反向 zone “0.168.192.in-adar arpa” zn{
Type slaver;
Fiel “slave/abc.com”;
Masters { 192.168.0.100; }
};
/etc/init.d/named restart
集群
在windows做一个IIS ip 192.168.0.123
Linux 做一个网页
网页步骤
Yuminstall httpd* -y
#Vi /etc/www/html/index.html
内容
#vi/etc/httpd/conf/httpd.conf
改 servername www.abc.com:80
/etc/init.d/httpd restart
#vi /var/named/abc.com.zone
改 www 0 A 192.168.0.100
www 0 A 192.168.0.123
/etc/init.d/httpd restart
Web
安装:Yum install httpd* -y
建立网站:vi /var/www/html/index.html
/etc/init.d/httpdrestart
在LINUX上查看:curl 192.168.0.100(web 服务器ip)
在自创目录下建立网站
Mkdir/web
#Vi/web/index.html建网站
#Vi/etc/httpd/conf/httpd.conf
改DocumentBoot “/web” 默认为/var/www/html
修改上下文 chcon –R –t httpd_sys_content_t/web
/etc/init.d/httpdrestart
做限制
#Vi/etc/httpd/conf/httpd.conf
加 <Directory /web>
Order deny,allow
Deny from all
Allow from 192.168.0.100
AuthType Basic
AuthName “helllo”
AuthUserFile /etc/httpd/userpasswd
Require user aaa
<Diretory>
Htpasswd –c/etc/httpd/userpasswd aaa
/etc/init.d/httpdrestart
用户自己家目录
Useraddaaa
Vi/etc/httpd/conf/httpd.conf
UserDir public_html 去#
UserDir disabled 加#
Mkdir/home/aaa/public_html
Vi/home/aaa/public_html/index.html
Setsebool–P httpd_enable_homedirs on
Chcon –R –thttpd_sys_content_t /home/aaa/public_html
Chmod o+x/home/aaa
用windows访问 192.168.0.100/~aaa
Lamp
安装msq数据库 yum install mysql*
然后启用/etc/init.d/mysqld restart
chkconfigmysqld on
netstat-nl |grep mysql进行查询
mysql进入查看
退出设密码
mysqladmin-u root password 123
mysql -uroot -p 进行登录
showdatebeses 进行查看服务器的信息
use
vi/etc/php.ini
[MySQL]
Mysql.defaule_port=3306
插入mysql.default_host =192.168.0.100
mysql.default_user=root
mysql.default_password=1234
extension=msql.so下面加上一行
extension=msqli.so让他支持msqli
然后退出
vi /etc/httpd/conf/httpd.conf
加 LoadModuce php5_modulemodules/libphp5.so
AddType application/x-http-php. Php
Windows 上共享phpwind…
Linux mount.cifs //192.168.0.123/aaa /mnt –ousername=administrator
Cd /mnt
Cp php…/usr/local/src
Cd/usr/local/src
解压:unzip php..
Cp –Rfupload /var/www/html
Chmod –Rf777 /var/www/html/upload
Vi/etc/httpd/conf/httpd.conf
改:DocumentBoot“/var/www/html/upload”
AddDefaultCharset zh-CN
/etc/init.d/httpdrestart
基于名字的虚拟主机
有DNS支持 有两个nds 正向区域abc.com bbb.com
#Vi/etc/httpd/conf/httpd.conf
添加<VirtualHost * 80>
DocumentRoot /web1
Servername www.abc.com
<Virtualhost>
<VirtualHost * 80>
DocumentRoot /web2
Servername www..bbb.com
<Virtualhost>
Mkdir/web1
Mkdir/web2
#vi/etc/resolv.conf
Nameserver 192.168.0.100
#vi/web1/index.html #vi /web2/index.html
Chcon -R-t httpd_sys_content_t /web1/2
/etc/init.d/httpdrestart
与FTP 结合
Yuminstall vstftpd* -y
Useraddaaa/bbb
#Vi/etc/passwd
改家目录 即:/home/aaa /web1
/hoem/bbb /web2
Chcon -Rfaaa:aaa /web1
Chcon -Rfbbb:bbb /web2
Setsebool-P allow_ftp_full_access on
Setsebool-P ftp_home_dir on
Mv/var/ftp /var/bak.ftp.bak
/etc/init.d/vsftpdrestart
HTTPS
Yuminstall mod-ssl* -y
Cd/etc/pki/tls/certs
Makeabc.crt
前三个为密码 接着是 国家简称 国家全称 城市 公司 部门 域名www.abc.com y邮箱
在改 SSCertificateFile/etc/pki/tls/certs/aaa.crt
SSCertificateFile/etc/pki/tls/certs/aaa.key
#vi/etc/httpd/conf/httpd.conf
Listen 80加#
#vi/var/www/htm/index.html
访问 https://
SENDMAIL 邮件
安装DNS 解析mail.abc.com
能发邮件Yum install sendmail* -y
Cd/etc/mail
#Viaccess
添加:connect 192.168.1.10 RELAY或
Connect abc.com RELAY
Alternatves--config mta
选择2 即:/usr/sbin/sendmail.sendmail
停用postfix : /etc/int.d/postfix stop
Chkconfig postfix off
Yum remove postfix* -y
#visendmail.cf
加# 0 DaemonPortopt=port=smtp/Addr=127.0.0.1Name=MTA
/etc/init.d/sendmailrestart
接收邮件
Yuminstall dovecot* -y
#Vi/etc/dovecot/dovecot.conf
加protocols=pop3
Listen=*
Login_trusted_network=192.168.0.0/24
#vi/etc/dovecot/dovecot.conf/10-mail.conf
去# mail_location=mbox:~/mail:INBOX=/var/mail/%u
/etc/init.d/dovecotrestart
基于身份审核的SMTP 认证
安装DNS 解析mail.abc.com
能发邮件Yum install sendmail* -y
Cd/etc/mail
#Viaccess
添加:connect 192.168.1.10 RELAY或
Connect abc.com RELAY
Alternatves--config mta
选择2 即:/usr/sbin/sendmail.sendmail
停用postfix : /etc/int.d/postfix stop
Chkconfig postfix off
Yum remove postfix* -y
Yuminstall syrus* -y
/etc/init.d/saslauthdstart
Chkconfigsasauthd on
#visendmail.mc
Dnl TRUST_AUTH-MECH…MD5….
Dnl ..GSSAP2 MD5
删掉dnl
DAEMON-OPIONS…ADDR=127.0.0.1..
添加 ndl
M4sendmail.mc > sendmail.cf
/etc/init.d/sendmailrestart
Yum install dovecot* -y
#Vi/etc/dovecot/dovecot.conf
加protocols=pop3
Listen=*
Login_trusted_network=192.168.0.0/24
#vi/etc/dovecot/dovecot.conf/10-mail.conf
去# mail_location=mbox:~/mail:INBOX=/var/mail/%u
/etc/init.d/dovecotrestart
防火墙
添加网卡 内网192.168.1.1和外网222.222.222.222
Vi/etc/sysctl.conf
改net.ipv4=1
Sysctl –p
基于源ip : iptables –t nat –APOSTROUTING –s 192.168.1.0/24 –j SNAT –to 222.222.222.222
基于目的ip: iptables –t nat –A PREROUTING –d222.222.222.222 –p tcp –dport 80 –j 192.168.1.2:80
禁止ping : iptables –A INPUT –p icmp –jDROP
外部telnet 内部 :iptables –t nat –A PREROUTING -d222.222.222.222 –p tcp –dport telnet –j DNAT –to192.168.1.2:23
禁止外部某台telnet :iptables –A FORWARD –S222.222.222.222 –p tcp –dport 23 –j DROP
发布ftp: ip: iptables –t nat –APREROUTING –d 222.222.222.222 –p tcp –dport 21 –j 192.168.1.2:21
添加模块 :modprobenf_nat_ftp (移除模块 rmmod nf_nat_ftp)
Echo “modprobenf_nat_ftp” > /etc/rc.modules
Chmod 755/etc/rc.modules
禁止其他主机ping 防火墙 但防火墙能ping 其他
Iptables –AINPUT –p icmp –icmp-type Echo-Request –j DROP
Iptables –AINPUT –p icmp –icmp-type Echo-_reply –j ACCEPT
Iptables –AINPUT –p icmp –icmp-type destination-unreachable –j ACCEPT
禁止某mac通过防火墙
Iptables –AFORWARD –m mac –mac-source 00:01:02:03:04:05 –j DROP
允许防火墙本机对外开放tcp端口20,21,25,110及被动模式FTP端口1250-1280
Iptables –AINPUT –p tcp –m multiport –dport 20,21,25,110,1250-1280 –j ACCEPT
禁止转发源ip地址段
Iptables –AFORWARD –p tcp –m iprang –src-rang 192.168.1.20-192.168.1.50 –j DROP
开放本机dns
Iptables –AINPUT –p tcp –dport 53 –j ACCEPT
Iptables –AINPUT –p udp -dport 53 –j ACCEPT
Iptables –AOUPUT –p tcp –dport 53 –j ACCEPT
Iptables –AOUPUT –p udp –dport 53 –j ACCEPT
查看 iptables –t nat –L
清空规则 iptables -F