目录
了解DHCP的服务
DHCP的分配方式
DHCP在Linux的应用
DHCP配置文件说明
DHCP中继
追踪DHCP的网卡信息
FTP
之前在写网络时候已经了解过DHCP是个什么东西了,不多赘述了。现在要和Linux合起来使用。它减少了管理员的工作量;避免了输入错误的可能;避免了IP地址冲突;当网络更改IP地址段时,不需要再重新配置每个用户的IP地址;提高了IP地址的利用率;方便客户端的配置
DHCP的典型应用模式如下:在网络中架设一台专用的DHCP服务器,负责集中分配各种网络地址参数(主要包括IP地址、子网掩码、广播地址、默认网关地址、DNS服务器地址),其它主机作为DHCP客户机,将网卡配置为自动获取地址,即可与DHCP服务器进行通信,完成自动配置过程。
在DHCP的工作原理中,DHCP服务器提供了三种IP地址分配地址:自动分配、手动分配和动态分配
自动分配是当DHCP客户机第一次成功地从DHCP服务器获取到一个IP地址后,就永久地使用这个IP地址。
手动配置是由DHCP服务器管理员专门指定IP地址
动态分配是当DHCP客户机第一次从DHCP服务器获取到IP地址后,并非永久的使用此地址,而是在每次使用完后,DHCP客户机就会释放这个IP地址,供其他客户机使用。
DHCP工作原理前面说过了
前提把防火墙和selinux 关闭
首先安装dhcp
[root@localhost ~]# yum install dhcp -y
把/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example,复制到dhcpd.conf,覆盖原来的dhcpd.conf,
[root@localhost ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
将虚拟机设置为仅主机模式
重新配置网卡参数
[root@localhost ~]#vim /etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost ~]# systemctl restart network //重启网卡
然后配置dhcpd.conf
[root@localhost ~]#vim /etc/dhcp/dhcpd.conf
[root@localhost dhcp]# systemctl start dhcpd 开启dhcp
修改第八行和27行
这样就配置完成了,让我们在window系统测试一下
最后验证一下验证区域与全局优先级
ipconfig /all 查看全部信息
说明是区域后再设置dns,系统会自动匹配后面的dns。
default-lease-time 600;# 默认租约,单位为秒
max-lease-time 7200; 最大租约,单位为秒
option domain-name "example.org"; 默认域名
option domain-name-servers 8.8.8.8; 指定DNS服务器地址
#host主机声明( 给单机分配固定的IP地址)
host passacaglia { #指定需要分配固定IP地址的客户机名称
hardware ethernet 0:0:c0:5d:bd:95; #指定该主机的MAC地址
filename "vmunix.passacaglia"; #指定保留给该主机的IP地址
server-name "toccata.fugue.com";
}
拓扑图
设置Cloud
二层交换机配置
undo terminal monitor
Info: Current terminal monitor is off.
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw1
[sw1]user-interface console 0
[sw1-ui-console0]idle-timeout 0 0
[sw1-ui-console0]q
[sw1]vlan bat 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]port default vlan 10
[sw1-Ethernet0/0/1]int e0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 20
[sw1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 100
[sw1-GigabitEthernet0/0/2]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
return
三层交换机配置
在没有做虚拟减少寻址前,vlan 100 IP地址要和vm1网关一致(服务器的网关一致)
undo terminal monitor
Info: Current terminal monitor is off.
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname L3
[L3]user-interface console 0
[L3-ui-console0]idle-timeout 0 0
[L3-ui-console0]q
[L3]int g0/0/1
[L3-GigabitEthernet0/0/1]port link-type trunk
[L3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[L3-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
return
[L3-GigabitEthernet0/0/1]q
[L3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[L3]vlan bat 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[L3]int vlan 10
[L3-Vlanif10]ip add 192.168.10.10 24
[L3-Vlanif10]dhcp select relay
[L3-Vlanif10]dhcp relay server-ip 192.168.40.100
[L3-Vlanif10]display this
#
interface Vlanif10
ip address 192.168.10.10 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.40.100
#
return
[L3-Vlanif10]int vlan 20
[L3-Vlanif20]ip add 192.168.20.10 24
[L3-Vlanif20]dhcp select relay
[L3-Vlanif20]dhcp relay server-ip 192.168.40.100
[L3-Vlanif20]dis this
#
interface Vlanif20
ip address 192.168.20.10 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.40.100
#
return
[L3-Vlanif20]int vlan 100
[L3-Vlanif100]ip add 192.168.40.1
^
Error:Incomplete command found at '^' position.
[L3-Vlanif100]ip add 192.168.40.1 24
[L3-Vlanif100]dhcp select relay
[L3-Vlanif100]dhcp relay server-ip 192.168.40.100
[L3-Vlanif100]dis this
#
interface Vlanif100
ip address 192.168.40.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.40.100
#
return
[L3-Vlanif100]ping 192.168.40.100
PING 192.168.40.100: 56 data bytes, press CTRL_C to break
Reply from 192.168.40.100: bytes=56 Sequence=1 ttl=64 time=110 ms
Reply from 192.168.40.100: bytes=56 Sequence=2 ttl=64 time=50 ms
Reply from 192.168.40.100: bytes=56 Sequence=3 ttl=64 time=70 ms
Reply from 192.168.40.100: bytes=56 Sequence=4 ttl=64 time=70 ms
Reply from 192.168.40.100: bytes=56 Sequence=5 ttl=64 time=70 ms
--- 192.168.40.100 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/74/110 ms
在虚拟机ping 设置的IP地址是可以通的
[root@localhost ~]#dhclient -d ens33
安装
[root@localhost ~]#yum install -y vsftpd
给最大的权限
[root@localhost vsftpd]#chmod 777 /var/ftp/pub
配置文件
[root@localhost vsftpd]#cd /var/ftp/pub
[root@localhost pub]#vim /etc/vsftpd/vsftpd.conf
anonymous_enable=YES #开启匿名用户访问。默认已开启
write_enable=YES #开放服务器的写权限(若要上传,必须开启)。默认已开启
anon_umask=022 #设置匿名用户所上传数据的权限掩码(反掩码)。
anon_upload_enable=YES #允许匿名用户.上传文件。默认已注释,需取消注释
anon_mkdir_write_enable=YES #允许匿名用户创建(上传)目录。默认已注释,需取消注释
anon_other_write_enable =YES #允许删除、重命名、覆盖等操作。需添加
重启服务
[root@localhost pub]#systemctl start vsftpd
测试
在pub下创建一个文件
[root@localhost pub]#touch xiaobin.zuishuai
[root@localhost pub]#ls
xiaobin.zuishuai
window系统测试
成功!!!!!