假设一台计算机做软路由,有三个网卡,连接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