Cấu hình DHCP trên Linux

0
1196
CÀI ĐẶT VÀ CẤU HÌNH DHCP – DYNAMIC HOST CONFIGURATION PROTOCOL

Chuẩn bị:

Máy 1: Linux, IP Address: 192.168.1.0/24
Máy 2: Windows, IP Address: 192.168.1.0/24

1. Cài và cấu hình DHCP server
Máy 1:

– Cài 2 gói: dhcp-3.0.5, dhcp-devel

#rpm -ivh /media/CentOS/dhcp-3.0.5-7.el5.i386.rpm
#rpm -ivh /media/CentOS/dhcp-devel-3.0.5-7.el5.i386.rpm

– Cấu hình

#vi /etc/dhcpd.conf                 //chưa có gì

– Copy file cấu hình mẩu vào /etc và cấu hình

#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf              //y: overwrite
#vi /etc/dhcpd.conf
          Từ dòng 4 đến dòng 31: cấu hình cho một subnet (scope), nếu muốn tạo thêm một subnet thì copy từ dòng 4 đến dòng 31  và cấu hình thêm trên subnet này. (shift:4,31t31)
      4 subnet 192.168.1.0 netmask 255.255.255.0 {
5
6 # — default gateway
7         option routers                  192.168.1.1;
8         option subnet-mask              255.255.255.0;
9
10         option nis-domain               “sinhvientot.net”;
11         option domain-name              “sinhvientot.net”;
12         option domain-name-servers      203.113.131.1;
13
14         option time-offset              -18000; # Eastern Standard Time
15 #       option ntp-servers              192.168.1.1;
16 #       option netbios-name-servers     192.168.1.1;
17 # — Selects point-to-point node (default is hybrid). Don’t change this unless
18 # — you understand Netbios very well
19 #       option netbios-node-type 2;
20
21         range dynamic-bootp 192.168.1.120 192.168.1.220;
22         default-lease-time 21600;
23         max-lease-time 43200;
24
25         # we want the nameserver to appear at a fixed address
26         host ns {
27                 next-server marvin.redhat.com;
28                 hardware ethernet 12:34:56:78:AB:CD;
29                 fixed-address 207.175.42.254;
30         }
31 }

– Restart servive
#service dhcpd restart
– Port dhcp
#netstat –anp | grep dhcpd
Máy 2:
– Đặt địa chỉ IP động

Ipconfig /release
Ipconfig /renew
Ipconfig /all

– Nếu Máy 2 là linux (cho nhận địa chỉ IP từ DHCP server):
#setup
Network configuration / eth0 / Use DHCP [*]
#service network restart
#ifconfig eth0                          //xem địa chỉ IP được cấp
Máy 1:
– Kiểm soát các địa chỉ IP đang cấp phát
#cat /var/lib/dhcpd/dhcpd.leases
2. Địa chỉ IP chỉ định
vd: Cấp địa IP 192.168.1.200 cho Máy 2
Máy 2

Ipconfig /all                  // để xem địa chỉ MAC

Máy 1

#vi /etc/dhcpd.conf
     25         # we want the nameserver to appear at a fixed address
26         host ns {
27                 next-server marvin.redhat.com;
28                 hardware ethernet 00:0c:29:91:08:b2;
29                 fixed-address 192.168.1.200;
30         }
31 }

Máy 2:
– Đặt địa chỉ IP động

Ipconfig /release
Ipconfig /renew
Ipconfig /all

This site uses Akismet to reduce spam. Learn how your comment data is processed.