Shell script to reset ebtables on Linux

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:

# 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 ***]----#
# 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
  echo "Accepting $p"
for T in filter nat broute
        echo "Flushing and deleting $T..."
        $EBT -t $T -F
        $EBT -t $T -X
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics via:
Category List of Unix and Linux commands
Disk space analyzers ncdu pydf
File Management cat
Firewall Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities NetHogs dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN Alpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • RfromApple Mar 29, 2017 @ 18:55

    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.

  • Tony Feb 21, 2017 @ 12:17

    Awesome work. thanks!

  • Tony Feb 1, 2017 @ 19:43

    Use pf. This is just bad.

  • c1b3rh4ck Sep 6, 2016 @ 1:47

    Cool thanks for share, but I was wondering in what case Do you use ebtables, at practical level.


    • 🐧 Vivek Gite Sep 7, 2016 @ 6:57

      If you setup bridge on Linux, you need to use this tool to block or allow traffic. Typically bridges includes your wireless wifi or virtual machines.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.