Skip to content

network-utilities/iptables-insert-before-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Iptables Insert Before Logging

iptables-insert-before-logging.sh, contains a function inserts rules prior to logging rules or appends if no logging chain jumps where found.

The following covers how to install this branch as a submodule within your own project, and parameters that iptables-insert-before-logging.sh currently responds to.

Byte size of iptables-insert-before-logging.sh Open Issues Open Pull Requests Latest commits


Table of Contents


Quick Start

Bash Variables

_module_https_url='https://github.com/network-utilities/iptables-insert-before-logging.git'
_module_relative_path='modules/iptables-insert-before-logging'

Git Commands

cd "<your-git-project-path>"

git checkout master
git submodule add -b master --name iptables-insert-before-logging "${_module_https_url}" "${_module_relative_path}"

Edit Your ReadMe File

Suggested additions so everyone has a good time with submodules

Clone with the following to avoid incomplete downloads


    git clone --recurse-submodules <url-for-your-project>


Update/upgrade submodules via


    git submodule update --init --recursive --merge

Example Usage

Example of sourcing and utilize iptables_insert_before_logging features

example-usage.sh

#!/usr/bin/env bash


## Find true directory this script resides in
__SOURCE__="${BASH_SOURCE[0]}"
while [[ -h "${__SOURCE__}" ]]; do
    __SOURCE__="$(find "${__SOURCE__}" -type l -ls | sed -n 's@^.* -> \(.*\)@\1@p')"
done
__DIR__="$(cd -P "$(dirname "${__SOURCE__}")" && pwd)"


## Source module code within this script
source "${__DIR__}/modules/iptables-insert-before-logging/iptables-insert-before-logging.sh"

iptables -N some_chain
iptables_insert_before_logging -A OUTPUT -p tcp -j some_chain

Test that things work!

Commit and Push

git add .gitmodules
git add modules/iptables-insert-before-logging
git add README.md


git commit -F- <<'EOF'
:heavy_plus_sign: Adds network-utilities/iptables-insert-before-logging#1 submodule


**Edits**


- `README.md` file, documentation updates for submodules


**Additions**

- `.gitmodules` file, tracks other Git repository code utilized by this project

- `modules/iptables-insert-before-logging` submodule, Git tracked dependency
EOF


git push origin master

🎉 Excellent 🎉 your repository is now ready to begin unitizing code from this project!


Iptables Insert Before Logging API

Inserts iptables rules prior to any logging jumps, or append if no logging rules where defined.

Param Type Description
$@ list required iptables rules to insert

Returns: boolean, exit status of inserting iptables rules

Throws Parameter_Error: ipv4_range_from_address not provided any arguments, arguments are not defined

Example:

iptables_insert_before_logging '-A' 'OUTPUT' '-p' 'tcp' '-j' 'some_chain'
#> iptables -I 5 OUTPUT -p tcp -j some_chain

License

Iptables Insert Before Logging submodule quick start documentation
Copyright (C) 2019  S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
by `jesin`
on