十(1,5),十一单元练习题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了十(1,5),十一单元练习题相关的知识,希望对你有一定的参考价值。
<<<第十单元练习题>>>
1.配置desktop主机和server主机的日志服务要求如下:
*)desktop主机中的日志全部定向到/var/log/westos文件中
*)时时同步desktop主机中的所有日志到server中
5.配置系统中的systemd-journal程序,使journal命令可以查看到关机前的日志
1.
desktop主机:
vim /etc/rsyslog.conf
重启rsyslog服务
---------------------------------------------------------------------
desktop主机:
systemctl stop firewalld.service
vim /etc/rsyslog.conf
重启rsyslog服务
server主机:
systemctl stop firewalld.service
vim /etc/rsyslog.conf
重启rsyslog服务,并查看UDP端口号
清空日志,并发送测试消息
收到测试消息
5.
创建目录“journal”-->修改权限-->重启进程-->重启虚拟机
发现日志是从05:42:50开始记录,这个时间是重启前的时间
<<<第十一单元练习>>>
1.在系统中创建set-ip-tool命令要求如下
当在系统中执行set-ip-tool 172.25.254.X 后
*)会自动显示ifconfig命令的输出
*)系统ip被设定为:172.25.254.X
*)系统网关被设定为:172.25.254.250
*)系统dns被设定为:172.25.254.250
1.
[[email protected] Desktop]# vim set-ip-tool
--------------------------------------------------
#!/bin/bash
IP=$1
DIR=/etc/sysconfig/network-scripts
> $DIR/ifcfg-eth0
echo "DEVICE=eth0" > $DIR/ifcfg-eth0
echo "BOOTPROTO=none" >> $DIR/ifcfg-eth0
echo "ONBOOT=yes" >> $DIR/ifcfg-eth0
echo "TYPE=Ethernet" >> $DIR/ifcfg-eth0
echo "IPADDR0=$IP" >> $DIR/ifcfg-eth0
echo "PREFIX0=24" >> $DIR/ifcfg-eth0
echo "GATEWAY=172.25.254.250" >> $DIR/ifcfg-eth0
echo "DNS=172.25.254.250" >> $DIR/ifcfg-eth0
systemctl restart network.service &> /dev/null
ifconfig
:wq
--------------------------------------------------
[[email protected] Desktop]# ll
total 4
-rw-r--r--. 1 root root 452 Oct 17 23:17 set-ip-tool
[[email protected] Desktop]# chmod u+x set-ip-tool
[[email protected] Desktop]# ll
total 4
-rwxr--r--. 1 root root 452 Oct 17 23:17 set-ip-tool
[[email protected] Desktop]# $PATH
bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin: No such file or directory
[[email protected] Desktop]# mv set-ip-tool /usr/local/bin/
[[email protected] Desktop]# ls /usr/local/bin/
lab set-ip-tool
[[email protected] Desktop]# systemctl stop NetworkManager.service
[[email protected] Desktop]# set-ip-tool 172.25.254.100
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.254.100 netmask 255.255.255.0 broadcast 172.25.254.255
inet6 fe80::5054:ff:fe00:320a prefixlen 64 scopeid 0x20<link>
ether 52:54:00:00:32:0a txqueuelen 1000 (Ethernet)
RX packets 456 bytes 43765 (42.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1492 bytes 106903 (104.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 739 bytes 66718 (65.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 739 bytes 66718 (65.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] Desktop]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.254.250 0.0.0.0 UG 0 0 0 eth0
172.25.254.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
[[email protected] Desktop]# cat /etc/resolv.conf
# Generated by NetworkManager
domain ilt.example.com
search ilt.example.com example.com
nameserver 172.25.254.250
本文出自 “施超Linux学习笔记” 博客,谢绝转载!
以上是关于十(1,5),十一单元练习题的主要内容,如果未能解决你的问题,请参考以下文章