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
2a1b4210
Commit
2a1b4210
authored
Dec 12, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add NEXTGEN_SWITCH
parent
5070a959
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
10 deletions
+28
-10
ansible/migrate-switch.yaml
ansible/migrate-switch.yaml
+16
-0
ansible/protocols/wg/wg.conf.j2
ansible/protocols/wg/wg.conf.j2
+1
-1
ansible/scripts/global-postup.sh.j2
ansible/scripts/global-postup.sh.j2
+3
-1
ansible/scripts/switch-rules-down.sh.j2
ansible/scripts/switch-rules-down.sh.j2
+2
-2
ansible/scripts/switch-rules-up.sh.j2
ansible/scripts/switch-rules-up.sh.j2
+2
-2
ansible/scripts/utility.sh.j2
ansible/scripts/utility.sh.j2
+4
-4
No files found.
ansible/migrate-switch.yaml
0 → 100644
View file @
2a1b4210
-
hosts
:
wg
remote_user
:
root
tasks
:
-
name
:
remove old rules
become
:
true
shell
:
'
{{ansible_user_dir}}/nextgen-network/scripts/switch-rules-down.sh'
-
name
:
install conntrack
become
:
true
apt
:
name
:
conntrack
-
name
:
future rules
become
:
true
shell
:
|
iptables -t mangle -N NEXTGEN_SWITCH
iptables -t mangle -A PREROUTING -m mark --mark 0x0 ! -p ospf -m set ! --match-set mycard src -j NEXTGEN_SWITCH
iptables -t mangle -I PREROUTING -m mark ! --mark 0x0 -j ACCEPT
ansible/protocols/wg/wg.conf.j2
View file @
2a1b4210
...
@@ -19,4 +19,4 @@ Endpoint = {{conn.remoteAddress}}:{{conn.remotePort}}
...
@@ -19,4 +19,4 @@ Endpoint = {{conn.remoteAddress}}:{{conn.remotePort}}
PersistentKeepalive = 1
PersistentKeepalive = 1
{% endif %}
{% endif %}
# forced change 12.1
1
2
# forced change 12.12
ansible/scripts/global-postup.sh.j2
View file @
2a1b4210
...
@@ -16,7 +16,9 @@ ip rule add pref 81 to {{subnet}} lookup main || true
...
@@ -16,7 +16,9 @@ ip rule add pref 81 to {{subnet}} lookup main || true
# chain for wg origin
# chain for wg origin
iptables
-t
mangle
-N
NEXTGEN_ORIGIN
iptables
-t
mangle
-N
NEXTGEN_ORIGIN
iptables
-t
mangle
-A
PREROUTING
!
-d
224.0.0.0/3
!
-p
ospf
-m
set
!
--match-set
mycard src
-j
NEXTGEN_ORIGIN
iptables
-t
mangle
-A
PREROUTING
-m
mark
--mark
0x0
!
-d
224.0.0.0/3
!
-p
ospf
-m
set
!
--match-set
mycard src
-j
NEXTGEN_ORIGIN
iptables
-t
mangle
-N
NEXTGEN_SWITCH
iptables
-t
mangle
-A
PREROUTING
-m
mark
--mark
0x0
!
-p
ospf
-m
set
!
--match-set
mycard src
-j
NEXTGEN_SWITCH
# switch rules
# switch rules
{{
ansible_user_dir
}}
/nextgen-network/scripts/switch-rules-up.sh
{{
ansible_user_dir
}}
/nextgen-network/scripts/switch-rules-up.sh
...
...
ansible/scripts/switch-rules-down.sh.j2
View file @
2a1b4210
...
@@ -20,10 +20,10 @@ interface_switch -D u_{{gw.isp}}_all {{gw.selectionMark}}
...
@@ -20,10 +20,10 @@ interface_switch -D u_{{gw.isp}}_all {{gw.selectionMark}}
## restore mark
## restore mark
{
%
for
plan
in
routePlans %
}
{
%
for
plan
in
routePlans %
}
ip rule del pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
ip rule del pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
restore_mark
-D
{{
plan.destMark
}}
restore_mark
_switch
-D
{{
plan.destMark
}}
{
% endfor %
}
{
% endfor %
}
{
%
for
gw
in
gateways %
}
{
%
for
gw
in
gateways %
}
restore_mark
-D
{{
gw.selectionMark
}}
restore_mark
_switch
-D
{{
gw.selectionMark
}}
{
% endfor %
}
{
% endfor %
}
true
true
ansible/scripts/switch-rules-up.sh.j2
View file @
2a1b4210
...
@@ -20,10 +20,10 @@ interface_switch -A u_{{gw.isp}}_all {{gw.selectionMark}}
...
@@ -20,10 +20,10 @@ interface_switch -A u_{{gw.isp}}_all {{gw.selectionMark}}
## restore mark
## restore mark
{
%
for
plan
in
routePlans %
}
{
%
for
plan
in
routePlans %
}
ip rule add pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
ip rule add pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
restore_mark
-A
{{
plan.destMark
}}
restore_mark
_switch
-A
{{
plan.destMark
}}
{
% endfor %
}
{
% endfor %
}
{
%
for
gw
in
gateways %
}
{
%
for
gw
in
gateways %
}
restore_mark
-A
{{
gw.selectionMark
}}
restore_mark
_switch
-A
{{
gw.selectionMark
}}
{
% endfor %
}
{
% endfor %
}
true
true
ansible/scripts/utility.sh.j2
View file @
2a1b4210
...
@@ -15,10 +15,10 @@ restore_mark_origin() {
...
@@ -15,10 +15,10 @@ restore_mark_origin() {
iptables -t mangle "$OPTION" OUTPUT -m connmark --mark "$MARK" -j CONNMARK --restore-mark
iptables -t mangle "$OPTION" OUTPUT -m connmark --mark "$MARK" -j CONNMARK --restore-mark
}
}
restore_mark() {
restore_mark
_switch
() {
OPTION=$1
OPTION=$1
MARK=$2
MARK=$2
iptables -t mangle "$OPTION"
PREROUTING
-m connmark --mark "$MARK" -j CONNMARK --restore-mark
iptables -t mangle "$OPTION"
NEXTGEN_SWITCH
-m connmark --mark "$MARK" -j CONNMARK --restore-mark
iptables -t mangle "$OPTION" OUTPUT -m connmark --mark "$MARK" -j CONNMARK --restore-mark
iptables -t mangle "$OPTION" OUTPUT -m connmark --mark "$MARK" -j CONNMARK --restore-mark
}
}
...
@@ -36,7 +36,7 @@ interface_switch() {
...
@@ -36,7 +36,7 @@ interface_switch() {
IPSET=$2
IPSET=$2
MARK=$3
MARK=$3
ipset create "$IPSET" hash:net maxelem 1000000 || true
ipset create "$IPSET" hash:net maxelem 1000000 || true
iptables -t mangle "$OPTION"
PREROUTING
-m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst -j CONNMARK --set-xmark "$MARK"
iptables -t mangle "$OPTION"
NEXTGEN_SWITCH
-m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst -j CONNMARK --set-xmark "$MARK"
}
}
interface_switch_chnroute() {
interface_switch_chnroute() {
...
@@ -44,5 +44,5 @@ interface_switch_chnroute() {
...
@@ -44,5 +44,5 @@ interface_switch_chnroute() {
IPSET=$2
IPSET=$2
MARK=$3
MARK=$3
ipset create "$IPSET" hash:net maxelem 1000000 || true
ipset create "$IPSET" hash:net maxelem 1000000 || true
iptables -t mangle "$OPTION"
PREROUTING
-m mark --mark 0 -m set --match-set "$IPSET" src -m set --match-set chnrouter dst -j CONNMARK --set-xmark "$MARK"
iptables -t mangle "$OPTION"
NEXTGEN_SWITCH
-m mark --mark 0 -m set --match-set "$IPSET" src -m set --match-set chnrouter dst -j CONNMARK --set-xmark "$MARK"
}
}
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