假设一台计算机做软路由,有三个网卡,连接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呢?itlab博客$Y'?L8v;JU5AQ
6jfl5I4N'x8KV0首先得在dhcp.conf文件中添加超级作用域:itlab博客hpO.Wx"c
itlab博客,yY:Z3`TfoH
ddns-update-style. interim;       ;指定DHCP支持的DNS动态更新为interimitlab博客m:ZQ0Vb
   ignore client-updates;              ;指定不允许客户机更新DNS记录。itlab博客N f2b%sB
   shared-network xxxdhcp  {     ;超级作用域名为xxxdhcp
3i9i2PUm0   option subnet-mask 255.255.255.0;itlab博客-euX](S%Zz,K'}:Z
   option domain-name-servers  192.168.1.2,192.168.1.10,192.168.4.1;itlab博客2X7u PO Oc]jW5N8cH
  option broadcast-address 192.168.1.255;itlab博客8f@ l)[2| y%{s
  default-lease-time 86400;
X#U"K8\ea+?:y D h9WGZ0  max-lease-time 172800;
9`Ix q9_&sC0     }itlab博客C*cc i-RnE.gu
itlab博客@'n?H1m
   subnet 192.168.1.0  netmask 255.255.255.0 {
#_4B2?8m$I2T)oW0    range 192.168.1.21 192.168.1.49;itlab博客%E4iv/jWb
    option routers 192.168.1.1;itlab博客B`LQ yU}.S&m m
     host pc1 {
M$Y&E3}X6b~_0       hardware ethernet MAC;itlab博客B_,I o)q"m
       fixed-address 192.168.1.20;
pu6yw#`g"QID0}
j&F5M#u&U `} R0}
)j m7qUZ7{v)m0
_)j`w rCuI^@0subnet 192.168.2.0  netmask 255.255.255.0 {itlab博客-? b0@0Q9K [#S.g W
    range 192.168.2.21 192.168.2.49;
'{pW+X&n ~/k$V0    option routers 192.168.2.1;
4W r6O~/F!VgFW6}0     host pc1 {itlab博客} FL7g8z0v
       hardware ethernet MAC;
_7r+gE%t0       fixed-address 192.168.2.20;itlab博客 ZX;C jH#d^EQL
}itlab博客@iV/N#dZ5Ew%h
}
p*XM)QHQ0itlab博客pw&}_ N+@%G
subnet 192.168.3.0  netmask 255.255.255.0 {itlab博客YZ~.P-C
    range 192.168.3.21 192.168.3.49;itlab博客dK4H*[z%]Jdm
    option routers 192.168.3.1;
A'Z6j,s!e `0     host pc1 {itlab博客 \+s#Ul/b fp6O
       hardware ethernet MAC;itlab博客\:c {p%sQ)l4[Q.u ]
       fixed-address 192.168.3.20;
P4} VPtn3on y0}
x I&o0]v ]0}
2`H-m K0UG'_ k _0itlab博客5xM_u&n:^4k9?$v0T%y1F
linux下的DHCP客户端:/etc/sysconfig/network-scripts/ifcfg-eth0把BOOTPROTO="none"修改为BOOTPROTO="dhcp"itlab博客v&h't!H%DM$q
n+A8Y:X3J)Fdz'}0如果需要在系统启动时自动引导启动联网,/etc/sysconfig/networking下的networking=yes。