Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tflanagan/node-iptables-country-block
https://github.com/tflanagan/node-iptables-country-block
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tflanagan/node-iptables-country-block
- Owner: tflanagan
- License: other
- Created: 2020-03-02T14:49:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-02T23:35:08.000Z (almost 5 years ago)
- Last Synced: 2024-11-17T12:16:55.514Z (about 2 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iptables-country-block
Interact with `iptables`, block whole countries based on assigned ip blocks
## Install
```
$ npm install [--global] iptables-country-block
```## Usage
### CLI
Note: Most use cases requires `--global` installation
```
$ [sudo] iptables-country-block [""[ ""[ ""]]]
$ [sudo] iptables-country-block "ru cn" "countryipblock" "https://raw.githubusercontent.com/herrbischoff/country-ip-blocks/master/ipv4/{isoCode}.cidr"
```### Require
```js
const {
createIptablesChain,
getCountryIPBlocks,
iptables
} = require('iptables-country-block');await iptables('-N somechain');
// or await createIptablesChain('somechain');const ipBlocks = await getCountryIPBlocks(
'https://raw.githubusercontent.com/herrbischoff/country-ip-blocks/master/ipv4/{isoCode}.cidr',
'cn'
);for(let i = 0; i < ipBlocks.length; ++i){
await iptables('-A somechain -s ' + ipBlocks[i] + ' -j DROP');
}await iptables('-I INPUT -j somechain');
await iptables('-I OUTPUT -j somechain');
await iptables('-I FORWARD -j somechain');
```