RHCE笔记整理
虚拟机环境重置
rht-vmctl reset classroom ; rht-vmctl reset server ; rht-vmctl reset desktop
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
rht-labcheck
ssh -X 172.25.0.11
ssh -X 172.25.0.10
RHCE总结笔记:
步骤01:配置SELinux,确保SELinux处于强制启用模式!!!
方法一
[root@server0 ~]# vim /etc/selinux/config //永久配置
SELINUX=enforcing
[root@server0 ~]# setenforce 1 //临时配置
方法二
[root@server0 ~]# sed -i ‘7c\SELINUX=enforcing’ /etc/selinux/config
[root@server0 ~]# cat /etc/selinux/config | grep ‘X=en*’
SELINUX=enforcing
##############################################################################
步骤02:自定义用户环境(别名设置)
在系统server0和desktop0上创建自定义命令为qstat,此自定义命令将执行以下命令:
/bin/ps -Ao pid,tt,user,fname,rsz
此命令对系统中所有用户有效。
方法一
[root@server0 ~]# vim /etc/bashrc //修改初始文件
alias qstat=’/bin/ps -Ao pid,tt,user,fname,rsz’ //设置别名
[root@server0 ~]# source /etc/bashrc //或重登录后生效
qstat //确认别名可用
方法二
[root@server0 ~]# echo “alias qstat=’/bin/ps -Ao pid,tt,user,fname,rsz’” >> /etc/bashrc ; source /etc/bashrc
##############################################################################
步骤03:配置防火墙端口转发
在系统server0、desktop0配置防火墙,要求如下:
1 除了172.34.0.0/24网段以外,其它客户机都可以访问虚拟机server0、desktop0 !要求设置永久有效!
2 在172.25.0.0/24网络中的系统,访问server0的本地端口5423将被转发到80 !要求设置永久有效!
方法一
[root@server0 ~]# systemctl restart firewalld ; systemctl enable firewalld ;firewall-cmd --set-default-zone=trusted ; firewall-cmd --permanent --add-source=172.34.0.0/24 --zone=block ; firewall-cmd --permanent --zone=trusted --add-forward-port=port=5423:proto=tcp:toport=80 ; firewall-cmd --reload
success
success
success
success
[root@server0 ~]#
##############################################################################
步骤04:配置链路聚合
在server0.example.com和desktop0.example.com之间按以下要求配置一个链路
1 此链路使用接口eth1和eth2
2 此链路在一个接口失效时仍然能工作
3 此链路在server0使用下面的地址 172.16.3.20/255.255.255.0
4 此链路在desktop0使用下面的地址 172.16.3.25/255.255.255.0
5 此链路在系统重启之后依然保持正常状态
方法一
[root@server0 ~]# nmcli connection add con-name team0 type team ifname team0 config ‘{ “runner”:{ “name”:“activebackup” }}’ //建立新的聚合连接
[root@server0 ~]# nmcli connection add con-name team0-p1 type team-slave ifname eth1 master team0 //指定成员网卡1
[root@server0 ~]# nmcli connection add con-name team0-p2 type team-slave ifname eth2 master team0 //指定成员网卡2
[root@server0 ~]# nmcli con modify team0 ipv4.method manual ipv4.addresses “172.16.3.20/24” #dektop是25# connection.autoconnect yes //为聚合连接配置IP地址[root@server0 ~]# nmcli connection up team0 //激活聚合连接[root@server0 ~]# nmcli con up team0-p1 //激活成员连接1[root@server0 ~]# nmcli con up team0-p2 //激活成员连接2
[root@server0 ~]# teamdctl team0 state //确认连接状态
server端
nmcli connection add con-name team0 type team ifname team0 config ‘{ “runner”:{ “name”:“activebackup” }}’ ; nmcli connection add con-name team0-p1 type team-slave ifname eth1 master team0 ; nmcli connection add con-name team0-p2 type team-slave ifname eth2 master team0 ; nmcli con modify team0 ipv4.method manual ipv4.addresses “172.16.3.20/24” connection.autoconnect yes ; nmcli connection up team0 ; nmcli con up team0-p1 ; nmcli con up team0-p2 ; teamdctl team0 state
desktop端
nmcli connection add con-name team0 type team ifname team0 config ‘{ “runner”:{ “name”:“activebackup” }}’ ; nmcli connection add con-name team0-p1 type team-slave ifname eth1 master team0 ; nmcli connection add con-name team0-p2 type team-slave ifname eth2 master team0 ; nmcli con modify team0 ipv4.method manual ipv4.addresses “172.16.3.25/24” connection.autoconnect yes ; nmcli connection up team0 ; nmcli con up team0-p1 ; nmcli con up team0-p2 ; teamdctl team0 state
##############################################################################
步骤05:配置IPv6地址
考试系统上配置接口eth0使用下列 IPv6 地址
1 server0上的地址应该是2003:ac18::305/64
2 desktop0上的地址应该是2003:ac18::306/64
3 两个系统必须能与网络2003:ac18/64内的系统通信
4 地址必须在重启后依旧生效
5 两个系统必须保持当前的IPv4地址并能通信
方法一
用nmcli命令行工具
server端
[root@server0 ~]# nmcli connection show #获知可用连接
名称 UUID 类型 设备
team0-p1 1cca3b40-5218-491c-90b4-9158484bac0c 802-3-ethernet eth1
team0 291a9824-f02a-48cc-93ea-fe5435f18fd7 team team0
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
team0-p2 0cba0d49-bd32-428d-88b4-41a2af3cd69e 802-3-ethernet eth2
[root@server0 ~]# nmcli connection modify “System eth0” ipv6.method manual ipv6.addresses 2003:ac18::305/64#dektop是306# connection.autoconnect yes
[root@server0 ~]# nmcli connection up “System eth0”
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
[root@server0 ~]# vim /etc/hostname #设置固定主机名,避免误操作(若有必要,还可进一步配置静态IP地址/默认网关/DNS地址)
server0.example.com
server端
nmcli connection show ; nmcli connection modify “System eth0” ipv6.method manual ipv6.addresses 2003:ac18::305/64 connection.autoconnect yes ; nmcli connection up “System eth0” ; echo ‘server0.example.com’ >> /etc/hostname ; cat /etc/hostname
desktop端
nmcli connection show ; nmcli connection modify “System eth0” ipv6.method manual ipv6.addresses 2003:ac18::306/64 connection.autoconnect yes ; nmcli connection up “System eth0” ; echo ‘server0.example.com’ >> /etc/hostname ; cat /etc/hostname
方法二
用图形工具(不推荐)
##############################################################################
步骤06:配置本地邮件服务
在系统 desktop0 上执行下列操作,将其配置为后端邮件服务:
lab smtp-nullclient setup (环境脚本)server和desktop在练习环境都要运行!!!
在系统 server0 上配置邮件服务,满足以下要求
1 这个系统不接收外部发送来的邮件
2 在这个系统上本地发送的任何邮件都会自动路由到 smtp0.example.com
3 从这个系统上发送的邮件显示来自于 desktop0.example.com
4 您可以在这个系统上发送邮件到本地用户student来测试您的配置,最终将会由系统 desktop0 上的用户 student 收到这封邮件
方法一
root@server0 ~]# vim /etc/postfix/main.cf
relayhost = [smtp0.example.com] //后端邮件服务器
inet_interfaces = loopback-only //仅本机