-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jamie Cockburn
committed
Nov 22, 2018
1 parent
091f851
commit c439c16
Showing
15 changed files
with
209 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ docs/_build/ | |
|
||
# PyBuilder | ||
target/ | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
from pyptables import default_tables, restore | ||
from pyptables.rules import Rule, Accept | ||
|
||
# get a default set of tables and chains | ||
tables = default_tables() | ||
|
||
# get the forward chain of the filter tables | ||
forward = tables['filter']['FORWARD'] | ||
|
||
# any packet matching an established connection should be allowed | ||
forward.append(Accept(match='conntrack', ctstate='ESTABLISHED')) | ||
|
||
# add rules to the forward chain for DNS, HTTP and HTTPS ports | ||
forward.append(Accept(proto='tcp', dport='53')) | ||
forward.append(Accept(proto='tcp', dport='80')) | ||
forward.append(Accept(proto='tcp', dport='443')) | ||
|
||
# any packet not matching a rules will be dropped | ||
forward.policy = Rule.DROP | ||
|
||
# write the rules into the kernel | ||
restore(tables) | ||
|
||
print tables.to_iptables() | ||
from pyptables import default_tables, restore | ||
from pyptables.rules import Rule, Accept | ||
|
||
# get a default set of tables and chains | ||
tables = default_tables() | ||
|
||
# get the forward chain of the filter tables | ||
forward = tables['filter']['FORWARD'] | ||
|
||
# any packet matching an established connection should be allowed | ||
forward.append(Accept(match='conntrack', ctstate='ESTABLISHED')) | ||
|
||
# add rules to the forward chain for DNS, HTTP and HTTPS ports | ||
forward.append(Accept(proto='tcp', dport='53')) | ||
forward.append(Accept(proto='tcp', dport='80')) | ||
forward.append(Accept(proto='tcp', dport='443')) | ||
|
||
# any packet not matching a rules will be dropped | ||
forward.policy = Rule.DROP | ||
|
||
# write the rules into the kernel | ||
restore(tables) | ||
|
||
print(tables.to_iptables()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ | |
if '--line-numbers' in sys.argv: | ||
output = add_line_numbers(output) | ||
|
||
print output | ||
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
rules for iptables. | ||
""" | ||
|
||
from base import InputRule | ||
from pyptables.rules.input.base import InputRule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.