Help

Keeping ebtables Rules After a Reboot

  1. Make sure the iptables-persistent package is installed on your system. If it is not, install it with the following command (for Debian/Ubuntu):
    sudo apt-get install iptables-persistent
    or for RHEL/CentOS/Fedora:
    sudo yum install iptables-services
  2. Create the /etc/ebtables directory if it does not exist yet:
    sudo mkdir -p /etc/ebtables
  3. Create a rules file in the /etc/ebtables directory:
    sudo touch /etc/ebtables/rules
  4. Save the current ebtables rules to the file:
    sudo ebtables-save > /etc/ebtables/rules
  5. Create a new systemd service file (for example, /etc/systemd/system/ebtables.service) with the following contents:
    [Unit]
    Description=Ebtables rules loader
    After=network.target
    
    [Service]
    Type=oneshot
    ExecStart=/sbin/ebtables-restore /etc/ebtables/rules
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
  6. Reload the systemd configuration and enable the new service:
    sudo systemctl daemon-reload
    sudo systemctl enable ebtables.service
  7. Check that the service works correctly by starting it manually:
    sudo systemctl start ebtables.service

Have more questions about Hosting?