一、DHCP中继代理
(1)在服务器上建立多个网段的作用域
 

  1. [root@localhost ~]# cat /etc/dhcpd.conf   
  2. ddns-update-style interim;  
  3. ignore client-updates;  
  4.         option subnet-mask              255.255.255.0;  
  5.         option domain-name-servers      202.106.0.20,202.106.148.1;  
  6.         option time-offset              -18000; # Eastern Standard Time  
  7.         default-lease-time 21600;  
  8.         max-lease-time 43200;  
  9. subnet 192.168.2.0 netmask 255.255.255.0 {  
  10.         option routers                  192.168.2.1;  
  11.         range dynamic-bootp 192.168.2.128 192.168.2.254;  
  12. }  
  13. subnet 192.168.3.0 netmask 255.255.255.0 {  
  14.         option routers                  192.168.3.1;  
  15.         range dynamic-bootp 192.168.3.128 192.168.3.254;  
  16. }  
  17. subnet 192.168.4.0 netmask 255.255.255.0 {  
  18.         option routers                  192.168.4.1;  
  19.         range dynamic-bootp 192.168.4.128 192.168.4.254;  


(2)开启中继代理服务器的路由转发功能
/etc/sysctl.conf net.ipv4.ip_forward=1 sysctl –p
 

  1. [root@localhost ~]# cat /etc/sysctl.conf   
  2. # Kernel sysctl configuration file for Red Hat Linux  
  3. #  
  4. # For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and  
  5. # sysctl.conf(5) for more details.  
  6.  
  7. # Controls IP packet forwarding  
  8. net.ipv4.ip_forward = 1 
  9.  
  10. # Controls source route verification  
  11. net.ipv4.conf.default.rp_filter = 1 
  12.  
  13. # Do not accept source routing  
  14. net.ipv4.conf.default.accept_source_route = 0 
  15.  
  16. # Controls the System Request debugging functionality of the kernel  
  17. kernel.sysrq = 0 
  18.  
  19. # Controls whether core dumps will append the PID to the core filename  
  20. # Useful for debugging multi-threaded applications  
  21. kernel.core_uses_pid = 1 
  22.  
  23. # Controls the use of TCP syncookies  
  24. net.ipv4.tcp_syncookies = 1 
  25.  
  26. # Controls the maximum size of a message, in bytes  
  27. kernel.msgmnb = 65536 
  28.  
  29. # Controls the default maxmimum size of a mesage queue  
  30. kernel.msgmax = 65536 
  31.  
  32. # Controls the maximum shared segment size, in bytes  
  33. kernel.shmmax = 4294967295 
  34.  
  35. # Controls the maximum number of shared memory segments, in pages  
  36. kernel.shmall = 268435456 
  37. [root@localhost ~]# sysctl -p  
  38. net.ipv4.ip_forward = 1 
  39. net.ipv4.conf.default.rp_filter = 1 
  40. net.ipv4.conf.default.accept_source_route = 0 
  41. kernel.sysrq = 0 
  42. kernel.core_uses_pid = 1 
  43. net.ipv4.tcp_syncookies = 1 
  44. kernel.msgmnb = 65536 
  45. kernel.msgmax = 65536 
  46. kernel.shmmax = 4294967295 
  47. kernel.shmall = 268435456 



(3)改配置文件
/etc/sysconfig/dhcrelay INTER>接口名 接口名” DHCPSERVERS=服务器IP

 

  1. [root@localhost ~]# cat /etc/sysconfig/dhcrelay   
  2. # Command line options here  
  3. INTERFACES="eth0 eth1 eth2" 
  4. DHCPSERVERS="192.168.2.2" 

(4)启动服务
service dhcrelay start
(5)设置下次开机自动启动
chkconfig dhcrelay on
ps:对于使用虚拟机来做DHCP中继代理实验,最后需要一条指令“dhcrelay DHCP服务器的IP地址”,真实环境此步骤可以省略。