# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Overview This is a collection of OpenWrt router management scripts for firewall configuration and network diagnostics. The scripts use nftables (fw4) for firewall management and are designed to restrict access to Taiwan IP addresses only. **Target Device**: OpenWrt 24.10.4 (r28959-29397011cc) at `192.168.42.10` ## Prerequisites These scripts require an OpenWrt router with: - `nft` command (nftables with fw4 firewall) - `curl` for downloading IP lists and checking network status - `jq` for JSON parsing (test_connection.sh) - `nc` (netcat) for port connectivity testing Install dependencies (from `R` file): ```sh opkg update opkg install curl ``` ## Scripts ### `update_tw_ip.sh` Downloads the latest Taiwan IP range list from ipdeny.com and updates the nftables `taiwan_ips` set in the `inet fw4` table. Usage: Run as root, typically via cron or manually: ```sh sh /root/42_10/update_tw_ip.sh ``` The script flushes the existing set and repopulates it with fresh IP data from `https://www.ipdeny.com/ipblocks/data/countries/tw.zone`. ### `test_connection.sh` Diagnostic script to verify firewall rules are working correctly. It: 1. Checks the current IP location via `https://ip.lotimmy.com/json` 2. Tests connectivity to specified ports on `125.229.110.50` 3. Reports whether connections succeed or are blocked Edit the `TARGET_IP` and `PORTS` variables at the top of the script to match your configuration before running. ## Firewall Configuration These scripts assume an nftables configuration with: - Table: `inet fw4` - Set: `taiwan_ips` (type for storing IP ranges) The firewall should have rules referencing this set to allow/deny traffic based on Taiwan IP membership.