G. Instalasi dan Konfigurasi DHCP Server

 

  1. Prerequisites (Prasyarat)
    1. Topologi Jaringan

       

    2. Konfigurasi Server dan Client

      Konfigurasi Server :
      --------------------------------------------------
      - Sistem Operasi        : Linux Debian 10 (Buster)
      - IP Address NIC 1      : DHCP Internet
      - Gateway               : DHCP Internet
      
      - Hostname              : ns100             (Gantilah angka 100 dengan nomer absen anda masing-masing)
      - Domain                : sekolah100.sch.id (Gantilah angka 100 dengan nomer absen anda masing-masing)
      - IP Address NIC 2      : 192.168.100.1/24  (Gantilah angka 100 dengan nomer absen anda masing-masing)
      
      
      Konfigurasi Client :
      --------------------------------------------------
      - Sistem Operasi        : Windows
      - IP Address            : DHCP

     

  2. Seting Server
     
    1. Konfigurasi Ethernet (Network Interface Card)

      Login sebagai user root

      ns100 login as: root
      password:
      
      Last login: Fri Jan 1 10:03:45 WIB 2021 on tty1
      Linux ns1 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64
      
      root@ns100:~#

       

      Seting IP Address

      root@ns100:~# nano /etc/network/interfaces
      
      # This file describes the network interfaces available on your system
      # and how to activate them. For more information, see interfaces(5).
      
      source /etc/network/interfaces.d/*
      
      # The loopback network interface
      auto lo
      iface lo inet loopback
      
      
      # The primary network interface
      auto ens33
      iface ens33 inet dhcp
      
      # The 2ndary network interface
      auto ens34
      iface ens34 inet static
              address 192.168.100.1/24
      root@ns100:~# reboot
      ns100 login as: root
      password:
      
      Last login: Fri Jan 1 10:10:25 WIB 2021 on tty1
      Linux ns1 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64
      
      root@ns100:~#
      root@ns100:~# ip a
      
      1: lo: (LOOPBACK,UP,LOWER_UP) mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host
             valid_lft forever preferred_lft forever
      2: ens33: (BROADCAST,MULTICAST,UP,LOWER_UP) mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
          link/ether 00:0c:29:48:5a:f1 brd ff:ff:ff:ff:ff:ff
          inet 192.168.16.130/24 brd 192.168.16.255 scope global ens33
             valid_lft forever preferred_lft forever
          inet6 fe80::20c:29ff:fe48:5af1/64 scope link
             valid_lft forever preferred_lft forever
      3: ens34: (BROADCAST,MULTICAST,UP,LOWER_UP) mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
          link/ether 00:0c:29:48:5a:fb brd ff:ff:ff:ff:ff:ff
          inet 192.168.100.1/24 brd 192.168.100.255 scope global ens34
             valid_lft forever preferred_lft forever
          inet6 fe80::20c:29ff:fe48:5afb/64 scope link
             valid_lft forever preferred_lft forever

       

      Pastikan server sudah terhubung ke internet, lakukan ping ke google.com

      root@ns100:/# ping google.com
      
      PING google.com (172.217.194.102) 56(84) bytes of data.
      64 bytes from 172.217.194.102: icmp_seq=1 ttl=128 time=26.1 ms
      64 bytes from 172.217.194.102: icmp_seq=2 ttl=128 time=26.0 ms
      64 bytes from 172.217.194.102: icmp_seq=3 ttl=128 time=25.4 ms
      64 bytes from 172.217.194.102: icmp_seq=4 ttl=128 time=25.3 ms
      64 bytes from 172.217.194.102: icmp_seq=5 ttl=128 time=150 ms
      64 bytes from 172.217.194.102: icmp_seq=6 ttl=128 time=215 ms
      64 bytes from 172.217.194.102: icmp_seq=7 ttl=128 time=25.3 ms
      ^C
      --- google.com ping statistics ---
      7 packets transmitted, 7 received, 0% packet loss, time 689ms
      rtt min/avg/max/mdev = 25.278/70.537/215.227/73.102 ms

       

    2. Konfigurasi Repository

      Kita gunakan server repository SMK Negeri 1 Klaten

      root@ns100:/# nano /etc/apt/sources.list
      		  
      # deb cdrom:[Debian GNU/Linux 10.6.0 _Buster_ - Official amd64 DVD Binary-1 20190706-10:24]/ buster contrib main
      # deb cdrom:[Debian GNU/Linux 10.6.0 _Buster_ - Official amd64 DVD Binary-1 20190706-10:24]/ buster contrib main
      
      #deb http://security.debian.org/debian-security buster/updates main contrib
      #deb-src http://security.debian.org/debian-security buster/updates main contrib
      
      # buster-updates, previously known as 'volatile'
      # A network mirror was not selected during install.  The following entries
      # are provided as examples, but you should amend them as appropriate
      # for your mirror of choice.
      #
      # deb http://deb.debian.org/debian/ buster-updates main contrib
      # deb-src http://deb.debian.org/debian/ buster-updates main contrib
      
      deb http://mirror.smkn1klaten.sch.id/debian/ buster main contrib non-free
      deb-src http://mirror.smkn1klaten.sch.id/debian/ buster main contrib non-free
      
      deb http://mirror.smkn1klaten.sch.id/debian/ buster-updates main contrib non-free
      deb-src http://mirror.smkn1klaten.sch.id/debian/ buster-updates main contrib non-free
      
      deb http://mirror.smkn1klaten.sch.id/debian-security buster/updates main contrib
      deb-src http://mirror.smkn1klaten.sch.id/debian-security buster/updates main contrib	  
      		  
      root@ns100:/# apt update
      		  
      Ign:1 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  InRelease
      Ign:2 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Release
      Ign:3 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Packages
      Ign:4 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Translation-en
      Ign:5 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Translation-en_US
      Ign:3 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Packages
      Ign:4 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Translation-en
      Ign:5 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Translation-en_US
      Ign:3 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  Packages
      Reading package lists... Done
      Building dependency tree
      Reading state information... Done
      		  

       

    3. Konfigurasi Network Address Translation (NAT)
      root@ns100:/# apt -y install iptables-persistent

      After this operation, 80.9 kB of additional disk space will be used.
      Get:1 http://repo.smkn1klaten.sch.id/debian/buster/amd64  netfilter-persistent 1.0.11 [10.1 kB]
      Get:2 http://repo.smkn1klaten.sch.id/debian/buster/amd64  iptables-persistent 1.0.11 [11.7 kB]
      Fetched 21.8 kB in 0s (413 kB/s)
      Preconfiguring packages ...
      Selecting previously unselected package netfilter-persistent.
      (Reading database ... 27449 files and directories currently installed.)
      Preparing to unpack .../netfilter-persistent_1.0.11_all.deb ...
      Unpacking netfilter-persistent (1.0.11) ...
      Selecting previously unselected package iptables-persistent.
      Preparing to unpack .../iptables-persistent_1.0.11_all.deb ...
      Unpacking iptables-persistent (1.0.11) ...
      Setting up netfilter-persistent (1.0.11) ...
      Created symlink /etc/systemd/system/multi-user.target.wants/netfilter-persistent.service → /lib/systemd/system/netfilter-persistent.service.
      Setting up iptables-persistent (1.0.11) ...
      Processing triggers for man-db (2.8.5-2) ...
      Processing triggers for systemd (241-5) ...

       

      root@ns100:~# systemctl is-enabled netfilter-persistent.service
      
      enabled
      root@ns100:~# systemctl enable netfilter-persistent.service
      
      Synchronizing state of netfilter-persistent.service with SysV service script with /lib/systemd/systemd-sysv-install.
      Executing: /lib/systemd/systemd-sysv-install enable netfilter-persistent
      root@ns100:~# systemctl status netfilter-persistent.service
      
       netfilter-persistent.service - netfilter persistent configuration
         Loaded: loaded (/lib/systemd/system/netfilter-persistent.service; enabled; vendor preset: enabled)
         Active: active (exited) since Sun 2021-01-03 10:09:45 WIB; 8min ago
       Main PID: 884 (code=exited, status=0/SUCCESS)
          Tasks: 0 (limit: 2331)
         Memory: 0B
         CGroup: /system.slice/netfilter-persistent.service
      
      root@ns100:~# nano /etc/sysctl.conf
      
      # Uncomment the next line to enable packet forwarding for IPv4
      #net.ipv4.ip_forward=1
      
      net.ipv4.ip_forward=1
      
      # Uncomment the next line to enable packet forwarding for IPv6
      #  Enabling this option disables Stateless Address Autoconfiguration
      #  based on Router Advertisements for this host
      #net.ipv6.conf.all.forwarding=1
      
      root@ns100:~# sysctl -p
      
      net.ipv4.ip_forward=1
      
      root@ns100:~# iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE
      
      root@ns100:~# iptables -t nat -L
      
      Chain PREROUTING (policy ACCEPT)
      target     prot opt source               destination
      
      Chain INPUT (policy ACCEPT)
      target     prot opt source               destination
      
      Chain POSTROUTING (policy ACCEPT)
      target     prot opt source               destination
      MASQUERADE  all  --  anywhere             anywhere
      
      Chain OUTPUT (policy ACCEPT)
      target     prot opt source               destination			
      
      root@ns100:~# iptables-save > /etc/iptables/rules.v4
      
      root@ns100:~# reboot	
      

       

    4. Install dan Konfigurasi DHCP Server
       

      Install paket DHCP server

      root@ns100:~# apt -y install isc-dhcp-server
      
      Reading package lists... Done
      Building dependency tree
      Reading state information... Done
      The following additional packages will be installed:
        libirs-export161 libisccfg-export163 policycoreutils selinux-utils
      Suggested packages:
        policykit-1 isc-dhcp-server-ldap
      The following NEW packages will be installed:
        isc-dhcp-server libirs-export161 libisccfg-export163 policycoreutils selinux-utils
      0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
      Need to get 1,615 kB of archives.
      After this operation, 6,539 kB of additional disk space will be used.
      Do you want to continue? [Y/n] y
      Get:1 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  libisccfg-export163 1:9.11.5.P4+dfsg-5.1 [263 kB]
      Get:2 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  libirs-export161 1:9.11.5.P4+dfsg-5.1 [236 kB]
      Get:3 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  isc-dhcp-server 4.4.1-2 [548 kB]
      Get:4 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  selinux-utils 2.8-1+b1 [101 kB]
      Get:5 http://mirror.smkn1klaten.sch.id/debian/buster/amd64  policycoreutils 2.8-1 [467 kB]
      Fetched 1,615 kB in 2s (1,006 kB/s)
      Preconfiguring packages ...
      Generating /etc/default/isc-dhcp-server...
      Job for isc-dhcp-server.service failed because the control process exited with error code.
      See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
      invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
       isc-dhcp-server.service - LSB: DHCP server
         Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
         Active: failed (Result: exit-code) since ..
           Docs: man:systemd-sysv-generator(8)
        Process: 1234 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
      

       

      Memilih ethernet yang akan digunakan untuk mendistribusikan sistem DHCP ke client.

      root@ns100:~# nano /etc/default/isc-dhcp-server
      
      # Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
      
      # Additional options to start dhcpd with.
      #       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
      #OPTIONS=""
      
      # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
      #       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
      #INTERFACESv4=""
      #INTERFACESv6=""
      
      INTERFACESv4="ens34"
      

       

      Konfigurasi DHCP Server (Ip Address, Subnetmask, Gateway, DNS) serta seting range IP Address yang akan di distribusikan ke client.

      root@ns100:~# cat /etc/resolv.conf
      
      domain localdomain
      search localdomain
      nameserver 192.168.16.2
                  
      root@ns100:~# nano /etc/dhcp/dhcpd.conf
      
      # dhcpd.conf
      #
      # Sample configuration file for ISC dhcpd
      #
      
      # option definitions common to all supported networks...
      #option domain-name "example.org";
      #option domain-name-servers ns1.example.org, ns2.example.org;
      
      option domain-name "sekolah100.sch.id";
      option domain-name-servers 192.168.100.1, 192.168.16.2;
      
      default-lease-time 600;
      max-lease-time 7200;
      
      # The ddns-updates-style parameter controls whether or not the server will
      # attempt to do a DNS update when a lease is confirmed. We default to the
      # behavior of the version 2 packages ('none', since DHCP v2 didn't
      # have support for DDNS.)
      ddns-update-style none;
      
      # If this DHCP server is the official DHCP server for the local
      # network, the authoritative directive should be uncommented.
      #authoritative;
      authoritative;
      
      # Use this to send dhcp log messages to a different log file (you also
      # have to hack syslog.conf to complete the redirection).
      #
      #
      
      # A slightly different configuration for an internal subnet.
      #subnet 10.5.5.0 netmask 255.255.255.224 {
      #  range 10.5.5.26 10.5.5.30;
      #  option domain-name-servers ns1.internal.example.org;
      #  option domain-name "internal.example.org";
      #  option routers 10.5.5.1;
      #  option broadcast-address 10.5.5.31;
      #  default-lease-time 600;
      #  max-lease-time 7200;
      #}
      
      # A slightly different configuration for an internal subnet.
      subnet 192.168.100.0 netmask 255.255.255.0 {
        range 192.168.100.10 192.168.100.30;
        option domain-name-servers 192.168.100.1, 192.168.16.2;
        option domain-name "sekolah100.sch.id";
        option routers 192.168.100.1;
        option broadcast-address 192.168.100.255;
        default-lease-time 600;
        max-lease-time 7200;
      }
      
      #
      

       

      Restart service DHCP Server

      root@ns100:~# /etc/init.d/isc-dhcp-server restart
      [ ok ] Restarting isc-dhcp-server (via systemctl): isc-dhcp-server.service.

       

       

  3. Seting Client

     

     

  4. Pengujian

    Menggunakan perintah ping

    C:\> 192.168.100.1
    
    Pinging 192.168.100.1 with 32 bytes of data:
    
    Reply from 192.168.100.1: bytes=32 time=1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time=1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time=1ms TTL=64
    Reply from 192.168.100.1: bytes=32 time=1ms TTL=64
    
    Ping statistics for 192.168.100.1:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 1ms, Average = 0ms
    
    C:\> 192.168.16.2
    
    Pinging 192.168.16.2 with 32 bytes of data:
    
    Reply from 192.168.16.2: bytes=32 time=1ms TTL=127
    Reply from 192.168.16.2: bytes=32 time=1ms TTL=127
    Reply from 192.168.16.2: bytes=32 time=1ms TTL=127
    Reply from 192.168.16.2: bytes=32 time=1ms TTL=127
    
    Ping statistics for 192.168.16.2:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 1ms, Average = 0ms
    
    C:\> google.com
    
    Pinging google.com [74.125.24.138] with 32 bytes of data:
    
    Reply from 74.125.24.138: bytes=32 time=24ms TTL=127
    Reply from 74.125.24.138: bytes=32 time=27ms TTL=127
    Reply from 74.125.24.138: bytes=32 time=26ms TTL=127
    Reply from 74.125.24.138: bytes=32 time=26ms TTL=127
    
    Ping statistics for 74.125.24.138:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 24ms, Maximum = 27ms, Average = 25ms
    
    C:\> detik.com
    
    Pinging detik.com [203.190.242.211] with 32 bytes of data:
    
    Reply from 203.190.242.211: bytes=32 time=14ms TTL=127
    Reply from 203.190.242.211: bytes=32 time=15ms TTL=127
    Reply from 203.190.242.211: bytes=32 time=15ms TTL=127
    Reply from 203.190.242.211: bytes=32 time=21ms TTL=127
    
    Ping statistics for 203.190.242.211:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 14ms, Maximum = 21ms, Average = 16ms
    
    

     

    Menggunakan Browser

     

     

  5. Kesimpulan

    Selamat! akhirnya kita telah belajar dan berhasil melakukan instalasi dan konfigurasi layanan DHCP Server.

    Semoga bermanfaat.