目录
前言
一、实验拓扑
二、目的和要求
1.目的
2.要求
三、实验步骤
1.DHCP服务器配置
1.1 关闭防火墙与SElinux
1.2 配置静态IP地址
1.3 配置本地yum源
1.4 安装DHCP
1.5 配置DHCP
1.6 启动DHCP
2.DNS服务器配置
2.1 关闭防火墙与SElinux
2.2 配置静态IP地址
2.3 配置本地yum源
2.4 安装DNS(BIND)
2.5 配置DNS
2.6 启动DNS并验证
3.web服务器配置
3.1 关闭防火墙与SElinux
3.2 查看IP地址获得情况
3.3 配置本地yum源
3.4 安装Apache
3.5 配置Apache
3.6 启动Apache
3.7 安装Nginx
3.8 配置Nginx
3.9 启动Nginx
3.10 安装Tomcat
3.11 配置Tomcat
3.12 启动 Tomcat
3.13 配置网关
4.DHCP中继服务器配置(多网卡)
4.1 关闭防火墙与SElinux以及网络图形化工具
4.2 配置静态IP
4.3 配置本地yum源
4.4 安装DHCP
4.5 配置DHCP中继
四、客户端访问测试
1.客户端通过DHCP服务获取IP地址并测试与web服务器的通信性
2.浏览器访问Web服务器的各个页面
总结
前前后后学习Linux差不多已有月余,此时利用一个综合实验,来检验学习成果,此次实验以网络相关部分为主。
实现每个节点都能相互ping通;
实现Clients主机能通过域名访问对应的web服务器;
DHCP服务器和DNS服务器分配静态IP
web服务器通过DHCP分配IP
用中继器实现DHCP分配不同网段的IP
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=enforcing 改为SELINUX=disabled
systemctl stop NetworkManager ; systemctl disable NetworkManager
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.253
PREFIX=24
GATEWAY=192.168.100.254
ifdown ens33 && ifup ens33
ip a
cd /etc/yum.repos.d/
mkdir backup
mv CentOS-* backup
vim local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount /dev/sr0 /mnt
yum install -y dhcp
vim /etc/dhcp/dhcpd.conf
cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
本网段(192.168.100.0)和多网段(192.168.200.0)
绑定web服务器的MAC地址,分配固定IP(192.168.100.251/24)
systemclt restart dhcpd
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=enforcing 改为SELINUX=disabled
systemctl stop NetworkManager ; systemctl disable NetworkManager
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.252
PREFIX=24
GATEWAY=192.168.100.254
ifdown ens33 && ifup ens33
ip a
cd /etc/yum.repos.d/
mkdir backup
mv CentOS-* backup
vim local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount /dev/sr0 /mnt
yum install -y bind
vim /etc/named.conf
cd /var/named/
ls
cp -p named.empty apache.com.zones
cp -p named.empty nginx.com.zones
cp -p named.empty tomcat.com.zones
vim apache.com.zones
vim nginx.com.zones
vim tomcat.com.zones
systemctl restart named
nslookup
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=enforcing 改为SELINUX=disabled
ifdown ens33 && ifup ens33
ip a
cd /etc/yum.repos.d/
mkdir backup
mv CentOS-* backup
vim local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount /dev/sr0 /mnt
yum install -y httpd
vim /etc/httpd/conf/httpd.conf
cd /var/
mkdir web
cd web/
mkdir apache
mv /tmp/VMwareDnD/U3EqOa/index.html .
vim index.html
mv index.html apache/
systemctl restart httpd
netstat -anptu | grep httpd
mv /tmp/VMwareDnD/U3EqOa/nginx-1.18.0.tar.gz .
tar xf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure --prefix=/usr/local/nginx
yum install -y pcre-devel
yum install -y zlib-devel
make && make install
vim /usr/local/nginx/conf/nginx.conf
cd /var/web/
mkdir nginx
cp apache/index.html nginx/
vim nginx/index.html
cd /usr/local/nginx/sbin/
./nginx
netstat -anptu | grep nginx
java -version
mv /tmp/VMwareDnD/U3EqOa/apache-tomcat-8.5.16.tar.gz .
ls
tar xf apache-tomcat-8.5.16.tar.gz
mv apache-tomcat-8.5.16 /usr/local/tomcat8
cd /usr/local/tomcat8/
ls
ln -s /usr/local/tomcat8/bin/startup.sh /usr/local/bin/btomcat
ln -s /usr/local/tomcat8/bin/shutdown.sh /usr/local/bin/stomca
vim /usr/local/tomcat8/conf/server.xml
mkdir /var/web/tomcat/ROOT -p
cp /var/web/nginx/index.html /var/web/tomcat/ROOT/
vim /var/web/tomcat/ROOT/index.html
btomcat
netstat -anptu | grep java
route add default gw 192.168.100.254
ip a
cd /etc/sysconfig/network-scripts/
vim ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.254
PREFIX=24
cp ifcfg-ens33 ifcfg-ens36
vim ifcfg-ens36
TYPE=Ethernet
BOOTPROTO=static
NAME=ens36
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.200.254
PREFIX=24
ifdown ens33 && ifup ens33
ifdown ens36 && ifup ens36
ip a
yum install -y dhcp
vim /etc/sysctl.conf
sysctl -p
dhcrelay 192.168.100.253
DHCP服务器重启服务
设置路由
route add default gw 192.168.200.254
客户端1:
ip a
ping 192.168.100.251
客户端2:
ip a
ping 192.168.100.251
echo "nameserver 192.168.100.252" > /etc/resolv.conf
花了三个小时左右的时间才搭建完毕,并不是太理想。但是看到实验结果的那一刻,还是有种学习的成就感,累点苦点也稍微值得。接下来的时间,要更加努力啊。