联动 IPrule规则
This commit is contained in:
47
ip-policy-rules
Normal file
47
ip-policy-rules
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="Custom IP Policy Route Rules for Alpine"
|
||||
|
||||
depend() {
|
||||
need net networking
|
||||
after net-online
|
||||
trigger on restart networking
|
||||
}
|
||||
|
||||
trigger() {
|
||||
case "$1" in
|
||||
restart)
|
||||
ebegin "Triggered by networking restart, reloading IP policy rules"
|
||||
restart
|
||||
eend $?
|
||||
;;
|
||||
*)
|
||||
ebegin "Unsupported trigger: $1"
|
||||
eend 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Loading custom IP policy rules"
|
||||
ip rule add from 44.32.191.0/24 to 0.0.0.0/0 lookup 102 priority 200
|
||||
ip rule add from 172.20.0.0/14 to 172.20.0.0/14 lookup 105 priority 300
|
||||
ip -6 rule add from 2000::/3 to 2000::/3 lookup 102 priority 200
|
||||
ip -6 rule add from fd00::/8 to fd00::/8 lookup 105 priority 300
|
||||
eend $? "Failed to load IP policy rules"
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Removing custom IP policy rules"
|
||||
ip rule del from 44.32.191.0/24 to 0.0.0.0/0 lookup 102 priority 200
|
||||
ip rule del from 172.20.0.0/14 to 172.20.0.0/14 lookup 105 priority 300
|
||||
ip -6 rule del from 2000::/3 to 2000::/3 lookup 102 priority 200
|
||||
ip -6 rule del from fd00::/8 to fd00::/8 lookup 105 priority 300
|
||||
eend $? "Failed to remove IP policy rules"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
Reference in New Issue
Block a user