Pagine

Linux - 1/2 - Installare un Server DHCP su Linux Centos

Procedura veloce per installare un server DHCP

1) yum -y install dhcp

2) cp -f /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf


3) vi /etc/dhcpd.conf




    # line 4: specify your network and subnetmask

    subnet

    192.168.91.0
     netmask
    255.255.255.0
     {
    # line 7 : specify default gateway

    option routers

    192.168.91.2
    ;


    # line 8: specify subnetmask

    option subnet-mask

    255.255.255.0
    ;


    # line 10: specify NIS domain name iy you using.
    # make it comment if you don not use.

    option nis-domain

    "instyle.locale"
    ;


    # line 11: specify domain name

    option domain-name

    "instyle.locale"
    ;


    # line 12: specify IP address of DNS nel caso che il server faccia anche da dns

    option domain-name-servers

    192.168.91.20
    ;


    # line 14: make it comment


    #
    option time-offset
    -18000;


    # line 21: specify the range of IP addresses for clients

    range dynamic-bootp

    192.168.91.128 192.168.91.254
    ;


    # line 22: default's terms of lease

    default-lease-time

    21600
    ;


    # line 23: maximun terms of lease

    max-lease-time

    43200
    ;


    # line 26: make following lines comment
   
    #
    host ns {
   
    #
    next-server marvin.redhat.com;


    #
    hardware ethernet 12:34:56:78:AB:CD;


    #
    fixed-address 207.175.42.254;


    #
    }


4) /etc/init.d/dhcpd start

    Starting dhcpd:
    [  OK  ]

5) Aprire la porta del firewall, si tratta della porta 67 UDP dopo il daemon DHCP sta in listening.


6) Il DHCP risponde sulla porta 68 UDP


7) chkconfig dhcpd on

8) Ecco delle opzioni suppletive:

ddns-update-style interim

subnet 192.168.1.0 netmask 255.255.255.0 {
                               option subnet-mask 255.255.255.0;
                               option broadcast-address 192.168.1.255; ip di broadcast
                               option routers 192.168.1.1;
                               default-lease-time 600;
                               max-lease-time 604800;
                               option domain-name "example.com"; dominio da passare ai client
                               option domain-name-servers 192.168.1.1, 192.168.1.2;
                               option time-offset 7200;
                               option ntp-servers 192.168.1.1; Time Server
                               range 192.168.1.100 192.168.1.200;

                               #sezione per definire IP statici
                               host server1 {
                                                        hardware ethernet 00:00:00:12:34:AB;
                                                        fixed-address 192.168.1.10;
                                                       } 
                               #in questo caso passiamo dei parametri specifici
                               host server2 {
                                                        hardware ethernet 00:00:00:23:45:EF;
                                                        fixed-address 192.168.1.11;
                                                        option host-name "web1.servers.example.com";
                                                        option domain-name "servers.example.com";
                                                        }
}

9) si possono definire dei gruppi specifici:


ddns-update-style interim

subnet 192.168.1.0 netmask 255.255.255.0 {
                               option subnet-mask 255.255.255.0;
                               option broadcast-address 192.168.1.255; ip di broadcast
                               option routers 192.168.1.1;
                               default-lease-time 600;
                               max-lease-time 604800;
                               option domain-name "example.com"; dominio da passare ai client
                               option domain-name-servers 192.168.1.1, 192.168.1.2;
                               option time-offset 7200;
                               option ntp-servers 192.168.1.1; Time Server
                               range 192.168.1.100 192.168.1.200;
group {
            option domain-name "servers.example.com";
            option ntp-servers 192.168.1.5;
            host server1 {
                                     hardware ethernet 00:00:00:12:34:AB;
                                     fixed-address 192.168.1.10;
                                     option host-name "db1.servers.example.com";
                                     }
            host server2 {
                                     hardware ethernet 00:00:00:23:45:EF;
                                     fixed-address 192.168.1.11;
                                     option host-name "web1.servers.example.com";
                                     }
}

10) Shared Network:

shared-network internal {
                                     option domain-name "test.example.com";
                                     option domain-name-servers 192.168.0.1;
                                     option routers 192.168.0.1;
                                     subnet 192.168.1.0 netmask 255.255.255.0 {
                                                                          range 192.168.1.100 192.168.1.200;
                                                                                                               }
                                     subnet 192.168.2.0 netmask 255.255.255.0 {
                                                                          range 192.168.2.100 192.168.2.200;
                                                                                                               }
                                     }
11) per testare che la sintassi del file sia corretta si usa:

service dhcpd configtest

12) per vedere se ci sono dei problemi andare a vedere i log creati in /var/log/messages

13) Nel caso in cui abbiamo piu' sottoreti una soluzione รจ settare un server dhcp per ogni lan oppure abilitare il DHCP Relayng su ogni singolo router

ddns-update-style interim;

subnet 192.168.1.0 netmask 255.255.255.0 {
                                                      option subnet-mask 255.255.255.0;                                                      option broadcast-address 192.168.1.255;                                                      option routers 192.168.1.1;                                                      default-lease-time 600;                                                      max-lease-time 604800;                                                      option domain-name "example.com";                                                      option domain-name-servers 192.168.1.1, 192.168.1.2;                                                      option time-offset 7200;                                                      option ntp-servers 192.168.1.1;                                                      range 192.168.1.100 192.168.1.200;                                                      }
subnet 192.168.2.0 netmask 255.255.255.0 {
                                                      option subnet-mask 255.255.255.0;                                                      option broadcast-address 192.168.2.255;                                                      option routers 192.168.2.1;                                                      default-lease-time 600;                                                      max-lease-time 604800;                                                      option domain-name "example.com";                                                      option domain-name-servers 192.168.2.1, 192.168.2.2;                                                      option time-offset 7200;                                                      option ntp-servers 192.168.2.1;                                                      range 192.168.2.100 192.168.2.200;                                                      }