Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux build DHCP+DNS+WEB service (small project site! )

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Experimental environment:

One GNS3

A Centos 7 Linux system

One server2016

Two PCs

Objective:

Set up a DHCP service to automatically assign IP addresses to two PCs

A DNS server for domain name resolution.

Build a web server to serve two websites

Connect the entire environment

(1) Build the project framework diagram first in GNS3

SW2 (Layer 2 Switch) Interface:

f1/1 vmnet1 network card connected to win10 is vlan10

f1/2 vmnet2 network card connected to win7 is vlan20

f1/3 vmnet8 network card connected to dhcp+dns is vlan100

f1/0 interface to sw1

SW1 (Layer 3 Switch) Interface:

f1/0 interface to sw2

f1/1 Connect to the f0/0 interface of the R3 router

R3 (router) interface:

f0/0 to f1/1 interface of sw1

f0/1 Connect to web server

DHCP+DNS Server Fixed IP Address: 192.168.100.100/24

Fixed IP address of WEB server: 14.0.0.14/24

The gateway for interface f0/1 of R3 is 14.0.0.1/24. The gateway for interface f0/0 is 12.0.0.2/24.

The gateway of f1/1 interface of SW1 layer 3 switch is 12.0.0.1/24

After the construction is completed, all open

(2) Double-click to open the SW2 Layer 2 switch, configure the vlan and port

f1/1 is vlan10

f1/2 is vlan20

f1/3 is vlan100

f1/0 is trunk link

sw2#conf t Go to global mode sw2(config)#vlan 10,20,100 Create three vlansw2(config-vlan)#exsw2(config)#int f1/1 Set f1/1 interface mode Place interface in vlan10 sw2 (config-if)#sw mod accsw2 (config-if)#sw acc vlan 10sw2 (config-if)#int f1/2 set f1/2 interface mode put interface in vlan20 sw2 (config-if)#sw mod accsw2 (config-if)#sw acc vlan 20sw2(config-if)#int f1/3 set f1/3 interface mode put interface in vlan100 sw2(config-if)#sw mod accsw2(config-if)#sw acc vlan 100sw2(config-if)#int f1/0 Set f1/0 to trunk link mode sw2(config-if)#sw mod trunksw2(config-if)#sw tr encap dotsw2(config-if)#ex

sw2(config)#do show vlan-sw b View vlan info... sw2(config)#do show int f1/0 switchport View f1/0 interface information sw2(config)#no ip routing Turn off routing on Layer 2 switches

(3) Double-click to open sw1 to set the gateway and vlan of the layer 3 switch.

Create three vlans 10, 20, 100

Set f1/0 interface to trunk link

Set gateway subnet mask for vlan10 192.168.10.1 255.255.255.0

Set gateway subnet mask for vlan20 192.168.20.1 255.255.255.0

Set gateway subnet mask for vlan100 192.168.100.1 255.255.255.0

1. Create a vlan and set interface f1/0 as a medium trunk link, and enter the vlan to set the corresponding virtual gateway and open it.

sw1(config)#vlan 10,20,100 Create three vlansw1(config-vlan)#ex exit sw1(config)#int f1/0 Enter interface f1/0sw1(config-if)#switch mod trunk set to trunk link sw1(config-if)#switch trunk encapsulation dot1q select encapsulation type sw1(config-if)#ex exit sw1(config)#int vlan 10 Go to vlan10sw1(config-if)#ip add 192.168.10.1 255.255.255.0 Set vlan10 gateway and subnet mask sw1(config-if)#no shut Open vlan10sw1(config-if)#exsw1(config)#int vlan 20 Set vlan20 sw1(config-if)#ip add 192.168.20.1 255.255.0sw1 (config-if)#no shutsw1(config-if)#exsw1(config)#int vlan 100 Set vlan100sw1(config-if)#ip add 192.168.100.1 255.255.255.0sw1(config-if)#no shut

2. Configure dhcp relay service

sw1#conf tEnter global mode sw1(config)#int vlan 10 Set DHCP relay sw1 in gateway (config-if)#ip helper-address 192.168.100.100sw1 (config-if)#no shutsw1 (config-if)#exsw1(config)#int vlan 20sw1 (config-if)#ip helper-address 192.168.100.100sw1 (config-if)#no shutsw1(config-if)#exsw1(config)#int vlan 100sw1(config-if)#ip helper-address 192.168.100.100sw1(config-if)#no shut

3. Set the Layer 3 port of interface f1/1, configure the address, set the duplex mode and rate, and configure sw1 as a default route.

sw1#conf tEnter global mode sw1(config)#int f1/1 IPsw1(config-if)#no switchportsw1(config-if)#ip add 12.0.0.1 255.255.0sw1 (config-if)#speed 100 Set rate sw1(config-if)#duplex full Set duplex mode sw1(config)ip route 0.0.0.0 0.0.0 12.0.0.2 Configure as default route

(4) Double-click to enter R3 router settings, configure the interface address, and set R3 router to static routing.

sw1#conf tEnter global mode sw1(config)#ip route 192.168.0.0 12.0.0.1 Set up a static route 255.255.255.0

(5) Install DHCP service on Linux system with vmnet8 in NAT network mode first

1, use yum repository to download dhcp service, DNS service

[root@localhost ~]# yum install dhcp -y Install dhcp service

[root@localhost ~]# yum install bind -y Install DNS Services

2. After installation, switch vmnet1, 2 and 8 to host-only mode. Modify vmnet8 on the network virtual editor on the virtual machine. Change nat mode to host-only mode and turn off local dhcp automatic allocation.

(6) Configure Linux dhcp server

1, first change the ip of the Linux system to a static address

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 Set the network card information of ens33 Set a static IP address

[root@localhost ~]# systemctl restart network.service Restart network services

[root@localhost ~]# ifconfig View current NIC information

2, copy a dhcp configuration file template to/etc directory

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf Copy a dhcp configuration file template to etc

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf Set dhcp configuration file

[root@localhost ~]# systemctl start dhcpd Start dhcp service

[root@localhost ~]# systemctl status dhcpd View dhcp service status information

7) Obtain DHCP auto-assigned addresses in win10 and win7 clients

1. Open the network of two clients and change it to obtain IP address automatically.

2. Open cmd command, enter ipconfig command, view ip address, successfully obtain

(8) Configure DNS configuration files

1. Configure global configuration file

[root@localhost ~]# rpm -qc bind View profile information for the software

[root@localhost ~]# vim /etc/named.conf Enter the main file for configuration

2. Enter the vim /etc/named.rfc1912.zones configuration file in the area

3. Configuration data configuration file (kgc.com.zone yun.com.zone)

[root@localhost ~]# cd /var/named Change directory to/var/named [root@localhost named]# cp -p named.localhost kgc.com.zone Copy template to kgc.com.zone[root@ localhost named]# vim kgc.com.zone Configure [root@localhost named]# cp -p kgc.com.zone yun.com.zone Copy a copy of kgc.com.zone as cloud data profile

4. Turn off the firewall and start the DNS resolution service.

5. Use parsing on the client to see if the parsing is successful.

(IX) Build two websites kgc.com yun.com

1. Set the server address and gateway to 14.0.0.14 14.0.0.1

2. Install the web server

3. Create two websites and edit their content

4. Use win7 or win10 to access the website created by the server to see if it can be accessed through domain name resolution.

(X) Use the client to ping the web server to see if it can be interconnected across the network

experiment is successful

Thanks for reading!!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report