DHCP中继配置
作者:互联网
换来换去感觉太凌乱所以可以分为三个步骤:
第一部分:服务器设置
DHCP服务器器调整: [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32 TYPE=Ethernet PROXY_METHOD=none
BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens32 UUID=b194e583-21c3-4109-a160-3d2a9876a30b DEVICE=ens32 ONBOOT=yes IPADDR=192.168.200.111 PREFIX=24 GATEWAY=192.168.200.112 //⽹网关需要指向DHCP中继服务器器同⽹网络的IP地址 DNS1=202.106.0.20 IPV6_PRIVACY=no
[root@localhost ~]# ifconfig ens32 //VMnet8模式 ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.200.111 netmask 255.255.255.0 broadcast 192.168.200.255 inet6 fe80::20c:29ff:feb6f933c prefixlen 64 scopeid 0x20<link> ether 00f0c:29:b6f93f3c txqueuelen 1000 (Ethernet) RX packets 12335 bytes 5849822 (5.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9984 bytes 1934256 (1.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf option domain-name "crushlinux.com"; option domain-name-servers 202.106.0.20, 8.8.8.8; default-lease-time 21600;
max-lease-time 43200;
subnet 192.168.200.0 netmask 255.255.255.0 { range 192.168.200.150 192.168.200.200; option routers 192.168.200.1; }
subnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.150 192.168.100.200; option routers 192.168.100.1; } [root@localhost ~]# systemctl restart dhcpd
第二部分:中继服务器设置
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens32 UUID=b194e583-21c3-4109-a160-3d2a9876a30b IPV6_PRIVACY=no DEVICE=ens32 ONBOOT=yes IPADDR=192.168.200.112 //需作为DHCP服务器器的⽹网关地址 NETMASK=255.255.255.0 [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens34
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens34 IPV6_PRIVACY=no DEVICE=ens34 ONBOOT=yes IPADDR=192.168.100.112 NETMASK=255.255.255.0
[root@localhost ~]# ip a | grep ens 2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 192.168.200.112/24 brd 192.168.200.255 scope global ens32 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 192.168.100.112/24 brd 192.168.100.255 scope global ens34
[root@localhost ~]# rpm -ivh /media/cdrom/Packages/dhcp-4.2.568.el7.centos.x86_64.rpm [root@localhost ~]# rpm -ql dhcp |grep dhcrelay /usr/lib/systemd/system/dhcrelay.service /usr/sbin/dhcrelay /usr/share/man/man8/dhcrelay.8.gz
打开DHCP中继服务器器路路由转发功能
[root@localhost ~]# vim /etc/sysctl.conf net.ipv4.ip_forward = 1 [root@localhost ~]# sysctl -p
开启DHCP中继服务 [root@localhost ~]# dhcrelay 192.168.200.111 Dropped all unnecessary capabilities. Internet Systems Consortium DHCP Relay Agent 4.2.5 Copyright 2004-2013 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/virbr0/52f54f00:b3:df:0e Sending on LPF/virbr0/52f54f00:b3:df:0e Listening on LPF/ens34/00f0c:29f8c:f2:e3 Sending on LPF/ens34/00f0c:29f8c:f2:e3 Listening on LPF/ens32/00f0c:29f8c:f2:d9 Sending on LPF/ens32/00f0c:29f8c:f2:d9 Sending on Socket/fallback
[root@localhost ~]# netstat -anpu | grep dhcrelay udp 0 0 0.0.0.0f67 0.0.0.0:* 2893/dhcrelay
第三部分:测试
当客户机在VMnet2⽹网络时: 当客户机在VMnet8⽹网络时:
标签:中继,no,配置,192.168,ens32,IPV6,DHCP,root,localhost 来源: https://www.cnblogs.com/CAPF/p/11363446.html