{"id":23201411,"url":"https://github.com/jlyonsmith/iptables-parser","last_synced_at":"2026-01-28T05:18:10.392Z","repository":{"id":143313338,"uuid":"240138728","full_name":"jlyonsmith/iptables-parser","owner":"jlyonsmith","description":"Basic nodejs parser/encoder for iptables config files","archived":false,"fork":false,"pushed_at":"2018-12-27T04:17:48.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-25T01:12:33.461Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"wkronmiller/iptables-parser","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jlyonsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-12T23:43:55.000Z","updated_at":"2020-02-12T23:43:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"5fcc5413-8a8e-402d-8790-475d8313d199","html_url":"https://github.com/jlyonsmith/iptables-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jlyonsmith/iptables-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2Fiptables-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2Fiptables-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2Fiptables-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2Fiptables-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jlyonsmith","download_url":"https://codeload.github.com/jlyonsmith/iptables-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2Fiptables-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28840088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T15:15:02.609Z","updated_at":"2026-01-28T05:18:10.387Z","avatar_url":"https://github.com/jlyonsmith.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nI couldn't find a NodeJS parser for CentOS IPTables configs, so I wrote one.\n\n[![CircleCI](https://circleci.com/gh/wkronmiller/iptables-parser/tree/master.svg?style=svg)](https://circleci.com/gh/wkronmiller/iptables-parser/tree/master)\n\n## Example Usage\n\n### Parsing\n\n```\nconst fs = require('fs');\n\nconst { parseIptablesDoc } = require('@wkronmiller/iptables-parser');\n\nconst tables = parseIptablesDoc(String(fs.readFileSync('/etc/sysconfig/iptables')));\n\n{\n  \"nat\": {\n    \"chains\": [\n      \":PREROUTING ACCEPT [10446:1172408]\",\n      \":INPUT ACCEPT [2:128]\",\n      \":OUTPUT ACCEPT [936796:35582363]\",\n      \":POSTROUTING ACCEPT [2:100]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A PREROUTING -p tcp --dport 8080 -m tcp -i enp2s0 -j DNAT --to-destination 10.0.0.2:8080\",\n        \"chain\": \"PREROUTING\",\n        \"protocol\": \"tcp\",\n        \"destinationPort\": \"8080\",\n        \"destinationIp\": \"10.0.0.2:8080\",\n        \"match\": \"tcp\",\n        \"jump\": \"DNAT\",\n        \"inInterface\": \"enp2s0\"\n      },\n      {\n        \"rule\": \"-A POSTROUTING -o enp2s0 -j MASQUERADE\",\n        \"chain\": \"POSTROUTING\",\n        \"jump\": \"MASQUERADE\",\n        \"outInterface\": \"enp2s0\"\n      }\n    ]\n  },\n  \"filter\": {\n    \"chains\": [\n      \":INPUT DROP [921:224347]\",\n      \":FORWARD DROP [0:0]\",\n      \":OUTPUT ACCEPT [565105:269130484]\",\n      \":LOGGING - [0:0]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\",\n        \"chain\": \"INPUT\",\n        \"state\": \"RELATED,ESTABLISHED\",\n        \"jump\": \"ACCEPT\"\n      },\n      {\n        \"rule\": \"-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT\",\n        \"chain\": \"FORWARD\",\n        \"state\": \"RELATED,ESTABLISHED\",\n        \"jump\": \"ACCEPT\"\n      },\n      {\n        \"rule\": \"-A FORWARD -o enp2s0 -j ACCEPT\",\n        \"chain\": \"FORWARD\",\n        \"jump\": \"ACCEPT\",\n        \"outInterface\": \"enp2s0\"\n      }\n    ]\n  },\n  \"mangle\": {\n    \"chains\": [\n      \":PREROUTING ACCEPT [29954120:21998687750]\",\n      \":INPUT ACCEPT [13724903:714542939]\",\n      \":FORWARD ACCEPT [16227934:21283971156]\",\n      \":OUTPUT ACCEPT [115615848:51845984788]\",\n      \":POSTROUTING ACCEPT [131843756:73129954576]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A PREROUTING -p tcp --dport 22 -m tcp -j TOS --set-tos 0x10/0x3f -m comment --comment \\\"Make ssh faster\\\"\",\n        \"chain\": \"PREROUTING\",\n        \"protocol\": \"tcp\",\n        \"destinationPort\": \"22\",\n        \"match\": \"tcp\",\n        \"jump\": \"TOS\",\n        \"tos\": \"0x10/0x3f\",\n        \"comment\": \"\\\"Make ssh faster\\\"\"\n      }\n    ]\n  }\n}\n\n```\n\n### Encoding\n\n```\n\nconst { encodeIPTables } = require('../src/index');\n\nconst tables = {\n  \"nat\": {\n    \"chains\": [\n      \":PREROUTING ACCEPT [10446:1172408]\",\n      \":INPUT ACCEPT [2:128]\",\n      \":OUTPUT ACCEPT [936796:35582363]\",\n      \":POSTROUTING ACCEPT [2:100]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A PREROUTING -p tcp --dport 8080 -m tcp -i enp2s0 -j DNAT --to-destination 10.0.0.2:8080\",\n        \"chain\": \"PREROUTING\",\n        \"protocol\": \"tcp\",\n        \"destinationPort\": \"8080\",\n        \"destinationIp\": \"10.0.0.2:8080\",\n        \"match\": \"tcp\",\n        \"jump\": \"DNAT\",\n        \"inInterface\": \"enp2s0\"\n      },\n      {\n        \"rule\": \"-A POSTROUTING -o enp2s0 -j MASQUERADE\",\n        \"chain\": \"POSTROUTING\",\n        \"jump\": \"MASQUERADE\",\n        \"outInterface\": \"enp2s0\"\n      }\n    ]\n  },\n  \"filter\": {\n    \"chains\": [\n      \":INPUT DROP [921:224347]\",\n      \":FORWARD DROP [0:0]\",\n      \":OUTPUT ACCEPT [565105:269130484]\",\n      \":LOGGING - [0:0]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\",\n        \"chain\": \"INPUT\",\n        \"state\": \"RELATED,ESTABLISHED\",\n        \"jump\": \"ACCEPT\"\n      },\n      {\n        \"rule\": \"-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT\",\n        \"chain\": \"FORWARD\",\n        \"state\": \"RELATED,ESTABLISHED\",\n        \"jump\": \"ACCEPT\"\n      },\n      {\n        \"rule\": \"-A FORWARD -o enp2s0 -j ACCEPT\",\n        \"chain\": \"FORWARD\",\n        \"jump\": \"ACCEPT\",\n        \"outInterface\": \"enp2s0\"\n      }\n    ]\n  },\n  \"mangle\": {\n    \"chains\": [\n      \":PREROUTING ACCEPT [29954120:21998687750]\",\n      \":INPUT ACCEPT [13724903:714542939]\",\n      \":FORWARD ACCEPT [16227934:21283971156]\",\n      \":OUTPUT ACCEPT [115615848:51845984788]\",\n      \":POSTROUTING ACCEPT [131843756:73129954576]\"\n    ],\n    \"rules\": [\n      {\n        \"rule\": \"-A PREROUTING -p tcp --dport 22 -m tcp -j TOS --set-tos 0x10/0x3f -m comment --comment \\\"Make ssh faster\\\"\",\n        \"chain\": \"PREROUTING\",\n        \"protocol\": \"tcp\",\n        \"destinationPort\": \"22\",\n        \"match\": \"tcp\",\n        \"jump\": \"TOS\",\n        \"tos\": \"0x10/0x3f\",\n        \"comment\": \"\\\"Make ssh faster\\\"\"\n      }\n    ]\n  }\n};\n\nencodeIPTables({ tables });\n\n*nat\n:PREROUTING ACCEPT [10446:1172408]\n:INPUT ACCEPT [2:128]\n:OUTPUT ACCEPT [936796:35582363]\n:POSTROUTING ACCEPT [2:100]\n-A PREROUTING -p tcp --dport 8080 -m tcp -i enp2s0 -j DNAT --to-destination 10.0.0.2:8080\n-A POSTROUTING -o enp2s0 -j MASQUERADE\nCOMMIT\n\n*filter\n:INPUT DROP [921:224347]\n:FORWARD DROP [0:0]\n:OUTPUT ACCEPT [565105:269130484]\n:LOGGING - [0:0]\n-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\n-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT\n-A FORWARD -o enp2s0 -j ACCEPT\nCOMMIT\n\n*mangle\n:PREROUTING ACCEPT [29954120:21998687750]\n:INPUT ACCEPT [13724903:714542939]\n:FORWARD ACCEPT [16227934:21283971156]\n:OUTPUT ACCEPT [115615848:51845984788]\n:POSTROUTING ACCEPT [131843756:73129954576]\n-A PREROUTING -p tcp --dport 22 -m tcp -j TOS --set-tos 0x10/0x3f -m comment --comment \"Make ssh faster\"\nCOMMIT\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlyonsmith%2Fiptables-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlyonsmith%2Fiptables-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlyonsmith%2Fiptables-parser/lists"}