IR-Access is a Go-based application designed to fetch Iranian IP prefixes and set up firewall rules using nftables
to allow only Iranian traffic while keeping SSH access open.
- Fetches Iranian IP prefixes from bgp.tools
- Filters the IP prefixes based on predefined ASN numbers
- Converts IPv4 prefixes to /24 blocks
- Configures
nftables
to allow traffic only from Iran (except SSH) - Automated setup and verification
Ensure the following dependencies are installed on your system:
- Go (>=1.22)
- nftables
- sudo privileges (for setup operation)
All binaries are available in amd64
and arm64
.
-
wget "https://github.com/irgfw/ir-access/releases/latest/download/ir-access-linux-amd64" -O ir-access && chmod +x ir-access
-
./ir-access -f
- Download from Releases.
- Open
CMD
orPowershell
in the directory. -
.\ir-access-windows-amd64.exe --fetch
-
Clone the repository:
git clone https://github.com/yourusername/IR-Access.git cd IR-Access
-
Build the application:
go build -o ir-access
Run the application with the following options:
./ir-access [OPTIONS]
Option | Short Flag | Description |
---|---|---|
--fetch |
-f |
Fetch all Iranian IP prefixes from bgp.tools. |
--setup |
-s |
Set up nftables rules to allow Iran-only access (fetches prefixes). |
--help |
-h |
Show help message. |
-
Fetch Iranian IP prefixes:
./ir-access --fetch
-
Set up firewall rules to allow Iran-Only access (excluding SSH):
sudo ./ir-access --setup
-
Fetching Prefixes:
- Downloads the IP prefix data from
bgp.tools
. - Filters the prefixes based on specific ASN numbers.
- Saves IPv4 and IPv6 prefixes into respective text files.
- Downloads the IP prefix data from
-
Setting Up nftables:
- Reads the stored prefix files.
- Detects the SSH port from
/etc/ssh/sshd_config
. - Configures firewall rules to allow only Iranian traffic.
- Applies and verifies the nftables rules.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to fork the repository and submit a pull request.