Linux下配置DHCP中继代理
发布网友
发布时间:2022-05-07 18:31
我来回答
共2个回答
热心网友
时间:2022-07-01 01:49
两台LINUX服务器,一台做DHCP服务器,一台做dhcprelay中继代理服务器,三台用于测试的PC,网线若干;
实验需要:
分配三个网段: 192.168.5.0/24
192.168.6.0/24
192.168.7.0/24
其中DHCP中继代理服务器的三个网卡分别为:eth0;eth1;eth2
eth0:192.168.5.1
eth1:192.168.6.1
eth2:192.168.7.1
DHCP服务器的网卡为:eth0
eth0:192.168.5.2
需要用于测试的PC1,PC2,PC3分别挂在三个网段中,最后实验的结果为,三个PC均获得所在网段的ip地址
对DHCP服务器的配置:
#vi /etc/dhcpd.conf
进入文本配置界面
ddns-update-style interim;
ignore client-updates;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option time-offset -18000; # Eastern Standard Time
default-lease-time 259200;
max-lease-time 777600;
option domain-name-servers 202.96.134.133,202.96.128.68;
option broadcast-address 192.168.5.255;
#DNS服务器地址
#下面配置终极作用域
shared-nework mynet{
subnet 192.168.5.0 netmask 255.255.255.0 {
option routers 192.168.5.1;
range dynamic-bootp 192.168.5.1 192.168.5.254;
}
subnet 192.168.6.0 netmask 255.255.255.0 {
option routers 192.168.6.1;
range dynamic-bootp 192.168.6.1 192.168.6.254;
}
subnet 192.168.7.0 netmask 255.255.255.0 {
option routers 192.168.7.1;
range dynamic-bootp 192.168.7.1 192.168.7.254;
}
}
下面我们将配置中继代理服务器
首先要配置文档/etc/sysconfig/dhcrealy.conf
#vi /etc/sysconfig/dhcrealy.conf
在里面输入:
INTERFACES="eth1 eth2"
DHCPSERVERS-"192.168.5.2"
下面启动dhcrelay
#dhcrelay -i eth1 -i eth2 192.168.5.2
最后,我们启动DHCP服务器:
#service dhcpd restart
用pc1,pc2,pc3进行测试:
热心网友
时间:2022-07-01 01:50
假设一台计算机做软路由,有三个网卡,连接3个不同的网段,192.168.1.1/24, 192.168.2.1/24,192.168.3.1/24;其中192.168.1.1/24这个网段有一个DHCP服务器,那怎么样设置可以使192.168.2.1/24和192.168.3.1/24这两个网段分配IP呢?
首先得在dhcp.conf文件中添加超级作用域:
ddns-update-style interim; ;指定DHCP支持的DNS动态更新为interim
ignore client-updates; ;指定不允许客户机更新DNS记录。
shared-network xxxdhcp { ;超级作用域名为xxxdhcp
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.2,192.168.1.10,192.168.4.1;
option broadcast-address 192.168.1.255;
default-lease-time 86400;
max-lease-time 172800;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.21 192.168.1.49;
option routers 192.168.1.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.1.20;
}
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.21 192.168.2.49;
option routers 192.168.2.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.2.20;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.21 192.168.3.49;
option routers 192.168.3.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.3.20;
}
}
linux下的DHCP客户端:/etc/sysconfig/network-scripts/ifcfg-eth0把BOOTPROTO="none"修改为BOOTPROTO="dhcp"
如果需要在系统启动时自动引导启动联网,/etc/sysconfig/networking下的networking=yes。