Shell script to reset ebtables on Linux

in Categories Firewall last updated September 5, 2016

Ebtables is an application program used to set up and maintain the tables of rules (inside the Linux kernel) that inspect Ethernet frames. It is analogous to the iptables application, but less complicated, due to the fact that the Ethernet protocol is much simpler than the IP protocol. ebtables used with bridges on Linux. The following script will stop and clean all ebtables rules:

#!/bin/bash
# A simple shell script to remove all ebtables rules
# Tested on : Debian and Ubuntu servers.
# ----------------------------------------------------------------------------
# Author: Vivek Gite 
# Copyright: 2016 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated 05 Sep 2016
# ----------------------------------------------------------------------------
#----[*** verify me ***]----#
EBT=/sbin/ebtables
 
# die if ebtables not found
[[ -x "$EBT" ]] || { echo "$0: error \"$EBT\" not found."; exit 1; }
 
# die if we are not root
[[ "$(id -u)" != "0" ]] && { echo "Error: $0 script must be run as root." 2>&1; exit 2; }
 
# Let us start
for p in INPUT FORWARD OUTPUT
do
  echo "Accepting $p"
  $EBT -P $p ACCEPT
done
for T in filter nat broute
do
        echo "Flushing and deleting $T..."
        $EBT -t $T -F
        $EBT -t $T -X
done

Share this on:

5 comment

  1. Yup. Thanks for the script. I was messing around my CentOS server and this script helped me to reset till I get everything correct for my setup.

Leave a Comment