###############################################################################
配置聚合连接(网卡绑定)team,聚合连接(也称为链路聚合)– 由多块网卡(team-slave)一起组建而成的虚拟网卡,即“组队”– 作用1:轮询式(roundrobin)的流量负载均衡– 作用2:热备份(activebackup)连接冗余一.添加team团队设备[root@server0 ~]# man teamd.conf /example #全文查找example #按n 跳转下一个匹配 查找网卡备份的文件# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'# cat /etc/sysconfig/network-scripts/ifcfg-team0 查看是否有team0网卡# ifconfig team0二、添加成员# nmcli connection add type team-slave ifname eth1 master team0 //添加eth1到team0# nmcli connection add type team-slave //添加eth2到team0ifname eth2 master team0三、配置team0的IP地址# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.1.1/24 connection.autoconnect yes //配置team0ip地址 四、激活team0# nmcli connection up team-slave-eth1 #激活设备eth1# nmcli connection up team-slave-eth2 #激活设备eth2# nmcli connection up team0 #激活主设备team0 五、验证# teamdctl team0 state #专用于查看team信息########################################################################################用户个性化配置文件 影响指定用户的 bash 解释环境– ~/.bashrc,每次开启 bash 终端时生效全局环境配置 影响所有用户的 bash 解释环境– /etc/bashrc,每次开启 bash 终端时生效[root@server0 ~]# vim /root/.bashrc #影响root文件 alias hello='echo hello' [root@server0 ~]# vim /home/student/.bashrc #影响student文件 alias hi='echo hi' [root@server0 ~]# vim /etc/bashrc #全局配置文件 alias haha='echo xixi' 退出远程登陆,从新远程server0验证[root@server0 ~]# hello #成功[root@server0 ~]# hi #失败[root@server0 ~]# haha #成功[root@server0 ~]# su - student[student@server0 ~]$ hello #失败[student@server0 ~]$ hi #成功[student@server0 ~]$ haha #成功[student@server0 ~]$ exit############################################################################################# 防火墙策略管理(firewall) 一、搭建基本Web服务 服务端: httpd(软件) 1.server0上安装httpd软件 2.server0启动httpd服务,设置开机自起 默认情况下:Apache没有提供任何页面 默认Apache网页文件存放路径:/var/www/html 默认Apache网页文件名称:index.html[root@server0 ~]# systemctl restart httpd 重启http服务[root@server0 ~]# systemctl enable httpd 随机自启[root@server0 ~]# firefox 172.25.0.11 //出现红帽页面,表示服务已经开启并配置正确[root@server0 ~]# vim /var/www/html/index.html //在Apaceh网页的存放路径下创建文件(文件名) <marquee><font color=green><h1>My First Web 内容滚动 设置字体颜色 设置字体大小 内容[root@server0 ~]# firefox 172.25.0.11 //查看网页出现内容########################################################################################二、FTP服务的搭建 服务端: vsftpd(软件) 1.server0上安装 vsftpd软件 2.server0启动 vsftpd服务,设置开机自起 默认共享的位置:/var/ftp配置# yum -y install vsftpd //装包# systemctl restart vsftpd //重启# systemctl enable vsftpd //随机自启# touch /var/ftp/zhangsan.txt //在共享位置创建文件测试# firefox ftp://172.25.0.11 //可以看到共享的zhangsan。txt########################################################################################## 防火墙策略管理(firewall) 作用:隔离 阻止入站,允许出站 系统服务:firewalld 管理工具:firewall-cmd(命令)、firewall-config(图形) 查看防火墙服务状态[root@server0 ~]# systemctl status firewalld.service 根据所在的网络场所区分,预设保护规则集– public:仅允许访问本机的sshd等少数几个服务– trusted:允许任何访问– block:拒绝任何来访请求– drop:丢弃任何来访的数据包 防火墙判断的规则:匹配及停止 1.首先看请求(客户端)当中的源IP地址,所有区域中是否有对于改IP地址的策略,如果有则该请求进入该区域 2.进入默认区域虚拟机server0:# systemctl status firewalld.service //查看防火墙状态 显示active # firewall-cmd --get-default-zone //查看默认分区public# firewall-cmd --zone=public --list-all //查看public分区的信息# firewall-cmd --add-service=http //添加http服务# firewall-cmd --zone=public --list-all //查看区域规则信息 services: dhcpv6-client http ssh //添加成功虚拟机desktop0:# firefox http://172.25.0.11 #访问成功# firefox ftp://172.25.0.11 #访问失败虚拟机server0:# firewall-cmd --zone=public --add-service=ftp# firewall-cmd --zone=public --list-all 虚拟机desktop0:# firefox ftp://172.25.0.11 #访问成功####################################################################################### --permanent选项:实现永久设置虚拟机server0:# firewall-cmd --reload #重新加载防火墙# firewall-cmd --zone=public --list-all //之前配置的http和ftp服务消失(因为上面的设置只为本次设置,所以防火墙重启之后,配置服务消失)# firewall-cmd --permanent --zone=public --add-service=ftp //永久设置ftp# firewall-cmd --permanent --zone=public --add-service=http //永久设置http# firewall-cmd --reload #重新加载防火墙 才能看到服务信息,否则服务相当于未启用# firewall-cmd --zone=public --list-all #################################################################################3#3# 修改默认的区域,不需要加上--permanent虚拟机desktop0:# ping 172.25.0.11 #可以通信虚拟机server0:# firewall-cmd --set-default-zone=block #修改默认区域 拒绝所有请求 (相当于请求发送成功,服务器回复拒绝通信)# firewall-cmd --get-default-zone #查看默认区域 block虚拟机desktop0:# ping 172.25.0.11 #不可以通信 //页面显示无法链接虚拟机server0:# firewall-cmd --set-default-zone=drop //丢弃任何来访数据包 (相当于直接将数据包丢弃,服务器不回包)# firewall-cmd --get-default-zone虚拟机desktop0:# ping 172.25.0.11 #通信无反馈,页面显示正在链接,但链接不上#########################################################################################实现本机的端口映射 本地应用的端口重定向(端口1 --> 端口2)– 从客户机访问 端口1 的请求,自动映射到本机 端口2– 比如,访问以下两个地址可以看到相同的页面:虚拟机desktop0:# firefox http://172.25.0.11:5423-------》172.25.0.11:80 虚拟机server0: # firewall-cmd --permanent --zone=public --add-forward-port=port=5423:proto=tcp:toport=80 # firewall-cmd --reload # firewall-cmd --zone=public --list-all虚拟机desktop0: # firefox http://172.25.0.11:5423###################################################################################