1.做好桥接云,桥接到centos 7 服务器上
2.利用华为模拟器做一个简单的局域网
3.交换机的配置
接入层交换机:
interface Ethernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094
interface Ethernet0/0/2 port link-type access port default vlan 10
interface Ethernet0/0/3 port link-type access port default vlan 10
核心交换机:
要在全局下开启DHCP功能 【】 dhcp enable
interface Vlanif10 ip address 192.168.10.1 255.255.255.0 dhcp select relay dhcp relay server-ip 192.168.100.2
interface Vlanif20 ip address 192.168.20.1 255.255.255.0 dhcp select relay dhcp relay server-ip 192.168.100.2
interface Vlanif30 ip address 192.168.100.1 255.255.255.0
interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/3 port link-type access port default vlan 30
4.centos 7的准备工作
①在全局下新建一个网络,并使用桥接模式(必须是在ensp里桥接的网卡)
②在虚拟机设置里选择自定义网络(刚刚创建的)
③手动配置centos 7的IP地址(这里设为192.168.100.2)
5.在centos 7 上下载dhcp,并配置
①下载DHCP
yum install -y dhcp
②配置DHCP的配置文件 /etc/dhcp/dhcpd.conf 其中域名可以删掉
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.200;
option domain-name-servers 114.114.114.114;
option domain-name "ddblog.xyz";
option routers 192.168.10.1;
option broadcast-address 192.168.10.255;
default-lease-time 300;
max-lease-time 7200;
}
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.20 192.168.10.200; ##地址池
option domain-name-servers 114.114.114.114; ##DNS服务器地址
option domain-name "ddblog.xyz"; ##域名
option routers 192.168.10.1; ##默认路由
option broadcast-address 192.168.10.255; ##广播地址
default-lease-time 300; ##默认租约时间
max-lease-time 7200; ##最大租约时间
}
③启动DHCP服务
systemctl start dhcpd
6.其他
rpm -ql dhcp #查看dhcp包安装了哪些文件和程序
/etc/dhcpd.conf #主配置文件
/etc/rc.d/init.d/dh #服务启动脚本
/etc/rc.d/init.d/dhcrelay #继dhcp服务启动脚本
/etc/sysconfig/dhcpd #次要配置文件
/etc/sysconfig/dhcrelay
/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example #示例文件
/ust/lib/systemd/system/dhcpd.services # 服务启动脚本
/var/lib/dhcpd/dhcpd.leases #租约信息存放的文件
/var/lib/dhclient/dhclient.leases #客户端租约文件
/var/lib/dhcpd/dhcpd.leases #服务器端的租约文件在
/etc/dhcp/dhcpd.conf #dhcp配置文件
7.结果展示
博客地址 https://www.ddblog.xyz/articles/56
|