title: grab the default gateway sh script error
body: <p>I make the script for monitoring the MAC address of the default gateway and alerts if found ARP attack. But i got some error in the execution.</p>
  
  <p>I cant return the results with te regular expressions. 
  This is for linux scripts</p>
  
  <pre><code>#!/bin/bash
  function getmac {
  dg = netstat -rn | grep -Eo 'default.*([0-9]{1,3}\.){3}[0-9]{1,3}'  #grab the default gateway (DG)
  dg_ip= $dg | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'         #strip the DG to just IP
  dg_arp = arp -a | grep -w $dg_ip                                    #grab the arp entry for DG
  dg_mac=$(echo $dg_arp | grep -Eo '[0-9a-f]{1,2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}[:-][0-9a-f]{2}') #strip the ARP entry to just the MAC
  echo "netstat shows "$dg
  echo "DG IP shows "$dg_ip
  echo "arp shows "$dg_arp
  echo "DG MAC shows "$dg_mac
  }
  </code></pre>
  
  <p>Thanks in advance and sorry from my english.</p>