Skip to content

Instantly share code, notes, and snippets.

@imlk0
Created August 30, 2022 01:08
Show Gist options
  • Select an option

  • Save imlk0/a2074e5ecab50b3232b08f757af20762 to your computer and use it in GitHub Desktop.

Select an option

Save imlk0/a2074e5ecab50b3232b08f757af20762 to your computer and use it in GitHub Desktop.

Revisions

  1. imlk0 created this gist Aug 30, 2022.
    33 changes: 33 additions & 0 deletions 80-imlk-ebtables-ipv6
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/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