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
7ce44dfb
Commit
7ce44dfb
authored
Apr 13, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use china and oversea ipset instead
parent
0c7baac2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
19 deletions
+15
-19
ansible/scripts/switch-rules-up.sh.j2
ansible/scripts/switch-rules-up.sh.j2
+5
-17
ansible/scripts/utility.sh.j2
ansible/scripts/utility.sh.j2
+10
-2
No files found.
ansible/scripts/switch-rules-up.sh.j2
View file @
7ce44dfb
#!/bin/bash
#!/bin/bash
source
{{
ansible_user_dir
}}
/nextgen-network/scripts/utility.sh
source
{{
ansible_user_dir
}}
/nextgen-network/scripts/utility.sh
## route plans chnroute
{
%
for
plan
in
routePlans %
}
ip rule add pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
interface_switch_chnroute
-A
u_
{{
plan.name
}}
_chnroute
{{
plan.destMark
}}
restore_mark_switch
-A
{{
plan.destMark
}}
{
% endfor %
}
## local gateways chnroute
{
%
for
gw
in
gateways %
}
{
%
if
gw.selectionMark
>
0 %
}
interface_switch_chnroute
-A
u_
{{
gw.isp
}}
_chnroute
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
{
% endif %
}
{
% endfor %
}
## route plans
## route plans
{
%
for
plan
in
routePlans %
}
{
%
for
plan
in
routePlans %
}
interface_switch
-A
u_
{{
plan.name
}}
_all
{{
plan.destMark
}}
ip rule add pref 400 fwmark
{{
plan.destMark
}}
lookup
{{
plan.destMark
}}
interface_switch_china
-A
u_
{{
plan.name
}}
_china
{{
plan.destMark
}}
interface_switch_oversea
-A
u_
{{
plan.name
}}
_oversea
{{
plan.destMark
}}
restore_mark_switch
-A
{{
plan.destMark
}}
restore_mark_switch
-A
{{
plan.destMark
}}
{
% endfor %
}
{
% endfor %
}
## local gateways
## local gateways
{
%
for
gw
in
gateways %
}
{
%
for
gw
in
gateways %
}
{
%
if
gw.selectionMark
>
0 %
}
{
%
if
gw.selectionMark
>
0 %
}
interface_switch-A u_
{{
gw.isp
}}
_all
{{
gw.selectionMark
}}
interface_switch_china
-A
u_
{{
gw.isp
}}
_china
{{
gw.selectionMark
}}
interface_switch_oversea
-A
u_
{{
gw.isp
}}
_oversea
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
{
% endif %
}
{
% endif %
}
{
% endfor %
}
{
% endfor %
}
...
...
ansible/scripts/utility.sh.j2
View file @
7ce44dfb
...
@@ -52,10 +52,18 @@ interface_switch() {
...
@@ -52,10 +52,18 @@ interface_switch() {
$IPTABLES_EXEC -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"
$IPTABLES_EXEC -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_ch
nroute
() {
interface_switch_ch
ina
() {
OPTION=$1
OPTION=$1
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_EXEC -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"
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst ! -m set --match-set chnrouter dst -j CONNMARK --set-xmark "$MARK"
}
interface_switch_oversea() {
OPTION=$1
IPSET=$2
MARK=$3
ipset create "$IPSET" hash:net maxelem 1000000 || true
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst -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