码迷,mamicode.com
首页 > 其他好文 > 详细

二级知识1

时间:2017-07-16 16:38:11      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:策略   修改   firefox   sys   su -   map   有用   local   web服务   

ELinux安全机制
 
SELinux运行模式的切换
? SELinux的运行模式
– enforcing(强制)、permissive(宽松)
– disabled(彻底禁用)
 
? 切换运行模式
– 临时切换:setenforce 1|0
– 固定配置:/etc/selinux/config 文件
 
[root@server0 ~]# getenforce     #查看当前SELinux的状态
Enforcing
[root@server0 ~]#  
 
[root@server0 ~]# setenforce 0   #当前关闭SELinux的状态
[root@server0 ~]# getenforce  
Permissive
 
永久修改SELinux运行模式,当前不生效
[root@server0 ~]# grep ‘^SELINUX=‘ /etc/selinux/config
SELINUX=permissive
 
#####################################################
配置高级连接,聚合连接
链路聚合的优势
? team,聚合连接(也称为链路聚合)
 
– 由多块网卡(team-slave)一起组建而成的虚拟网卡,
即“组队”
 
– 作用1 : 轮询式(roundrobin)的流量负载均衡
– 作用2 : 热备份(activebackup)连接冗余
 
[root@server0 ~]# man teamd.conf   #查看team帮助信息
  /example    全文查找example
     按键盘上 ‘n‘ 可以跳转匹配
     按 ‘q‘退出
 
[root@server0 ~]# nmcli connection add type team         con-name team0 ifname team0  autoconnect yes         config  ‘{"runner": {"name": "activebackup"}}‘  
 
nmcli connection 添加  类型  为组队   
配置文件后缀名 team0 接口名字  team0  每次开机自动连接    
组队的内部分配方式  为热备份
 
#生成的配置文件                 
vim /etc/sysconfig/network-scripts/ifcfg-team0
 
删除
# nmcli connection delete team0  
# nmcli connection delete team0-1
# nmcli connection delete team0-2
#  在新建一遍team0
 
第二种方法修改方式
# nmcli connection modify team0  
team.config ‘{"runner": {"name": "activebackup"}}‘
######################################################
添加成员网卡
 
# nmcli connection add type team-slave con-name team0-1 ifname eth1 master team0  
 
# nmcli connection add type team-slave con-name team0-2 ifname eth2 master team0  
 
 
nmcli  connection  添加  类型为  组队的后端成员  配置文件名后缀 team0-1 添加网络接口  eth1  添加到team0组队中
 
#####################################################
配置IP及激活
[root@server0 ~]# nmcli connection modify team0       ipv4.method manual ipv4.addresses 172.16.3.20/24     connection.autoconnect yes
 
[root@server0 ~]# nmcli connection up team0
 
[root@server0 ~]# nmcli connection up team0-1
 
[root@server0 ~]# nmcli connection up team0-2
 
[root@server0 ~]# ifconfig
[root@server0 ~]# teamdctl team0 state   #查看team0运行状态
[root@server0 ~]# ifconfig eth1 down
[root@server0 ~]# teamdctl team0 state
 
#######################################################
 nmcli connection add type team  
 con-name team0 ifname team0 autoconnect yes         
 config ‘{"runner": {"name": "activebackup"}}‘
 
 nmcli connection add type team-slave con-name team0-1   
 ifname eth1 master team0  
 
 nmcli connection add type team-slave con-name team0-2  
 ifname eth2 master team0  
 
 nmcli connection modify team0  ipv4.method manual ipv4.addresses 172.16.3.25/24   connection.autoconnect yes
 
 nmcli connection up team0
 nmcli connection up team0-1
 nmcli connection up team0-2
 teamdctl team0 state
#######################################################
配置永久别名
 
全局环境配置
? 影响所有用户的 bash 解释环境
– /etc/bashrc,每次开启 bash 终端时生效
 
针对单个用户配置
 
– ~/.bashrc ,每次开启 bash 终端时生效
 
 
###################################################
[root@server0 ~]# vim  /etc/bashrc
 
alias haha=‘echo hello!‘
alias myls=‘ls -lhd‘
[root@server0 ~]#  su - student
 
[student@server0 ~]$ haha
[student@server0 ~]$ exit
 
[root@server0 ~]# useradd tom
[root@server0 ~]# su - tom
 
[tom@server0 ~]$ haha
[tom@server0 ~]$ exit
 
#####################################################
 
配置IPv6地址
 
[root@server0 ~]# nmcli connection modify ‘System eth0‘ ipv6.method manual ipv6.addresses                        2003:ac18::305/64 connection.autoconnect yes
 
[root@server0 ~]# nmcli connection up ‘System eth0‘
 
 
[root@server0 ~]# ping6 2003:ac18::305
 
 
###################################################
防火墙应用
 
  起到隔离作用,保护局域网或主机系统
 
####################################################
搭建基本Web服务
 
服务端:server
 1.安装 httpd 可以提供页面   
[root@server0 ~]# yum -y install httpd
 2.重起服务
[root@server0 ~]# systemctl restart httpd
[root@server0 ~]# systemctl status httpd
 3.本机测试
[root@room9pc14 桌面]# ssh -X root@172.25.0.11
 把真机的firefox浏览器全部关闭
[root@server0 ~]# firefox http://172.25.0.11
 
 
网页文件默认存放路径:
[root@localhost ~]# ls /var/www/html/
 
默认网页文件的命名:  index.html
 
[root@server0 ~]# vim  /var/www/html/index.html
<h1><marquee><font color=red>NSD1703
 
[root@server0 ~]# firefox  http://172.25.0.11
 
##################################################
 
FTP:文件传输协议
 
服务端:server
 1.安装 vsftpd 可以提供文件传输   
[root@server0 ~]# yum -y install vsftpd
 2.重起服务
[root@server0 ~]# systemctl restart  vsftpd
[root@server0 ~]# systemctl status  vsftpd
 3.本机测试
[root@server0 ~]# firefox  ftp://172.25.0.11
 
默认共享路径:
[root@server0 ~]# ls  /var/ftp
 
#####################################################
命令行的访问Web
[root@server0 ~]# elinks -dump http://172.25.0.11
                                    NSD1703
 
命令行的访问FTP
 
[root@server0 ~]# ftp 172.25.0.11
 
Connected to 172.25.0.11 (172.25.0.11).
220 (vsFTPd 3.0.2)
Name (172.25.0.11:root): ftp
230 Login successful.
 
ftp>bye
#######################################################
 
RHEL7的防火墙体系
? 系统服务:firewalld
? 管理工具:firewall-cmd、firewall-config
 
[root@server0 ~]# systemctl status firewalld
 
 
– public:仅允许访问本机的sshd等少数几个服务
– trusted:允许任何访问
– block:阻塞任何来访请求
– drop:丢弃任何来访的数据包
 
 
##################################################
1.server0操作查看 当前默认的区域
[root@server0 ~]# firewall-cmd --list-all
2.desktop0 操作
[root@desktop0 ~]# ping -c 2 172.25.0.11
################################################
1.server0操作修改 当前默认的区域
[root@server0 ~]# firewall-cmd --set-default-zone=block
[root@server0 ~]# firewall-cmd --list-all
2.desktop0 操作
[root@desktop0 ~]# ping -c 2 172.25.0.11
#################################################
1.server0操作查看 修改默认的区域
[root@server0 ~]# firewall-cmd --set-default-zone=drop
2.desktop0 操作
[root@desktop0 ~]# ping -c 2 172.25.0.11
######################################################
 
 
客户端匹配规则:         
  1.客户端的源IP地址,在public有策略限制,  进入public
  2.客户端从哪一个网络接口进来
 
 
 
1.server0操作查看
[root@server0 ~]# firewall-cmd --list-all
[root@server0 ~]# firewall-cmd --set-default-zone=public
[root@server0 ~]# firewall-cmd --list-all
 
2.desktop0 操作
[root@desktop0 ~]# ping -c 2 172.25.0.11
[root@desktop0 ~]# ftp 172.25.0.11
[root@desktop0 ~]# elinks -dump http://172.25.0.11
 
3.server0操作
[root@server0 ~]# firewall-cmd --add-service=http
[root@server0 ~]# firewall-cmd --add-service=ftp
 
4.desktop0 操作
[root@desktop0 ~]# ftp 172.25.0.11
[root@desktop0 ~]# elinks -dump http://172.25.0.11
 
 
– 永久(--permanent)
 
# firewall-cmd --permanent  --add-service=http
# firewall-cmd --permanent  --add-service=ftp
 
# firewall-cmd --reload   #重新加载配置
 
######################################################
防火墙端口转发
 
server0操作
[root@server0 ~]# firewall-cmd --list-all
 
[root@server0 ~]# firewall-cmd --permanent --add-forward-port=port=5423:proto=tcp:toport=80
[root@server0 ~]# firewall-cmd --reload  
[root@server0 ~]# firewall-cmd --list-all
 
desktop操作
[root@desktop0 ~]# elinks -dump http://172.25.0.11:5423
 
#####################################################
图形:firewall-config 先选择永久------>区域public----->端口转发
   .......
[root@server0 ~]# firewall-cmd --reload
 
#####################################################
修改默认的区域zone,不需要 --permanent
[root@server0 ~]# firewall-cmd --set-default-zone=trusted  
 
 
典型的应用方式:
严格,方式1:将默认区域保持为block,针对需要放行的访问在trusted区域添加策略
宽松,方式2:将默认区域保持为trusted,针对需要阻止的访问在block区域添加策略
 
####################################################
 hostnamectl  set-hostname  server0.example.com 配置主机名
 
    { "runner":{ "name":"activebackup" }  }
    { "runner":{ "name":"roundrobin" }  }

搭建基本邮件服务
 
1.在server0上操作  
[root@server0 ~]# rpm -q postfix
postfix-2.10.1-6.el7.x86_64
[root@server0 ~]# systemctl status postfix.service  
 
2.在server0上操作,创建邮件用户
[root@server0 ~]# useradd zhangsan
[root@server0 ~]# useradd lisi
[root@server0 ~]# passwd zhangsan
更改用户 zhangsan 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@server0 ~]# echo 123 | passwd --stdin lisi
 
3.修改配置文件,/etc/postfix/main.cf
99   myorigin = example.com       #发件人默认补全的域名后缀      
116  inet_interfaces = all        #允许所有网络接口
164  mydestination = example.com  
                                              #收件人的域名后缀,判断为本域邮件
 
[root@server0 ~]# systemctl restart postfix
 
4.用zhangsan发邮件,lisi收邮件
# mail -s ‘哈01‘ -r zhangsan@example.com lisi@example.com
   邮件内容
       .   #代表结束
# mail -u lisi    #收邮件
>N  1 zhangsan@example.com  Fri Apr 28 10:35  22/689    
& 1
######################################################
邮件发送的方式:
非交互是发邮件
1.利用管道
# echo 123 | mail -s ‘t3‘ -r zhangsan lisi
 
2.利用 < 可以  将文本文件的内容,当作命令的输入
 
# echo hahaxixi  > /opt/mail.txt
# cat /opt/mail.txt
# mail -s ‘test02‘ -r zhangsan  lisi  < /opt/mail.txt
 
######################################################
vim 末行模式开启行号  :set nu
 
1.在server0上操作,vim  /etc/postfix/main.cf
99  myorigin = desktop0.example.com       #发邮件的来源  
116 inet_interfaces = loopback-only
164 mydestination =  
264 mynetworks = [::1]/128, 127.0.0.0/8  #信任的网络
317 relayhost = [smtp0.example.com]     #指定真正的邮件服务器
 
[root@server0 ~]# systemctl restart postfix.service  
 
2.在desktop0上操作
[root@desktop0 ~]# firewall-cmd --set-default-zone=trusted
[root@desktop0 ~]# lab smtp-nullclient setup  
                                                                #搭建邮件服务器脚本命令
3.在server0上操作,  
echo 123 | mail -s ‘abc01‘ -r  lisi  student
4.在desktop0上操作
mail -u student
######################################################
MariaDB数据库基本管理
 
? RHEL7 中的 MariaDB 相关包
– mariadb-server:提供服务端有关的系统程序
– mariadb:提供客户端及管理工具
 
  MariaDB数据库: 端口号 3306
 
1.安装数据库的软件
[root@server0 ~]# yum -y install mariadb mariadb-server
 
[root@server0 ~]# rpm -q mariadb
 
[root@server0 ~]# rpm -q mariadb-server
 
2.重起mariadb
[root@server0 ~]# systemctl restart mariadb
 
#####################################################
默认数据库安装其服务, 无密码可以登陆
 
[root@server0 ~]# mysql                #进入数据库
MariaDB [(none)]> show  databases;     #查看所有数据库
MariaDB [(none)]> create  database studb;  #创建数据库
MariaDB [(none)]> show  databases;
MariaDB [(none)]> drop  database studb;    #删除数据库
MariaDB [(none)]> show  databases;
 
MariaDB [(none)]> use mysql;    #进入mysql数据库中
 
MariaDB [(none)]> show tables;   #查看所有的表格
 
MariaDB [mysql]> desc user;    #查看表结构,具体都有那些列
 
MariaDB [mysql]> select User,Host,Password from user;
            #查询user表中User,Host,Password三列的内容
####################################################
为数据库管理员设置密码
     数据库管理员:root  与   Linux系统管理员root不是同一个人
 
[root@server0 ~]# mysqladmin -u root password ‘123‘
 
[root@server0 ~]# mysql -u root
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
 
[root@server0 ~]# mysql -u root -p      #交互式登陆
Enter password:  
 
[root@server0 ~]# mysql -u root -p123  #非交式是登陆
                                                               #选项-p与密码之间没有空格
####################################################
mariadb服务端配置调整
? 禁止监听,只服务于本机
[root@server0 ~]# vim /etc/my.cnf    #修改mariadb配置文件
[mysqld]
skip-networking    #跳过网络监听
.. ..
[root@server0 ~]# systemctl restart mariadb
 
 
? 导入/恢复到数据库
– mysql [-u用户名] [-p[密码]] 数据库名 < 备份文
件.sql
 
# wget http://classroom.example.com/pub/materials/users.sql
# ls
# mysql -u root -p123  
MariaDB [(none)]> create database nsd;
MariaDB [(none)]> quit
 
# mysql -u root -p123 nsd < users.sql  #导入数据到nsd数据库
 
# mysql -u root -p123  
MariaDB [(none)]> use nsd;
 
MariaDB [(none)]> show tables;
MariaDB [(none)]> select * from base;     #查询表中所有内容
MariaDB [(none)]> select * from location; #查询表中所有内容
 
###################################################
1 请查询base表中tom的密码
MariaDB [nsd]> use nsd;
MariaDB [nsd]> select name,password from base where name=‘tom‘;
 
2 密码是 solicitous 的人的名字?
MariaDB [nsd]> select name,password from base where password=‘solicitous‘;
 
3 有多少人的姓名是 Barbara 同时居住在 Sunnyvale?
MariaDB [nsd]> select * from base,location            where base.name=‘Barbara‘ and location.city=‘Sunnyvale‘ and base.id=location.id;
 
MariaDB [nsd]> select count(*) from base,location      where base.name=‘Barbara‘ and location.city=‘Sunnyvale‘ and base.id=location.id;
#######################################################
MariaDB用户授权
 
? MariaDB [(none)]>  
 
– GRANT 权限列表 ON 数据库名.表名 TO 用户名@
客户机地址 IDENTIFIED BY ‘密码‘;
 
# mysql -u root -p123
 
  grant  select  on    nsd.*  to   stu@localhost
identified by ‘123‘;
 
   当stu用户从本地登陆mariadb输入密码123,将会获得nsd数据库中所有表的查询权限
 
验证:  # mysql -u stu -p123       #可以登陆数据库即可
 
######################################################
删除表记录
1. 禁止空密码root用户访问 mariadb 数据库
 
MariaDB [mysql]> use mysql;
MariaDB [mysql]> select User,Host,Password from user   where User=‘root‘ and Password=‘‘;
 
MariaDB [mysql]> delete from user  where User=‘root‘ and Password=‘‘;
 
MariaDB [mysql]> select User,Host,Password from user   where User=‘root‘ and Password=‘‘;
 
######################################################
数据库表及相关软件的基本知识:
 
    数据(记录):用来表示一个事物(实体)的一些信息(属性)的文字/图片文件等,例如字符串“:tedu.cn”
    数据表:存放很多条数据记录的容器,例如学员联系信息表、学员月考成绩表
    数据表的每一行:存放一条记录
    数据表的每一列/字段:很多个事物的同一个属性
    数据库:存放很多个相互关联的表格的容器,例如NSD1609学员档案库
    数据库管理系统(DBMS):用来管理(创建库/添加/查询/删除/授权等)数据库信息的软件平台
 
postfix空客户端邮件服务器的功能:
 
    不为用户提供电子邮箱
    为邮箱用户向其他邮件服务器发送邮件
    不接受(投递/存储)发送给给本服务器的邮件
 
空客户端邮件服务器的工作环境:
 
客户端 ---> 空客户端邮件服务器(发)---> 普通邮件服务器(发/收)
 
电子邮箱:1234567@qq.com表示在互联网区域qq.com内的一台邮件服务器上属于用户1234567的一个电子邮箱(目录)。
 
postfix发信服务(TCP 25,SMTP)的功能:
 
    为用户提供电子邮箱
    为邮箱用户向其他邮件服务器发送邮件
    为邮箱用户投递/存储收到的邮件
 
dovecot取信服务(TCP 110/143,POP3/IMAP)的功能:为邮箱用户提取邮件。

二级知识1

标签:策略   修改   firefox   sys   su -   map   有用   local   web服务   

原文地址:http://www.cnblogs.com/zjswdbk/p/7190775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!