Linux DHCP service configuration and FTP service configuration

1. DHCP overview and principle

Insert picture description here

dhcp principle and dhcp relay blog

Two, configuration command steps

1. Set up a DHCP configuration file

yum -y install dhcp             //首先安装dhcp
cd /etc/dhcp
less dhcpd.conf                 //看一下dhcp配置文件,大多无内容
cd /usr/share/doc/dhcp-4.2.5            //dhcp配置文件参考模板
less dhcpd.conf.example                 //查看配置文件参考模板
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf   //将模板文件复制到配置文件中
vim /etc/dhcp/dhcpd.conf                //进入编辑dhcp配置文件

2. Set up the global configuration

default-lease-time 21600; 	     //默认租约为 6 小时,单位为秒
max-lease-time 43200; 		     //最大租约为 12 小时,单位为秒
option domain-name "gg.com";         //指定默认域名
option domain-name-servers 8.8.8.8;     //指定 DNS 服务器地址
ddns-update-style none 		 //禁用 DNS 动态更新

3. Network segment statement

Acting on the entire subnet segment, some configuration parameters have a higher priority than the global configuration parameter
4yy Copy template, p: paste the gateway in the next line, generally .1 or .254

subnet 192.168.80.0 netmask 255.255.255.0 {
    
    	   //首先声明dhcp服务器分配网段的地址池以及子网掩码
  range 192.168.100.10 192.168.100.20;		   //设置ip地址池
  option routers 192.168.100.254;	           //指定默认网关 
}
subnet 192.168.1.0 netmask 255.255.255.0 {
    
             //其次声明其他网段以及子网
  range 192.168.1.10 192.168.1.20;                 //设置ip地址池
  option routers 192.168.1.254;                    //指定默认网关   
}
subnet 192.168.2.0 netmask 255.255.255.0 {
    
            
  range 192.168.2.10 192.168.2.20;              
  option routers 192.168.2.254;                  
}

4. Host host statement (assign a fixed IP address to a single machine)

host hostname {
    
                               //指定需要分配固定IP地址的客户机名称
  hardware ethernet  xx:xx:xx:xx:xx:xx;   //指定该主机的MAC地址
  fixed-address 192.168.71.88;           //指定保留给该主机的IP地址
}

5. Turn on the service

systemctl start dhcpd                          //开启dhcp服务
systemctl stop firewalld                       //关闭防火墙
sentenforce 0                                  //关闭防火墙
netstat -naup | grep 67                        //查看服务是否启动
tail -f /var/log/messages                      //如果启动失败,可以通过查看日志文件来排查错误

6. Instance configuration

Set up network

Insert picture description here

Insert picture description here

<Huawei>
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw2 
[sw2]user-interface console 0 
[sw2-ui-console0]idle-timeout 0 0
[sw2-ui-console0]vlan bat 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2]int g0/0/3
[sw2-GigabitEthernet0/0/3]p l t
[sw2-GigabitEthernet0/0/3]p t a v a
[sw2-GigabitEthernet0/0/3]int vlanif 10
[sw2-Vlanif10]ip add 192.168.1.254 24
[sw2-Vlanif10]int vlan 20
[sw2-Vlanif20]ip add 192.168.2.254 24
[sw2-Vlanif20]int vlan 100
[sw2-Vlanif100]ip add 192.168.100.254 24
[sw2-Vlanif100]
[sw2-Vlanif100]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[sw2] 
[sw2]dhcp enable
[sw2]int vlan 100 
[sw2-Vlanif100]dhcp select relay 
[sw2-Vlanif100]dhcp relay server-ip 192.168.100.20
[sw2-Vlanif100]int vlan 10
[sw2-Vlanif10]dhcp select relay
[sw2-Vlanif10]dhcp relay server-ip 192.168.100.20
[sw2-Vlanif10]int vlan 20
[sw2-Vlanif20]dhcp select relay
[sw2-Vlanif20]dhcp relay server-ip 192.168.100.20

<Huawei>
<Huawei> u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]vlan bat 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]p l a 
[Huawei-Ethernet0/0/1]p d v 10
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l a
[Huawei-Ethernet0/0/2]p d v 20
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l a
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/4
[Huawei-Ethernet0/0/4]p l a
[Huawei-Ethernet0/0/4]p d v 100
[Huawei-Ethernet0/0/4]
[Huawei-Ethernet0/0/4]

Virtual machine settings Insert picture description here
Insert picture description here
Host configuration

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Configure the network card settings
Insert picture description here
Restart the network card

Insert picture description here
Insert picture description here

1. Install dhcp to
view the mount
Insert picture description here

Insert picture description here

Insert picture description here
2. Copy the template file and configure
Insert picture description here

3. Configuration content
Insert picture description here
Insert picture description here
4. Verify the result in ensp
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_53567573/article/details/113925068