【Linux】基础实验

1.搭建一个NFS服务器,客户端可以从该服务器的、share目录上传并下载文件

2.搭建一个web服务器,客户端通过www.haha.com访问该网站时能够看到内容:thisishaha

3.建立一个DNS服务器,客户端可以使用该服务器解析域名www.haha.com为web服务器的IP

4.将客户端的IP地址中的域名解析服务器地址修改为第三题的dns服务器的ip,使用ping命令ping www.haha.com看能否ping通,用curl www.haha,com看是否能看到内容

1.搭建一个NFS服务器

下载安装包

[root@server ~]# yum install rpcbind -y
[root@server ~]# yum install nfs-utils

服务端配置【服务端的IP地址192.168.154.141】

[root@server ~]# mkdir /share
[root@server ~]# vim /etc/exports
/share 192.168.154.143(rw)
[root@server ~]# chmod o+w /share/
[root@server ~]# systemctl disable firewalld --now
[root@server ~]# getenforce
Permissive
[root@server ~]# setenforce 0
[root@server ~]# systemctl restart nfs-server
[root@server ~]# showmount -e 192.168.154.141
Export list for 192.168.154.141:
/share 192.168.154.143

客户端配置【客户端IP地址192.168.154.143】 

[root@client ~]# showmount -e 192.168.154.141
Export list for 192.168.154.141:
/share 192.168.154.143
[root@client ~]# mkdir -p /nfsclient/nfsclient-share/
[root@client ~]# mount 192.168.154.141:/share /nfsclient/nfsclient-share/
[root@client ~]# df -h

2.搭建一个web服务器

下载安装包Nginx

[root@server ~]# yum install nginx -y

添加IP地址并重新启动 

[root@server ~]# nmtui
[root@server ~]# nmcli connection up ens160

 创建目录,配置文件内容并写入网页内容

[root@server ~]# mkdir /www/haha
[root@server ~]# echo this is haha > /www/haha/index.html
[root@server ~]# vim /etc/nginx/conf.d/test_haha.conf
[root@server ~]# cat /etc/nginx/conf.d/test_haha.conf
server {
        listen 192.168.154.21:80;
        server_name www.haha.com;
        root /www/haha/21;
        location / {
        }
}
[root@server ~]# vim /etc/hosts
[root@server ~]# cat /etc/hosts
192.168.154.21 www.haha.com

关掉防火墙,selinux,重启nginx服务

[root@server ~]# systemctl disable firewalld --now
[root@server ~]# setenforce 0
[root@server ~]# getenforce
Permissive
[root@server ~]# systemctl restart nginx

测试 

[root@server ~]# curl 192.168.154.21
this is haha

 

3.建立一个DNS服务器

下载安装包:

[root@server ~]# yum install bind -y

 

主配置文件的操作如下: 

[root@server ~]# vim /etc/named.conf
options{
       listen-on port 53 {any;};
       directory "/var/named";
};
zone "haha.com"  IN {
       type master;
       file "named.haha.com";
};

 

文件资源记录:

[root@server ~]# vim /var/named/named.haha.com
$TTL 1D
@  IN SOA @ admin.haha.com. (0 1D 1H 1W 3H)
   IN NS  ns.haha.com.
   IN MX 10 mail.haha.com.
ns IN A 192.168.154.141
mail IN A 192.168.154.21
www IN A 192.168.154.22
whaha IN CNAME www
[root@server ~]# systemctl restart named    #重启系统
[root@server ~]# systemctl disable firewalld --now  #关掉防火墙
[root@server ~]# setenforce 0  #关掉seliunx

客户端测试:

[root@client ~]# host www.haha.com 192.168.154.141

4.将客户端的IP地址中的域名解析服务器地址修改为第三题的dns服务器的ip

客户端服务器配置

[root@server ~]# yum install bind -y
[root@server ~]# rpm -ql bind
/etc/named.conf
/var/named/slaves
[root@server ~]# vim /etc/name.conf
[root@server ~]# vim /etc/named.conf
[root@server ~]# cat /etc/named.conf
options{
       listen-on port 53 {any;};
       directory "/var/named";
};
zone "haha.com" IN {
       type master;
       file "named.haha.com";
};
[root@server ~]# vim /var/named/named.haha.com
[root@server ~]# cat /var/named/named.haha.com
$TTL 1D
@ IN SOA @ admin.haha.com. (0 1D 1H 1W 3H)
  IN NS ns.haha.com.
  IN MX 10 main.haha.com.
ns IN A 192.168.154.141
main IN A 192.168.154.10
www IN A 192.168.154.22
whaha IN CNAME www
[root@server ~]# systemctl restart named
[root@server ~]# systemctl disable firewalld --now
[root@server ~]# setenforce 0
[root@server ~]# getenforce
Permissive

服务端服务器测试

[root@client ~]# ping www.haha.com
[root@client ~]# curl www.haha.com

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值