初期はここ

This commit is contained in:
joe 2026-01-22 10:50:27 +09:00
parent d61b305520
commit e38fcf5b3a

20
ipfn1.0 Normal file → Executable file
View file

@ -1,5 +1,5 @@
#!/bin/bash
# Version: 2.0.0 (Refactored for nftables)
# Version: 1.0.0 (Refactored for nftables)
# Date: 2026-01-22
# Original Author: krasherjoe
# Refactored by: Gemini (AI Thought Partner)
@ -37,7 +37,7 @@ is_container() {
# バージョン表示
show_version() {
cat << EOF
nft-ipf ver.2.0.0
ipfn ver.1.0.0
Date: 2026-01-22
Based on ipf ver.1.0.4
@ -52,11 +52,11 @@ show_help() {
Usage: $(basename "$0") [OPTIONS] [PORT:IP:PORT | -L | -d HANDLE]
Examples:
ipf 11434:10.1.1.2:11434 # Forward local port 11434 to 10.1.1.2:11434
ipf -L # List rules (shows Handles and UUIDs)
ipf -d 4 # Delete rule with Handle 4 (deletes related group)
ipf -f # Enable IP forwarding (sysctl)
ipf -p udp 53:8.8.8.8:53 # Forward UDP
ipfn 11434:10.1.1.2:11434 # Forward local port 11434 to 10.1.1.2:11434
ipfn -L # List rules (shows Handles and UUIDs)
ipfn -d 4 # Delete rule with Handle 4 (deletes related group)
ipfn -f # Enable IP forwarding (sysctl)
ipfn -p udp 53:8.8.8.8:53 # Forward UDP
Options:
-h, --help Show this help
@ -126,7 +126,7 @@ list_rules() {
fi
done
echo "---------------------------------------------------------------------------------"
echo "Use 'ipf -d HANDLE' to delete a rule group."
echo "Use 'ipfn -d HANDLE' to delete a rule group."
}
# ルール追加
@ -148,7 +148,7 @@ add_rule() {
# IPフォワード確認
if [[ $(sysctl -n net.ipv4.ip_forward) -ne 1 ]]; then
echo -e "\e[33mWarning: IP forwarding is disabled. Run 'ipf -f' to enable.\e[0m"
echo -e "\e[33mWarning: IP forwarding is disabled. Run 'ipfn -f' to enable.\e[0m"
fi
# UUID生成 (ルールセットをグループ化するため)
@ -288,4 +288,4 @@ if [[ "$arg" =~ ^[0-9]+:[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$ ]]; then
add_rule "$arg"
else
error "Invalid format. Expected: PORT:IP:PORT"
fi
fi