Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    PfSense 2.1.5 için 5651 Log Tutma

    Scheduled Pinned Locked Moved Turkish
    2 Posts 2 Posters 1.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Q
      Qbilay
      last edited by

      Merhaba arkadaslar.

      Başlıkta da belirttigim gibi 2.1.5 için kurulum ve ayarlarinin basit oldugunu dusundugum 5651 loglamasini anlatmaya calisacagim.

      Oncelikle cok fazla vaktim olmamasindan kurulum ve yapilandirmada goresel ekleyemedim.

      Sistemde Cron disinda bir eklenti olmadigi icin kullanilan paketlerde veya sonradan kurulabilecek paketlerde bir sorun olup olmayacagi konusunda su an icin bir fikir sahibi degilim. Karsilasilan problem veya sorunlar bu baslik altinda paylasilirsa cozume daha kolay olunur dusuncesindeyim.

      Sozu fazla uzatmadan;

      2.1.5

      Kurulumdan sonra

      System_Advanced altindan SSH (Secure Shell Server) aktif hale getirelim.

      putty ile pfSense e baglanalim

      Samba Client kuralim

      pkg_add -r http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.3-release/net/samba36-smbclient-3.6.3.tbz

      5651.sh dosyasinin icerigini asagidaki gibi olusturalim

      /sbin/5651.sh

      #=======================================================================================

      DosyaTarih=date "+%d.%m.%Y-%H%M"
      Tarih=date "+%d.%m.%Y"
      SaatKontrol=date "+%H%M"
      GunSonu=2355
      cd /var/log/5651/Raporlar
      sh /sbin/5651RaporHazirla.sh > IP-MAC-$DosyaTarih.txt
      if [ $SaatKontrol == $GunSonu ]
      then
      cd /var/log/5651
      tar -zcvf 5651-Arsiv-$Tarih.tar.gz Raporlar/
      cd Raporlar
      rm *.txt
      cd ..
      /usr/local/bin/smbclient \\XXX.XXX.XXX.XXX\YYYY -U QQQQ%WWWW -W -N -c "prompt; put 5651-Arsiv-$Tarih.tar.gz"
      fi

      #==========================================================================================

      5651RaporHazirla.sh dosyasinin icerigini asagidaki gibi olusturalim

      /sbin/5651RaporHazirla.sh

      #=========================================================================================

      #!/bin/sh

      dhcpactiv.sh

      v.004

      - rewritten again to pull data from dhcpd files according to labels instead of position

      v.003

      - add code to remove tstp information from dpcpd.leases

      v.002

      - rewritten to use awk more for parsing

      - added "GMT" indicator to Expiration col head

      echo "                                                                                "
      echo "                  BAŞLANGIÇ            BİTİŞ                                  "
      echo " IP Adresi        Tarih      Saat      Tarih      Saat      MAC Adresi        "
      echo "================= ===================== ===================== ==================="

      awk ' { out = ""}
            { $1=="lease"||$1=="client-hostname" ? out=" " $2 : out=out }
            { $1=="starts"? out=" " $3 " " $4: out=out }
        { $1=="ends"? out=" " $3 " " $4: out=out }
        { $1=="binding"||$1=="hardware" ? out= " " $3: out=out }
            { $1=="}"? out="\n": out=out }
            { printf out," " }' /var/dhcpd/var/db/dhcpd.leases
        | grep active
        | sed -e s/'[{};" ]'/\ /g 
        | awk '{ printf "%-19s %-22s %-22s %-15s %-10s %-5s\n", $1, $2, $3, $5, "", "" }'

      Now do the same for /etc/dhcpd.conf

      echo "                                                                                "
      echo " STATİK TANIMLI IP ADRESLERİ                                                    "
      echo " IP Adresi        MAC Adresi                                                    "
      echo "================= ===================                                            "

      awk ' { out = ""}
            { $1=="host"||$1=="fixed-address" ? out=" " $2 : out=out }
            { $1=="hardware" ? out= " " $3: out=out }
            { $1=="}"? out="\n": out=out }
            { printf out," " }' /var/dhcpd/etc/dhcpd.conf
        | grep :
        | sed -e s/'[{};" ]'/\ /g 
        | awk  '{ printf "%-0s %-17s %-15s %-30s %-0s \n", "", $3, $2, "", ""}'

      Finally, grab the current arp table

      echo "                                                                                "
      echo " AKTİF BAĞLANTILAR                                                              "
      echo " IP Adresi        MAC Adresi                                                    "
      echo "================= ===================                                            "
      arp -a
        | sed -e s/'[(){};" ]'/\ /g 
        |  awk '{ printf "%-0s %-17s %-15s %-15s %-15s \n", "", $2, $4, "", ""}'

      #===========================================================================================

      Dosya izinlerini ayarlayalim

      cd /sbin
      chmod 0755 5651.sh
      chmod 0755 5651RaporHazirla.sh
      cd /var/log
      mkdir 5651
      chmod 0755 5651
      cd 5651
      mkdir Raporlar
      chmod 0755 Raporlar

      System_Packages Cron paketini kuralim

      Services_Cron altindan asagidaki gibi gorev olusturalim.

      Minute */5

      Hour *

      Day of the Month *

      Month of the Year *

      Day of the Week *

      User root

      Command /sbin/5651.sh

      Boylelikle her 5 dakikada bir betik calistirilarak /var/log/5651/Raporlar altina dosya olusturulacaktir.
      Gun sonunda (Saat 23:55 olarak ayarlanmistir) ise olusturulan bu dosyalar paketlenerek arsivlenecek XXX.XXX.XXX.XXX ip adresindeki YYYY paylasimina QQQQ kullanici adi ve WWWW sifresi ile baglanarak dosyayi gonderecektir.
      Gun sonunda hazirlanan dosya eger Windows bilgisayarda acilan paylasimin icersindeki bir klasore gonderilecekse;

      5651.sh dosyasinin icersindeki smbclient ile ilgili komutun sonuna "-D /KKKK" (KKKK=Klasor adi) eklenebilir

      /usr/local/bin/smbclient \\XXX.XXX.XXX.XXX\YYYY -U QQQQ%WWWW -W -N -c "prompt; put 5651-Arsiv-$Tarih.tar.gz" -D /KKKK

      Saygilar.

      5651.zip

      1 Reply Last reply Reply Quote 0
      • T
        tcjackal
        last edited by

        paylaşım için teşekkürler.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.