Created
August 30, 2022 01:08
-
-
Save imlk0/a2074e5ecab50b3232b08f757af20762 to your computer and use it in GitHub Desktop.
Upload this file to /etc/hotplug.d/iface/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# imlk: setup ipv6 bridge while ipv4 is nat mode. see https://jethro.fun/index.php/archives/162/ | |
logger -t imlk-ebtables-ipv6 "hotplugin event: $INTERFACE -> $ACTION" | |
if [[ "$INTERFACE" != "wan" ]]; then | |
exit | |
fi | |
case "$ACTION" in | |
ifup) | |
logger -t imlk-ebtables-ipv6 "setup ipv6 passthrough ..." | |
# force non-ipv6 packet to be routed | |
ebtables -t broute -A BROUTING -p ! ipv6 -j DROP -i eth0.2 | |
# drop some bad devices in UCAS | |
ebtables -t filter -A FORWARD --src 5c:02:14:73:1c:b6 -j DROP | |
ebtables -t filter -A FORWARD --src 8c:de:f9:ec:92:be -j DROP | |
ebtables -t filter -A FORWARD --src 54:ee:75:f2:85:12 -j DROP | |
brctl addif br-lan eth0.2 | |
logger -t imlk-ebtables-ipv6 "setup ipv6 passthrough done!" | |
;; | |
ifdown) | |
logger -t imlk-ebtables-ipv6 "revert ipv6 passthrough ..." | |
brctl delif br-lan eth0.2 | |
ebtables -t broute -D BROUTING -p ! ipv6 -j DROP -i eth0.2 | |
logger -t imlk-ebtables-ipv6 "revert ipv6 passthrough done!" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment