Skip to content

Instantly share code, notes, and snippets.

@veltlion
veltlion / mac_to_ipv6.bash
Created January 16, 2023 04:05 — forked from mej/mac_to_ipv6.bash
[BASH] Function to convert MAC address to IPv6 link-local address
mac_to_ipv6() {
local HWADDR="$1" IFACE="$2"
local -a OCTETS
local IPV6ADDR
if [[ -z "$IFACE" ]]; then
IFACE=$(ip route | grep ^default | sed 's/^.* dev //')
fi
OCTETS=( ${HWADDR//:/\ } )
OCTETS[0]=$(printf %02x $((16#${OCTETS[0]}+0x02)))
@veltlion
veltlion / natter-hook.sh
Last active March 31, 2024 05:05
Natter/NATMap 打洞后自动更新 qBittorrent/Transmission 监听端口和 OpenWrt 防火墙规则/iptables 规则 并推送到 Telegram
#!/bin/sh
# Natter
protocol=$1
inner_ip=$2
inner_port=$3
outter_ip=$4
outter_port=$5
# ipv4hex=$(printf '%02x' ${outter_ip//./ })
# ip4p="2001::$(printf '%2x' ${outter_port}):${ipv4hex:0:4}:${ipv4hex:4}"