方便大家学习,天天更新,由于回寝之后才能敲当天的代码,加写说明,可能会慢些,我一步一步全写一下~~

day01

今天的目标就是搞下软件仓库,简单的就一笔带过了~~

1.安装vm和redhat版本安装

取名为server,细节不多说~~

2.软件仓库配置

df //查看挂载目录

每个人都可能不一样哦,这个好像是根据主机名来的,一般没调过都是root,我这里是我的名字~~

图片

图片

复制挂载目录

之后配置本地yum源

cd /etc/yum.repos.d/ vim myrepos.repo //编辑为如下即可 [app] name = app enable = 1 gpgcheck = 0 //别忘了换自己的路径 baseurl = file:///run/media/zaunekko/RHEL-8-2-0-BaseOS-x86_64/AppStream ​ [base] name = base enable = 1 gpgcheck = 0 baseurl = file:///run/media/zaunekko/RHEL-8-2-0-BaseOS-x86_64/BaseOS ​ yum makecache //即可成功

如图所示

图片

图片

3.创建快照

别忘了搞个快照~~

第一天over~~

day02

1.再配置两台相同环境的

分别取名为client1,client2,细节不说了,克隆不克隆随你,mac别一样就行~~

2.配置网卡

sever,client1,client2,配置相同的虚拟网卡,别选0,1,8,这三个一般别的nat,桥接等等模式会默认配置,想知道的看虚拟网络编辑器那里就知道为什么了,这里不细说,这里我们选了5~~

图片

图片

3.配置sever虚拟机

首先配置network,如下~~

图片

图片

之后就可以一直敲了~~

[root@localhost ~]# setenforce 0 [root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# yum install dhcp-server.x86_64 -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 0:02:05 ago on Tue 29 Jun 2021 12:41:53 PM CST. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: dhcp-server x86_64 12:4.3.6-40.el8 base 529 k Transaction Summary ================================================================================ Install 1 Package Total size: 529 k Installed size: 1.2 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: dhcp-server-12:4.3.6-40.el8.x86_64 1/1 Installing : dhcp-server-12:4.3.6-40.el8.x86_64 1/1 Running scriptlet: dhcp-server-12:4.3.6-40.el8.x86_64 1/1 Verifying : dhcp-server-12:4.3.6-40.el8.x86_64 1/1 Installed products updated. Installed: dhcp-server-12:4.3.6-40.el8.x86_64 Complete! [root@localhost ~]# cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp-server/dhcpd.conf.example # see dhcpd.conf(5) man page # [root@localhost ~]# cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf //路径写上面查看到的 cp: overwrite '/etc/dhcp/dhcpd.conf'? y [root@localhost ~]# vim /etc/dhcp/dhcpd.conf

配置如下

# which we don't really recommend.//在此之前的subnet的代码块都删掉,或者你注释掉,之后配置如下 # A slightly different configuration for an internal subnet. subnet 1.1.1.0 netmask 255.255.255.0 { //网段和子网号 range 1.1.1.2 1.1.1.3; //想要分配出的ip option domain-name-servers 1.1.1.1; //网关服务器地址,因为我们选择自己找所以网关是自己 option domain-name "zaunekko.example.org";//随意取 option routers 1.1.1.1; //同上即可 default-lease-time 600; //最少租期 max-lease-time 7200; //最大租期 }

退出来,启动dhcp服务~~

[root@localhost ~]# systemctl restart dhcpd.service

成功~~

4.配置client01,client02有线连接

两个都恢复快照,打开network,重新打开一下有线连接,即可发现ip地址已经被配置,分别为刚刚所想配置的1.1.1.2和1.1.1.3,这里我是client02的ip是1.1.1.3~~

5.继续回来配置server

根据作业所示,需要更改1.1.1.3的固定分配地址为1.1.1.100~~

那么就ping一下,就会有arp缓存,就能知道对应的ip对应的mac地址了,应该都记得arp原理吧~~

[root@localhost ~]# arp -a ? (210.30.48.7) at <incomplete> on ens160 ? (1.1.1.3) at 00:0c:29:5f:2a:44 [ether] on ens160 //复制此mac地址 ? (203.107.6.88) at <incomplete> on ens160 ? (1.1.1.2) at 00:0c:29:7c:aa:c9 [ether] on ens160 ? (192.168.116.2) at <incomplete> on ens160

接下来更改dhcpd.conf,配置如下

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf //找到此段,大致为70行 host fantasia { hardware ethernet 00:0c:29:5f:2a:44; //为上步mac地址 fixed-address 1.1.1.100; //想分配的固定ip }

退出来,重新启动dhcp服务~~

[root@localhost ~]# systemctl restart dhcpd.service

成功~~

6.查看client的ip分配是否成功

打开对应的client主机,我这里是client1,重新打开一下有线连接,即可发现ip地址已经被配置为1.1.1.100~~

如下图所示~~

图片

图片

至此,你就可以交作业了,建议再创个快照~~

day02 附加(添加中继)

这里我们直接将server和client1调整到第10块虚拟网卡,client2调整到第15块虚拟网卡,并且为clinet1再添加一个网络适配器,调整到第15块虚拟网卡~~

准备工作做好之后~~

1.配置sever

首先network配置如下~~

图片

图片

因为继刚刚所敲的,然后,只需要敲~~

[root@localhost ~]# route add default gw 1.1.1.2 //因为原来的client1是这个ip,我们想让他做中继 ​ [root@localhost ~]# vim /etc/dhcp/dhcpd.conf //重新配置一下 subnet 1.1.1.0 netmask 255.255.255.0 { range 1.1.1.2 1.1.1.3; option domain-name-servers 1.1.1.2; //更改为client1的 option domain-name "zaunekko.example.org"; option routers 1.1.1.2; default-lease-time 600; max-lease-time 7200; } subnet 100.100.100.0 netmask 255.255.255.0 { range 100.100.100.2 100.100.100.3; option domain-name-servers 100.100.100.1; //更改为client1另外一个网卡的 option domain-name "zaunekko.example.org"; option routers 100.100.100.1; default-lease-time 600; max-lease-time 7200; } ​ ​ [root@localhost ~]# systemctl restart dhcpd.service

成功~~

2.配置client1

重新打开一下有线连接~~

配置会变成此~~

图片

图片

此时打开第二个网卡并且记住名字,并且配置为如下~~

图片

图片

完成之后~~

图片

图片

之后可以敲了~~

[root@localhost yum.repos.d]# setenforce 0 [root@localhost yum.repos.d]# systemctl stop firewalld.service [root@localhost yum.repos.d]# vim /etc/sysctl.conf//添加如下~~ net.ipv4.ip_forward = 1; ​ [root@localhost yum.repos.d]# sysctl -p sysctl: setting key "net.ipv4.ip_forward": Invalid argument net.ipv4.ip_forward = 1; [root@localhost yum.repos.d]# cat /proc/sys/net/ipv4/ip_forward 1 //发现成功 [root@localhost yum.repos.d]# yum install dhcp-relay.x86_64 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 1:41:08 ago on Tue 29 Jun 2021 12:53:09 PM CST. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: dhcp-relay x86_64 12:4.3.6-40.el8 base 236 k ​ Transaction Summary ================================================================================ Install 1 Package ​ Total size: 236 k Installed size: 348 k Is this ok [y/N]: y Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : dhcp-relay-12:4.3.6-40.el8.x86_64 1/1 Running scriptlet: dhcp-relay-12:4.3.6-40.el8.x86_64 1/1 Verifying : dhcp-relay-12:4.3.6-40.el8.x86_64 1/1 Installed products updated. ​ Installed: dhcp-relay-12:4.3.6-40.el8.x86_64 ​ Complete! [root@localhost yum.repos.d]# cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/ [root@localhost yum.repos.d]# vim /etc/systemd/system/dhcrelay.service //编辑如下 ​ [Unit] Description=DHCP Relay Agent Daemon Documentation=man:dhcrelay(8) Wants=network-online.target After=network-online.target ​ [Service] Type=notify ExecStart=/usr/sbin/dhcrelay -d --no-pid 1.1.1.1 -i ens160 -i ens224 StandardError=null ​ [Install] WantedBy=multi-user.target ​ ​ [root@localhost yum.repos.d]# systemctl --system daemon-reload [root@localhost yum.repos.d]# systemctl restart dhcrelay.service [root@localhost yum.repos.d]#

成功~~

3.查看client2

重新打开一下client2的有线连接~~

如下~~

图片

图片

发现成功~~

day03

1.配置sever

ip网关等等都设为192.168.1.1

老师给的很详细直接看就行了,略了今天,直接配~~

[root@localhost ~]# yum install bind.x86_64 -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 1 day, 0:03:22 ago on Tue 29 Jun 2021 12:39:46 PM CST. Dependencies resolved. ======================================================================================================== Package Architecture Version Repository Size ======================================================================================================== Installing: bind x86_64 32:9.11.13-3.el8 app 2.1 M Transaction Summary ======================================================================================================== Install 1 Package Total size: 2.1 M Installed size: 4.5 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: bind-32:9.11.13-3.el8.x86_64 1/1 Installing : bind-32:9.11.13-3.el8.x86_64 1/1 Running scriptlet: bind-32:9.11.13-3.el8.x86_64 1/1 Verifying : bind-32:9.11.13-3.el8.x86_64 1/1 Installed products updated. Installed: bind-32:9.11.13-3.el8.x86_64 Complete! [root@localhost ~]# vim /etc/named.conf [root@localhost ~]# named-checkconf /etc/named.conf [root@localhost ~]# vim /etc/named.rfc1912.zones [root@localhost ~]# cd /var/named/ [root@localhost named]# cp named.localhost shida.com.zone [root@localhost named]# vim shida.com.zone [root@localhost named]# named-checkzone shida.com /var/named/shida.com.zone zone shida.com/IN: loaded serial 0 OK [root@localhost named]# cd /var/named/ [root@localhost named]# cp shida.com.zone 192.168.1.zone [root@localhost named]# vim 192.168.1.zone [root@localhost named]# named-checkzone 1.168.192.in-adddr.arpa /var/named/192.168.1.zone zone 1.168.192.in-adddr.arpa/IN: loaded serial 0 OK [root@localhost named]# systemctl stop firewalld.service se[root@localhost named]# setenforce 0 [root@localhost named]# systemctl restart named.service [root@localhost named]# systemctl enable named.service Created symlink /etc/systemd/system/multi-user.target.wants/named.service → /usr/lib/systemd/system/named.service. [root@localhost named]# chmod +r * [root@localhost named]# vim /etc/resolv.conf [root@localhost named]# PEERDNS=yes [root@localhost named]# nslookup > syb.shida.com Server: 192.168.1.1 Address: 192.168.1.1#53 Name: syb.shida.com Address: 192.168.1.1 > 192.168.1.1 1.1.168.192.in-addr.arpa name = syb.shida.com. > www.shida.com Server: 192.168.1.1 Address: 192.168.1.1#53 www.shida.com canonical name = station2.shida.com. Name: station2.shida.com Address: 192.168.1.2 > yy.shida.com Server: 192.168.1.1 Address: 192.168.1.1#53 Name: yy.shida.com Address: 192.168.1.4

day04

1.配置sever

很详细,也是直接敲~~

[root@localhost ~]# yum install httpd.x86_64 -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 0:00:04 ago on Thu 01 Jul 2021 12:42:49 PM CST. Dependencies resolved. ======================================================================================================== Package Architecture Version Repository Size ======================================================================================================== Installing: httpd x86_64 2.4.37-21.module+el8.2.0+5008+cca404a3 app 1.4 M Installing dependencies: apr x86_64 1.6.3-9.el8 app 125 k apr-util x86_64 1.6.1-6.el8 app 105 k httpd-filesystem noarch 2.4.37-21.module+el8.2.0+5008+cca404a3 app 36 k httpd-tools x86_64 2.4.37-21.module+el8.2.0+5008+cca404a3 app 103 k mod_http2 x86_64 1.11.3-3.module+el8.2.0+4377+dc421495 app 158 k redhat-logos-httpd noarch 81.1-1.el8 base 26 k Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8 app 25 k apr-util-openssl x86_64 1.6.1-6.el8 app 27 k Enabling module streams: httpd 2.4 ​ Transaction Summary ======================================================================================================== Install 9 Packages ​ Total size: 2.0 M Installed size: 5.5 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : apr-1.6.3-9.el8.x86_64 1/9 Running scriptlet: apr-1.6.3-9.el8.x86_64 1/9 Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/9 Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/9 Installing : apr-util-1.6.1-6.el8.x86_64 4/9 Running scriptlet: apr-util-1.6.1-6.el8.x86_64 4/9 Installing : httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 5/9 Installing : redhat-logos-httpd-81.1-1.el8.noarch 6/9 Running scriptlet: httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch 7/9 Installing : httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch 7/9 Installing : mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64 8/9 Installing : httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 9/9 Running scriptlet: httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 9/9 Verifying : apr-1.6.3-9.el8.x86_64 1/9 Verifying : apr-util-1.6.1-6.el8.x86_64 2/9 Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 3/9 Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 4/9 Verifying : httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 5/9 Verifying : httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch 6/9 Verifying : httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 7/9 Verifying : mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64 8/9 Verifying : redhat-logos-httpd-81.1-1.el8.noarch 9/9 Installed products updated. ​ Installed: apr-1.6.3-9.el8.x86_64 apr-util-1.6.1-6.el8.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64 httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64 mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64 redhat-logos-httpd-81.1-1.el8.noarch ​ Complete! [root@localhost ~]# vim /etc/httpd/conf/httpd.conf [root@localhost ~]# echo "weclome to gongyedaxue" >> /var/www/html/index.html [root@localhost ~]# systemctl restart httpd.service [root@localhost ~]# mkdir -p /gongye/yuyue [root@localhost ~]# echo "my name is yuyue" >> /gongye/yuyue/index.html [root@localhost ~]# vim /etc/httpd/conf.d/vdir.conf [root@localhost ~]# semanage fcontext -a -t httpd_sys_content_t '/gongye(/.*)?' [root@localhost ~]# restorecon -Rv /gongye/ Relabeled /gongye from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0 Relabeled /gongye/yuyue from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0 Relabeled /gongye/yuyue/index.html from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0 [root@localhost ~]# systemctl restart httpd.service ​

day05

1.配置sever

直接敲~~

[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# yum install vsftpd.x86_64 -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 23:27:18 ago on Thu 01 Jul 2021 12:42:49 PM CST. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: vsftpd x86_64 3.0.3-31.el8 app 180 k Transaction Summary ================================================================================ Install 1 Package Total size: 180 k Installed size: 343 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : vsftpd-3.0.3-31.el8.x86_64 1/1 Running scriptlet: vsftpd-3.0.3-31.el8.x86_64 1/1 Verifying : vsftpd-3.0.3-31.el8.x86_64 1/1 Installed products updated. Installed: vsftpd-3.0.3-31.el8.x86_64 Complete! [root@localhost ~]# systemctl enable vsftpd.service --now Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /usr/lib/systemd/system/vsftpd.service. [root@localhost ~]# mkdir -p /ftp/share [root@localhost ~]# echo "ni ming yong hu" > /ftp/share/test.txt [root@localhost ~]# vim /etc/vsftpd/vsftpd.conf [root@localhost ~]# systemctl restart vsftpd.service [root@localhost ~]# ls -Zd /var/ftp/ system_u:object_r:public_content_t:s0 /var/ftp/ [root@localhost ~]# semanage fcontext -a -t public_content_t '/ftp/share(/.*)?' [root@localhost ~]# restorecon -Rv /ftp/share/ Relabeled /ftp/share from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:public_content_t:s0 Relabeled /ftp/share/test.txt from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:public_content_t:s0

2.client01验证

直接敲~~

root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# yum install ftp.x86_64 -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 0:03:11 ago on Thu 01 Jul 2021 09:16:34 PM PDT. Package ftp-0.17-78.el8.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete! [root@localhost ~]# ftp 192.168.1.1 Connected to 192.168.1.1 (192.168.1.1). 220 (vsFTPd 3.0.3) Name (192.168.1.1:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (192,168,1,1,64,225). 150 Here comes the directory listing. -rw-r--r-- 1 0 0 16 Jul 02 04:14 test.txt 226 Directory send OK. ftp> get test.txt local: test.txt remote: test.txt 227 Entering Passive Mode (192,168,1,1,206,235). 150 Opening BINARY mode data connection for test.txt (16 bytes). 226 Transfer complete. 16 bytes received in 0.000273 secs (58.61 Kbytes/sec) ftp> exit 221 Goodbye. [root@localhost ~]# ls anaconda-ks.cfg Documents Music Pictures Templates Videos Desktop Downloads original-ks.cfg Public test.txt [root@localhost ~]# cat test.txt ni ming yong hu [root@localhost ~]#

3.配置本地用户的,配置sever

直接敲~~

[root@localhost ~]# useradd yuyue [root@localhost ~]# echo redhat123|passwd --stdin yuyue Changing password for user yuyue. passwd: all authentication tokens updated successfully. [root@localhost ~]# su - yuyue [yuyue@localhost ~]$ echo "weclome to gongyedaxue" >> yuyue.txt [yuyue@localhost ~]$ vim /etc/vsftpd/vsftpd.conf [yuyue@localhost ~]$ su - root Password: [root@localhost ~]# vim /etc/vsftpd/vsftpd.conf [root@localhost ~]# systemctl restart vsftpd.service [root@localhost ~]# getsebool -a | grep ftp ftpd_anon_write --> off ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> off ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off tftp_anon_write --> off tftp_home_dir --> off [root@localhost ~]# setsebool -P ftpd_full_access on [root@localhost ~]#

4.返回client01验证

直接敲~~

[root@localhost ~]# ftp 192.168.1.1 Connected to 192.168.1.1 (192.168.1.1). 220 (vsFTPd 3.0.3) Name (192.168.1.1:root): yuyue 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (192,168,1,1,230,28). 150 Here comes the directory listing. -rw-rw-r-- 1 1001 1001 23 Jul 02 04:27 yuyue.txt 226 Directory send OK. ftp> get yuyue.txt local: yuyue.txt remote: yuyue.txt 227 Entering Passive Mode (192,168,1,1,152,72). 150 Opening BINARY mode data connection for yuyue.txt (23 bytes). 226 Transfer complete. 23 bytes received in 1.9e-05 secs (1210.53 Kbytes/sec) ftp> exit 221 Goodbye. [root@localhost ~]# ls anaconda-ks.cfg Documents Music Pictures Templates Videos Desktop Downloads original-ks.cfg Public test.txt yuyue.txt [root@localhost ~]# cat yuyue.txt weclome to gongyedaxue [root@localhost ~]#
最后修改:2021 年 07 月 05 日
END
本文作者:
文章标题:网络工程实验安排
本文地址:https://www.zaunekko.com/archives/27/
版权说明:若无注明,本文皆ZaunEkko原创,转载请保留文章出处。
如果觉得我的文章对你有用,请随意赞赏