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

Experiment: build DHCP services and cross-segment DNS and web services in different network segments

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

Share

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

Experiment name: set up DHCP service and DNS and web service across network segments in different network segments. Experimental principles: layer 2 switching, layer 3 forwarding, static routing, vlan partition, DHCP principle, DNS principle, web principle experimental objects: client, server, layer 2 equipment, layer 3 equipment experimental ideas:

1) two clients are automatically assigned addresses by DHCP and are under different vlan

2) after obtaining the ip address, you can visit the website. To visit the website, you need to set up the DNS domain name resolution service, and then set up the httpd service.

The idea of configuration is from the bottom to the upper layer, and from the internal network to the external network.

The steps of the experiment:

1. Needless to say, the topology diagram is here.

two。 Intranet configuration

Sw 2 switch:

Sw2#conf tEnter configuration commands, one per line. The End with CNTL/Z.sw2 (config) # no ip routing 'device is modified by the router Need to cancel route forwarding 'sw2 (config) # int f1/0sw2 (config-if) # sw mod tr' interface configuration trunk'*Mar 100: 00 int f1/0sw2 47.903:% DTP-5-TRUNKPORTON: Port Fa1/0 has become dot1q trunksw2 (config-if) # sw tr en d 'trunk Encapsulation Type dot1q'sw2 (config) # vlan 10lle 20100' create VLAN'sw2 (config-vlan) # exitsw2 (config) # int f1/1sw2 (config-if) # sw mod acc 'Interface configuration access'sw2 (config-if) # sw acc vlan 10sw2 (config-if) # int f1/2sw2 (config-if) # sw mod accsw2 (config-if) # sw acc vlan 20sw2 (config-if) # int f1/3sw2 (config-if) # sw mod accsw2 (config-if) # sw acc vlan 100sw2 (config-if) # do show vlan-sw b 'View vlan information' VLAN Name Status Ports -1 default active Fa1/4 Fa1/5, Fa1/6, Fa1/7 Fa1/8, Fa1/9, Fa1/10, Fa1/11 Fa1/12, Fa1/13, Fa1/14 Fa1/1510 VLAN0010 active Fa1/120 VLAN0020 active Fa1/2100 VLAN0100 active Fa1/31002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup

Sw3 layer 3 switch:

Sw3#conf tEnter configuration commands, one per line. End with CNTL/Z.sw3 (config) # int f1/0sw3 (config-if) # sw mod trusw3 (config-if) # * Mar 1 01 int f1/0sw3 24 config-if 05.283:% DTP-5-TRUNKPORTON: Port Fa1/0 has become dot1q trunksw3 (config-if) # sw tru en dsw3 (config-if) # exitsw3 (config) # vlan 10 vlan 20100 sw3 (config-vlan) # int vlan 10 'configure vlan-if 's ip address' sw3 (config-if) # * Mar 1 01R 255.951: % LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10 Changed state to upsw3 (config-if) # ip add 192.168.10.1 255.255.255.0sw3 (config-if) # ip helper-address 192.168.100.100 'create a relay for the ip address of dhcp Help him to cross the vlan'sw3 (config-if) # int vlan 20*Mar 1 01VR 2538. 551:% LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to upsw3 (config-if) # ip add 192.168.20.1 255.255.255.0sw3 (config-if) # ip helper-address 192.168.100.100sw3 (config-if) # int vlan 100*Mar 1 01Vl26 config-if 08.023:% LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100 Changed state to upsw3 (config-if) # ip add 192.168.100.1 255.255.255.0sw3 (config-if) # ip helper-address 192.168.100.100sw3 (config-if) # int f0/0sw3 (config-if) # ip add 11.0.0.11 255.255.255.0sw3 (config-if) # no shut*Mar 1 01 255.255.255.0sw3 32:% LINK-3-UPDOWN: Interface FastEthernet0/0 Changed state to up*Mar 1 01 changed state to upsw3 32 Line protocol on Interface FastEthernet0/0 02.439:% LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to upsw3 (config-if) # exitsw3 (config) # ip route 0.0.0.0 0.0.0.0 11.0.0.1sw3 (config) # do show ip int bInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 11.0.0.11 YES manual up up Vlan1 unassigned YES unset up up Vlan10 192.168.10.1 YES manual up up Vlan20 192.168. 20.1 YES manual up up Vlan100 192.168.100.1 YES manual up up sw3 (config) # do show ip routCodes: C-connected S-static, R-RIP, M-mobile, B-BGP D-EIGRP, EX-EIGRP external, O-OSPF, IA-OSPF inter area N1-OSPF NSSA external type 1, N2-OSPF NSSA external type 2 E1-OSPF external type 1, E2-OSPF external type 2i-IS-IS, su-IS-IS summary, L1-IS-IS level-1, L2-IS-IS level-2 ia-IS-IS inter area, *-candidate default U-per-user static route o-ODR, P-periodic downloaded static routeGateway of last resort is 11.0.0.1 to network 0.0.0.0C 192.168.10.0 Vlan10C 192.168.20.0 Vlan20 24 is directly connected, Vlan20 11.0.0.0 is directly connected, FastEthernet0/0C 192.168.100.024 is directly connected Vlan100S* 0.0.0.0amp 0 [1amp 0] via 11.0.0.1sw3 (config) #

Start configuring DHCP server

First configure the network card

[root@localhost ~] # yum install dhcp*-y 'install' [root@localhost ~] # rpm-Q dhcpdhcp-4.2.5-77.el7.centos.x86_64 [root@localhost ~] # hostname dhcp [root@localhost ~] # su [root@dhcp ~] # vim / etc/sysconfig/network-scripts/ifcfg-ens33 'modify the network card' TYPE= "Ethernet" PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "static" 'change to static' DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" 0f432513-5d7a-455c-88b4-257a9a1dbb45 "DEVICE=" ens33 "ONBOOT=" yes IPADDR=192.168.100.100 'NETMASK=255.255.255.0' ip address' NETMASK=255.255.255.0 'subnet mask' GATEWAY=192.168.100.1 'Gateway' [root@dhcp ~] # systemctl restart Network 'restart Network Card' [root@dhcp ~] # ifconfig 'verify' ens33: flags=4163 mtu 1500 inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255 [root@dhcp ~] # vim / etc/dhcp/dhc 'Open dhcpd.conf You'll find it's empty, but let's see / usr/share/doc/dhcp*/dhcpd.conf.example'dhclient.d/ dhcpd6.conf dhclient-exit-hooks.d/ dhcpd.conf [root@dhcp ~] # cp/ usr/share/doc/dhcp-4.2.5/dhcpd.conf.example / etc/dhcp/dhcpd.conf 'copy to / etc/dhcp/' cp: do you overwrite "/ etc/dhcp/dhcpd.conf"? Y 'override' [root@dhcp ~] # vim / etc/dhcp/dhcpd.conf 'edit' option domain-name "example.org"; 'domain name' option domain-name-servers 12.0.0.12; 'modify to dns server IP'default-lease-time 600;' default lease 600s'max-lease-time 7200 'maximum lease 7200s'subnet 192.168.10.0 netmask 255.255.255.0 {' segment subnet mask 'range 192.168.10.10 192.168.10.100;' range 'option routers 192.168.10.1;' designated gateway'} subnet 192.168.20.0 netmask 255.255.255.0 {range 192.168.20.20 192.168.20.200 Option routers 192.168.20.1;} subnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.10 192.168.100.200; option routers 192.168.100.1 } [root@dhcp ~] # systemctl start dhcpd 'enable dhcpd service' [root@dhcp ~] # systemctl stop firewalld.service 'turn off firewall' [root@dhcp ~] # setenforce 0 'temporarily shut down' [root@dhcp ~] # netstat-natp | grep dhcp 'check port status' [root@dhcp ~] # netstat-naup | grep dhcpudp 000.0.0.0dhcpd 67 0.0.0. 0RV * 39158/dhcpd [root@dhcp ~] #

The configuration of the two clients is relatively simple. Change the IP address acquisition to automatic acquisition.

Then enter ipconfig / release to release the current address at the CMD command prompt, and ipconfig / renew to get the new address command

3. After the private network is set up, the configuration of the public network will begin.

ISP#conf tEnter configuration commands, one per line. End with CNTL/Z.ISP (config) # int f0/0ISP (config-if) # ip add 11.0.0.1 255.255.255.0ISP (config-if) # no shutISP (config-if) # int f*Mar 1 01 LINK-3-UPDOWN: Interface FastEthernet0/0:% LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0 Changed state to upISP (config) # int f0gamma 1 ISP (config-if) # ip add 12.0.0.1 255.255.255.0ISP (config-if) # no shut*Mar 1 01 24 changed state to up*Mar 27.779:% LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up*Mar 1 01 24 changed state to up*Mar 28.779:% LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1 Changed state to upISP (config-if) # exitISP (config) # ip route 192.168.0.0 255.255.0.0 11.0.0.11' Segment Summary 'ISP (config) # do show ip routeCodes: C-connected, S-static, R-RIP, M-mobile, B-BGP D-EIGRP, EX-EIGRP external, O-OSPF, IA-OSPF inter area N1-OSPF NSSA external type 1, N2-OSPF NSSA external type 2 E1-OSPF external type 1 E2-OSPF external type 2 I-IS-IS, su-IS-IS summary, L1-IS-IS level-1, L2-IS-IS level-2 ia-IS-IS inter area, *-candidate default, U-per-user static route o-ODR, P-periodic downloaded static routeGateway of last resort is not set 11.0.0.0 is subnetted, 1 subnetsC 11.0.0.0 is directly connected FastEthernet0/0S 192.168.0.0 via 11.0.0.11 12.0.0.0 via 24 is subnetted, 1 subnetsC 12.0.0.0 is directly connected, FastEthernet0/1ISP (config) # do show ip int bInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 11.0.0.1 YES manual up up FastEthernet0/1 12.0.0.1 YES manual up up ISP (config) #

Configure DNS and HTTPD servers

[root@localhost] # yum install httpd bind- y [root@localhost ~] # rpm-Q httpd bindhttpd-2.4.6-90.el7.centos.x86_64bind-9.11.4-9.P2.el7.x86_64 [root@localhost ~] # vim / etc/sysconfig/network-scripts/ifcfg-ens33PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "static" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" UUID= "8d222179-116b-41b5-8b47-0076ca1aeddb" DEVICE= "ens33" ONBOOT= "yes" IPADDR=12.0.0.12NETMASK=255.255.255.0GATEWAY=12.0.0.1 [root@localhost ~] # systemctl restart network [root@localhost ~] # ifconfigens33: flags=4163 mtu 1500 inet 12.0.12 netmask 255.255.0 broadcast 12.0.0.255 inet6 fe80::e2c1 C26d:afa1:a4ad prefixlen 64 scopeid 0x20 ether 00:0c:29:52:4d:89 txqueuelen 1000 (Ethernet) RX packets 8232 bytes 10547854 (10 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3149 bytes 242681 (236.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~] # vim / etc/named.named.conf named.iscdlv.key named.rfc1912. Zones named.root.key [root@localhost ~] # vim / etc/named.conf 'main configuration File' options {listen-on port 53 {any }; listen-on-v6 port 53 {:: 1;}; directory "/ var/named"; dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt"; memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing" Secroots-file "/ var/named/data/named.secroots"; allow-query {any;}; [root@localhost ~] # vim / etc/named.rfc1912.zones' zone profile 'zone "kgc.com" IN {type master; file "kgc.com.zone";' zone data profile 'allow-update {none;};} [root@localhost ~] # cp-p / var/named/named.localhost / var/named/kgc.com.zone 'copy template, rename, retain permission' [root@localhost ~] # vim / var/named/kgc.com.zone 'zone data configuration file' $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W; expire 3H) Minimum NS @ A 127.0.0.1 AAAA:: 1www IN A 12.0.0.12 'add here' [root@localhost ~] # systemctl stop firewalld.service 'turn off the firewall' [root@localhost ~] # setenforce 0 [root@localhost ~] # systemctl start named [root@localhost ~] # vim / etc/httpd/conf / httpd.conf 'configure httpd' 41 Listen 12.0.0.12 Listen 80' to listen on port'42 # Listen 80'of 12.0.0.12. 95 ServerName www.kgc.com:80 'modify domain name' [root@localhost ~] # systemctl start httpd 'launch' [root@localhost ~] #

test

C:\ Users\ GSY > nslookup www.kgc.comDNS request timed out. Timeout was 2 seconds. Server: UnKnownAddress: 12.0.0.12DNS request timed out. Timeout was 2 seconds.DNS request timed out. Timeout was 2 seconds. Name: www.kgc.comAddress: 12.0.0.12

Root@localhost ~] # cd / var/www/html 'webpage' [root@localhost html] # ls [root@localhost html] # vim index.html'to create a new file, representing the home page 'this is test web' fighting for steamed bread [root@localhost html] # systemctl restart httpd

Refresh

Summary: to understand the specific location of each configuration file, how to configure it, how to write the configuration format, and what each parameter represents, you need to keep in mind.

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