Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
tun
Commits
4112314f
Commit
4112314f
authored
Jan 11, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some mini-router rules
parent
78d85e26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
ansible/migrate-mini-chnroute.yaml
ansible/migrate-mini-chnroute.yaml
+34
-0
ansible/scripts/global-postup.sh.j2
ansible/scripts/global-postup.sh.j2
+8
-1
src/inventory.ts
src/inventory.ts
+6
-1
No files found.
ansible/migrate-mini-chnroute.yaml
0 → 100644
View file @
4112314f
-
hosts
:
switch
remote_user
:
root
tasks
:
-
name
:
load vars
include_vars
:
file
:
'
../result/{{item}}.yaml'
with_items
:
-
global-vars
-
vars-{{inventory_hostname_short}}
-
name
:
post scripts
template
:
src
:
scripts/{{item}}.sh.j2
dest
:
'
{{ansible_user_dir}}/nextgen-network/scripts/{{item}}.sh'
mode
:
a+x
with_items
:
-
postup
-
predown
-
global-postup
-
utility
-
switch-rules-up
-
switch-rules-down
-
ocserv-postup
-
ocserv-predown
-
name
:
migrate
become
:
true
shell
:
|
{% for interface in masqInterfaces %}
iptables -t mangle -A NEXTGEN_ORIGIN -i {{item.name}} ! -p ospf -m set ! --match-set mycard src -j CONNMARK --set-xmark {{interface.mark}}
iptables -t mangle -A NEXTGEN_ORIGIN -m connmark --mark {{item.mark}} -j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff
iptables -t mangle -A OUTPUT -m connmark --mark {{item.mark}} -j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff
# TODO: ip rule
# ip rule add pref 300 fwmark {{item.mark}} lookup {{item.mark}}
{% endfor %}
with_items
:
'
{{masqInterfaces}}'
ansible/scripts/global-postup.sh.j2
View file @
4112314f
...
@@ -17,12 +17,19 @@ ip rule add pref 81 to {{subnet}} lookup main || true
...
@@ -17,12 +17,19 @@ ip rule add pref 81 to {{subnet}} lookup main || true
# MASQ interfaces
# MASQ interfaces
{
%
for
interface
in
masqInterfaces %
}
{
%
for
interface
in
masqInterfaces %
}
iptables
-t
nat
-A
POSTROUTING
-o
{{
interface
}}
-j
MASQUERADE
iptables
-t
nat
-A
POSTROUTING
-o
{{
interface
.name
}}
-j
MASQUERADE
{
% endfor %
}
{
% endfor %
}
# chain for wg origin
# chain for wg origin
iptables
-t
mangle
-N
NEXTGEN_ORIGIN
iptables
-t
mangle
-N
NEXTGEN_ORIGIN
iptables
-t
mangle
-I
PREROUTING
-m
mark
--mark
0x0
!
-p
ospf
-j
NEXTGEN_ORIGIN
iptables
-t
mangle
-I
PREROUTING
-m
mark
--mark
0x0
!
-p
ospf
-j
NEXTGEN_ORIGIN
{
%
for
interface
in
masqInterfaces %
}
iptables
-t
mangle
-A
NEXTGEN_ORIGIN
-i
{{
interface.name
}}
!
-p
ospf
-m
set
!
--match-set
mycard src
-j
CONNMARK
--set-xmark
{{
interface.mark
}}
iptables
-t
mangle
-A
NEXTGEN_ORIGIN
-m
connmark
--mark
{{
interface.mark
}}
-j
CONNMARK
--restore-mark
--nfmask
0xffffffff
--ctmask
0xffffffff
iptables
-t
mangle
-A
OUTPUT
-m
connmark
--mark
{{
interface.mark
}}
-j
CONNMARK
--restore-mark
--nfmask
0xffffffff
--ctmask
0xffffffff
# TODO: ip rule
# ip rule add pref 300 fwmark {{interface.mark}} lookup {{interface.mark}}
{
% endfor %
}
iptables
-t
mangle
-N
NEXTGEN_SWITCH
iptables
-t
mangle
-N
NEXTGEN_SWITCH
iptables
-t
mangle
-A
PREROUTING
-m
mark
--mark
0x0
!
-p
ospf
-m
set
!
--match-set
mycard dst
-j
NEXTGEN_SWITCH
iptables
-t
mangle
-A
PREROUTING
-m
mark
--mark
0x0
!
-p
ospf
-m
set
!
--match-set
mycard dst
-j
NEXTGEN_SWITCH
...
...
src/inventory.ts
View file @
4112314f
...
@@ -241,7 +241,12 @@ class InventoryBuilder {
...
@@ -241,7 +241,12 @@ class InventoryBuilder {
const
lanInterfaces
=
host
.
lanInterfaces
;
const
lanInterfaces
=
host
.
lanInterfaces
;
const
localSubnets
=
host
.
subnets
;
const
localSubnets
=
host
.
subnets
;
//console.log(localSubnets);
//console.log(localSubnets);
const
masqInterfaces
=
host
.
masqInterfaces
.
length
>
0
?
host
.
masqInterfaces
.
split
(
'
,
'
)
:
[];
const
masqInterfaces
=
host
.
masqInterfaces
.
length
>
0
?
(
host
.
masqInterfaces
as
string
).
split
(
'
,
'
).
map
((
interfaceName
,
interfaceIndex
)
=>
{
return
{
name
:
interfaceName
,
mark
:
1900
+
interfaceIndex
}
})
:
[];
const
routePlans
=
this
.
getRoutePlansFromGatewayGroups
(
host
);
const
routePlans
=
this
.
getRoutePlansFromGatewayGroups
(
host
);
for
(
const
h
of
this
.
connections
)
{
for
(
const
h
of
this
.
connections
)
{
...
...
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