centos6.6-------DHCP服务配置

一、为一个单一的网段提供地址服务

软件包:  dhcp
配置文件:  /etc/dhcp/dhcpd.conf
租约文件:     /var/lib/dhcpd/dhcpd.leases
监听端口:     67/udp
客户端租约文件:/var/lib/dhclient/dhclient-eth1.leases

网卡网段必须和DHCP分配的网段匹配

1。服务端配置

[root@Server dhcp]# vim dhcpd.conf 
# A slightly different configuration for an internal subnet.
subnet 192.168.137.0 netmask 255.255.255.0 {     //subnet 网段  netmask 子网掩码
  range 192.168.137.1 192.168.137.5; //ip地址池
  option routers 192.168.137.1;   //网关
  default-lease-time 600;   //默认租约时间
  max-lease-time 7200;   //最大租约时间
}
[root@Server ~]# /etc/init.d/dhcpd restart
正在启动 dhcpd:                                           [确定]

2。客户端


[root@Client2 ~]# service network restart
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0: 活跃连接状态:激活中
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/4
状态:激活中
状态:激活的
连接被激活
                                                           [确定]

[root@Client ~]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:0C:29:F5:7C:30 
          inet addr:192.168.137.1  Bcast:192.168.137.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fef5:7c30/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11315 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1234 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10269732 (9.7 MiB)  TX bytes:129859 (126.8 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:352 (352.0 b)  TX bytes:352 (352.0 b)

 

二、指定静态IP

在/etc/dhcp/dhcpd.conf配置文件里写入如下第二段代码

subnet 192.168.137.0 netmask 255.255.255.0 {
        range 192.168.137.1 192.168.137.5;
        option routers 192.168.137.1;
        default-lease-time 600;
        max-lease-time 7200;
host Client {
        hardware ethernet 00:0C:29:F5:7C:30;   //找到所要指定网卡物理地址
        fixed-address 192.168.137.2;           //指定ip
}

 

[root@Client ~]# service network restart

[root@Client ~]# ip a s eth1
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f5:7c:30 brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.2/24 brd 192.168.137.255 scope global eth1
    inet6 fe80::20c:29ff:fef5:7c30/64 scope link 
       valid_lft forever preferred_lft forever
[root@Client ~]# 

三、为多个网段提供ip

转载于:https://www.cnblogs.com/wu-yue/p/6287822.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值