Skip to content

Instantly share code, notes, and snippets.

@lixin9311
Created March 9, 2026 11:43
Show Gist options
  • Select an option

  • Save lixin9311/1c692470e189eb615f3e2524d2e66ca5 to your computer and use it in GitHub Desktop.

Select an option

Save lixin9311/1c692470e189eb615f3e2524d2e66ca5 to your computer and use it in GitHub Desktop.
Enable V6 Plus Static IP on UDM
#!/bin/sh
# Configure JPIX "v6 Plus" Fixed IP service (IPIP).
# Intended for unattended use (e.g., crontab).
#
# Use --dry-run to preview the changes
#
# Prerequisites: System must already have MAP-E JPIX configured.
#
# Note: Weekly scheduled backup could revert the network settings.
# Disable the backup to allow the change to persist.
set -eu
# ── Parameters ────────────────────────────────────────────────────────
USERNAME="kotei0123456"
PASSWORD="p1a2s3s4"
IPV4_CIDR="8.8.8.8/32" # static IPv4 in CIDR notation
IPV6_IID="::1:2:3:4" # IPv6 Interface Identifier (lower 64 bits)
IPV6_REMOTE="2404:9200:225:100::65" # tunnel remote endpoint (IPv6 or hostname)
STATE_FILE="/data/udapi-config/ubios-udapi-server/ubios-udapi-server.state"
WORKING_FILE="${STATE_FILE}.modified"
# ──────────────────────────────────────────────────────────────────────
DRY_RUN=false
case "${1:-}" in --dry-run) DRY_RUN=true ;; esac
# Split CIDR into address and prefix length.
IPV4_ADDR="${IPV4_CIDR%/*}"
IPV4_PREFIX="${IPV4_CIDR#*/}"
# Create working copy.
cp -p "$STATE_FILE" "$WORKING_FILE"
# Build the serverName payload: IID|IPv6_Remote|IPv4_Address|IPv4_Prefix
SERVER_NAME="${IPV6_IID}|${IPV6_REMOTE}|${IPV4_ADDR}|${IPV4_PREFIX}"
# Apply modifications with jq:
# 1. Change capability from map_e_jpix → ipip_jpix
# 2. Add authentication block with serverName encoding
# 3. Remove 192.0.0.x addresses from all interfaces
jq --indent 1 \
--arg user "$USERNAME" \
--arg pass "$PASSWORD" \
--arg sname "$SERVER_NAME" \
'
.interfaces |= [
.[] |
# Update hb46pp capability and add authentication
if .ipv6.hb46pp.capability == "map_e_jpix" then
.ipv6.hb46pp.capability = "ipip_jpix"
| .ipv6.hb46pp.authentication = {
username: $user,
password: $pass,
serverName: $sname
}
else . end
|
# Remove 192.0.0.x addresses
if .addresses then
.addresses |= [ .[] | select(.cidr == null or (.cidr | startswith("192.0.0.") | not)) ]
else . end
]
' "$WORKING_FILE" > "${WORKING_FILE}.tmp" && mv "${WORKING_FILE}.tmp" "$WORKING_FILE"
# Dry run: show diff and exit without applying.
if [ "$DRY_RUN" = true ]; then
diff -u "$STATE_FILE" "$WORKING_FILE" || true
rm -f "$WORKING_FILE"
exit 0
fi
# Apply changes.
ubios-udapi-client put /system/ubios/udm/configuration "@${WORKING_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment