Linux set up DHCP + DNS + WEB Services (small project site!)

lab environment:

  • A GNS3

  • Centos7 a Linux system

  • A server server2016

  • Two PC

Purpose:

Set up a DHCP server automatically assigns IP addresses to the two PC

Set up a DNS resolution servers to resolve domain names

Set up a web server provides two websites

To achieve interoperability of the entire environment



(A) in FIG gns3 frame structures in the first item out

SW2 (switcher) Interface:

f1 / 1 is connected win10 vmnet1 card is vlan10

f1 / 2 is connected to the win7 vmnet2 card vlan20 

f1 / 3 dhcp + dns connected to the card vmnet8 vlan100

f1 / 0 f1 sw1 is connected / 0 interface

sw1 (three switches) Interface:

f1 / 0 f1 is connected sw2 / 0 interface

connected to the router R3 f0 f1 / 1/0 Interface

R3 (router) Interface:

f0 / 0 f1 sw1 is connected / 1 Interface

f0 / 1 connected to the web server

DHCP + DNS server fixed IP address: 192.168.100.100/24

WEB server's fixed IP address: 14.0.0.14/24

R3 is a gateway f0 / 1 interface is a gateway 14.0.0.1/24 f0 / 0 interface is 12.0.0.2/24

f1 sw1 three gateway exchange / 1 interface is 12.0.0.1/24

After the build is completed fully open

Screenshot micro-channel _20190904145519.png

(B) Double-click to open sw2 switcher, and port configuration vlan

f1 / 1 to vlan10 

f1 / 2 as vlan20

f1 / 3 is vlan100

f1 / 0 to trunk link

sw2#conf t      进入全局模式
sw2(config)#vlan 10,20,100   创建三个vlan
sw2(config-vlan)#ex
sw2(config)#int f1/1    设置f1/1接口模式将接口放到vlan10中
sw2(config-if)#sw mod acc
sw2(config-if)#sw acc vlan 10
sw2(config-if)#int f1/2  设置f1/2接口模式将接口放到vlan20中
sw2(config-if)#sw mod acc
sw2(config-if)#sw acc vlan 20
sw2(config-if)#int f1/3  设置f1/3接口模式将接口放到vlan100中
sw2(config-if)#sw mod acc
sw2(config-if)#sw acc vlan 100
sw2(config-if)#int f1/0   设置f1/0为trunk链路模式
sw2(config-if)#sw mod trunk
sw2(config-if)#sw tr encap dot
sw2(config-if)#ex

Screenshot micro-channel _20190904152713.png

sw2(config)#do show vlan-sw b  查看vlan的信息
...
sw2(config)#do show int f1/0 switchport   查看f1/0的接口信息
sw2(config)#no ip routing  关闭二层交换机的路由功能

Screenshot micro-channel _20190904152833.png

Screenshot micro-channel _20190904152713.png

(三)双击打开sw1设置三层交换机的网关和vlan

创建三个vlan10,20,100

将f1/0接口设置为trunk链路

设置vlan10的网关子网掩码192.168.10.1 255.255.255.0

设置vlan20的网关子网掩码192.168.20.1 255.255.255.0

设置vlan100的网关子网掩码 192.168.100.1 255.255.255.0

1,创建vlan并将接口f1/0设置为中中继链路,并进入vlan设置相应的虚拟网关并开启

sw1(config)#vlan 10,20,100  创建三个vlan
sw1(config-vlan)#ex     退出
sw1(config)#int f1/0   进入接口f1/0
sw1(config-if)#switch mod trunk   设置为trunk链路
sw1(config-if)#switch trunk encapsulation dot1q  选择封装的类型
sw1(config-if)#ex  退出
sw1(config)#int vlan 10                进入vlan10
sw1(config-if)#ip add 192.168.10.1 255.255.255.0  设置vlan10的网关及子网掩码
sw1(config-if)#no shut   开启vlan10
sw1(config-if)#ex
sw1(config)#int vlan 20    设置vlan20 
sw1(config-if)#ip add 192.168.20.1 255.255.255.0
sw1(config-if)#no shut
sw1(config-if)#ex
sw1(config)#int vlan 100   设置vlan100
sw1(config-if)#ip add 192.168.100.1 255.255.255.0
sw1(config-if)#no shut

Screenshot micro-channel _20190907165705.png

2,配置dhcp的中继服务

sw1#conf t  进入全局模式
sw1(config)#int vlan 10     设置网关中的DHCP中继
sw1(config-if)#ip helper-address 192.168.100.100
sw1(config-if)#no shut
sw1(config-if)#ex
sw1(config)#int vlan 20
sw1(config-if)#ip helper-address 192.168.100.100
sw1(config-if)#no shut
sw1(config-if)#ex
sw1(config)#int vlan 100
sw1(config-if)#ip helper-address 192.168.100.100
sw1(config-if)#no shut

Screenshot micro-channel _20190907165826.png

3,设置接口f1/1的三层端口,配置地址,并设置双工模式及速率,将sw1配置为一个默认的路由

sw1#conf t  进入全局模式
sw1(config)#int f1/1      设置接口的IP
sw1(config-if)#no switchport
sw1(config-if)#ip add 12.0.0.1 255.255.255.0
sw1(config-if)#speed 100   设置速率
sw1(config-if)#duplex full  设置双工模式
sw1(config)ip route 0.0.0.0 0.0.0.0 12.0.0.2  配置为默认路由

Screenshot micro-channel _20190907165959.png

Screenshot micro-channel _20190907170122.png

(四)双击进入R3路由器设置,配置接口地址,并设置R3路由器为静态路由

sw1#conf t  进入全局模式
sw1(config)#ip route 192.168.0.0 255.255.255.0 12.0.0.1 设置一个静态路由

微信截图_20190907171145.png

微信截图_20190907171244.png

(五)先用NAT网络模式的vmnet8Linux系统上安装DHCP服务

1,利用yum仓库下载dhcp服务,DNS服务

[root@localhost ~]# yum install dhcp -y 安装dhcp服务

[root@localhost ~]# yum install bind -y 安装DNS服务

图片1.png

微信截图_20190908160711.png

2,安装好之后将vmnet128全部切换为仅主机模式,在虚拟机上的网络虚拟编辑器上修改vmnet8nat模式改为仅主机模式并将本地dhcp自动分配关闭

图片2.png


(六)配置Linux系统的dhcp服务器

1,先将Linux系统的ip更改为一个静态的地址

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33   设置ens33的网卡信息设置一个静态的IP地址

图片1.png

[root@localhost ~]# systemctl restart network.service  重启网络服务
[root@localhost ~]# ifconfig  查看当前的网卡信息

图片2.png

2,复制一份dhcp配置文件的模板到/etc目录下

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf  复制一份dhcp的配置文件模板到etc下
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf   设置dhcp的配置文件

微信截图_20190908181651.png

微信截图_20190908160711.png

[root@localhost ~]# systemctl start dhcpd   开启dhcp服务
[root@localhost ~]# systemctl status dhcpd  查看dhcp服务状态信息

图片3.png

(七)在win10和win7客户机中获取DHCP自动分配的地址

1,打开两台客户机的网络更改为自动获取IP地址

2,打开cmd命令输入命令ipconfig,查看ip地址,成功获取

图片1.png

图片2.png

微信截图_20190908160711.png

(八),配置DNS的配置文件

1,配置全局配置文件

[root@localhost ~]# rpm -qc bind   查看软件的配置文件信息

[root@localhost ~]# vim /etc/named.conf   进入主文件进行配置

微信截图_20190908181949.png

2,进入区域“vim /etc/named.rfc1912.zones配置文件中

微信截图_20190908183139.png

3,配置数据配置文件(kgc.com.zone yun.com.zone)

[root @ localhost ~] # cd / var / named directory to the switching / var / the named 
[the root @ localhost the named] CP # -p named.localhost kgc.com.zone template for replication kgc.com.zone 
[the root @ localhost named] # vim kgc.com.zone configure 
[root @ localhost named] # cp -p kgc.com.zone yun.com.zone copy kgc.com.zone as a cloud data profiles

微信截图_20190908183527.png

4, turn off the firewall, dns resolution service start

微信截图_20190908184059.png

5, using analytic on the client to see whether it can successfully resolved

微信截图_20190908184406.png

(Ix) set up at two sites on the server server2016 kgc.com yun.com

1, the server and gateway server address is set to 14.0.0.14 14.0.0.1

微信截图_20190908184704.png

2, install the web server

微信截图_20190908184725.png

3, create two websites and edit site content

微信截图_20190908184737.png

4, access to the server using websites created win7 or win10 area to see if able to resolve domain names

微信截图_20190908184745.png

微信截图_20190908184752.png

(X) with the client to ping web server to see whether the whole network interoperability

image.png

Experiment is successful


thanks for reading! ! !


Guess you like

Origin blog.51cto.com/14080162/2436602