Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51ae4e37
authored
Feb 05, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: use vlan.name instead of vlan
parent
ef431d40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
circle/firewall/fw.py
+10
-8
No files found.
circle/firewall/fw.py
View file @
51ae4e37
...
...
@@ -59,11 +59,11 @@ class Firewall:
if
rule
.
direction
==
'1'
:
# going TO host
self
.
iptables
(
'-A
%
s_
%
s -d
%
s
%
s
%
s -g
%
s'
%
(
vlan
,
host
.
vlan
,
ipaddr
,
dport_sport
,
(
vlan
.
name
,
host
.
vlan
.
name
,
ipaddr
,
dport_sport
,
rule
.
extra
,
action
))
else
:
self
.
iptables
(
'-A
%
s_
%
s -s
%
s
%
s
%
s -g
%
s'
%
(
host
.
vlan
,
vlan
,
ipaddr
,
dport_sport
,
(
host
.
vlan
.
name
,
vlan
.
name
,
ipaddr
,
dport_sport
,
rule
.
extra
,
action
))
def
fw2vlan
(
self
,
rule
):
...
...
@@ -99,9 +99,10 @@ class Firewall:
if
rule
.
direction
==
'1'
:
# going TO host
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
vlan
,
l_vlan
,
dport_sport
,
rule
.
extra
,
action
))
(
vlan
.
name
,
l_vlan
.
name
,
dport_sport
,
rule
.
extra
,
action
))
else
:
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
l_vlan
,
vlan
,
self
.
iptables
(
'-A
%
s_
%
s
%
s
%
s -g
%
s'
%
(
l_vlan
.
name
,
vlan
.
name
,
dport_sport
,
rule
.
extra
,
action
))
...
...
@@ -223,10 +224,10 @@ class Firewall:
for
s_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
self
.
iptables
(
'-N
%
s_
%
s'
%
(
s_vlan
,
d_vlan
))
self
.
iptables
(
'-N
%
s_
%
s'
%
(
s_vlan
.
name
,
d_vlan
.
name
))
self
.
iptables
(
'-A FORWARD -i
%
s -o
%
s -g
%
s_
%
s'
%
(
s_vlan
.
name
,
d_vlan
.
name
,
s_vlan
,
d_vlan
))
(
s_vlan
.
name
,
d_vlan
.
name
,
s_vlan
.
name
,
d_vlan
.
name
))
def
ipt_filter_host_rules
(
self
):
"""Build hosts' rules."""
...
...
@@ -251,7 +252,8 @@ class Firewall:
for
s_vlan
in
self
.
vlans
:
for
d_vlan
in
self
.
vlans
:
self
.
iptables
(
'-A
%
s_
%
s -g LOG_DROP'
%
(
s_vlan
,
d_vlan
))
self
.
iptables
(
'-A
%
s_
%
s -g LOG_DROP'
%
(
s_vlan
.
name
,
d_vlan
.
name
))
def
__init__
(
self
,
proto
=
4
):
self
.
RULES
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment