#!/usr/bin/perl

### Skrypt do mac listy :)
### wykonany przez dhapollo
### Mozna wykozystać pozostawiajac powuższe nagłówki :)



  $lp = 1;


open (PLIK_MAC, "/etc/serwer/mac/mac.list") or die "open $alert_file: $!\n";
{
  sleep 1;
    if (seek(PLIK_MAC,0,1))
      {

          print "--------------------------------------------- \n";
          print "                 Przypisanie MAC >>> IP \n";
          print "--------------------------------------------- \n";

    while (<PLIK_MAC>)
        {
    chop;
  next if (/^\s*$/); # wyjazd z pustymi liniami
  next if (/^#/);    # wyjazd z #
     if (/(\d+\.\d+\.\d+\.\d+) \; (\S+) \; (\S+)/)
        {

  print " $lp -> Nazwa: $3 IP:$1 MAC: $2 \n";
  system "iptables -A MACCONTROL -s $1 -m mac --mac-source $2 -j ACCEPT";
  $lp = $lp + 1;
}

} # end while
     } # end if seek
 } # end for

close PLIK_MAC;
