{"id":13527398,"url":"https://github.com/silverwind/default-gateway","last_synced_at":"2025-05-16T18:10:45.888Z","repository":{"id":21679240,"uuid":"95317392","full_name":"silverwind/default-gateway","owner":"silverwind","description":"Get the default network gateway, cross-platform.","archived":false,"fork":false,"pushed_at":"2023-12-14T12:33:36.000Z","size":367,"stargazers_count":86,"open_issues_count":4,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T12:59:40.694Z","etag":null,"topics":["aix","android","cross-platform","freebsd","gateway","ibmi","linux","macos","module","nodejs","openbsd","solaris","windows"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silverwind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-24T19:07:44.000Z","updated_at":"2024-03-09T15:56:08.000Z","dependencies_parsed_at":"2024-01-14T01:15:11.657Z","dependency_job_id":null,"html_url":"https://github.com/silverwind/default-gateway","commit_stats":{"total_commits":204,"total_committers":10,"mean_commits":20.4,"dds":0.05882352941176472,"last_synced_commit":"5d684146e2772a8f0a7e1f78772f4d1be6fd0e6e"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fdefault-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fdefault-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fdefault-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fdefault-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silverwind","download_url":"https://codeload.github.com/silverwind/default-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245543416,"owners_count":20632648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["aix","android","cross-platform","freebsd","gateway","ibmi","linux","macos","module","nodejs","openbsd","solaris","windows"],"created_at":"2024-08-01T06:01:47.200Z","updated_at":"2025-03-27T17:16:49.334Z","avatar_url":"https://github.com/silverwind.png","language":"JavaScript","readme":"# default-gateway\n[![](https://img.shields.io/npm/v/default-gateway.svg?style=flat)](https://www.npmjs.org/package/default-gateway) [![](https://img.shields.io/npm/dm/default-gateway.svg)](https://www.npmjs.org/package/default-gateway) [![](https://packagephobia.com/badge?p=default-gateway)](https://packagephobia.com/result?p=default-gateway)\n\nObtains the machine's default gateway through `exec` calls to OS routing ints.\n\n- On Linux and Android, the `ip` command must be available (usually provided by the `iproute2` package).\n- On Unix (and macOS), the `netstat` command must be available.\n- On Windows, `wmic` must be available.\n- On IBM i, the `db2util` command must be available (provided by the `db2util` package).\n\n## Usage\n\n```js\nimport {gateway4async, gateway4sync, gateway6async, gateway6sync} from \"default-gateway\";\n\nconst {gateway, version, int} = await gateway4async();\n// gateway = '1.2.3.4', version = 4, int = 'en1'\n\nconst {gateway, version, int} = await gateway6async();\n// gateway = '2001:db8::1', version = 6,int = 'en2'\n\nconst {gateway, version, int} = gateway4sync();\n// gateway = '1.2.3.4', version = 4, int = 'en1'\n\nconst {gateway, version, int} = gateway6sync();\n// gateway = '2001:db8::1', version = 6, int = 'en2'\n```\n\n## API\n### gateway4async()\n### gateway6async()\n### gateway4sync()\n### gateway6sync()\n\nReturns: `result` *Object*\n  - `gateway` *String*: The IP address of the default gateway.\n  - `version` *Number*: The IP address version of `gateway`.\n  - `int` *String*: The name of the interface. On Windows, this is the network adapter name.\n\nThe `gateway` property will always be defined on success, while `int` can be `null` if it cannot be determined. All methods reject/throw on unexpected conditions.\n\n## License\n\n© [silverwind](https://github.com/silverwind), distributed under BSD licence\n","funding_links":[],"categories":["Repository","JavaScript","Misc"],"sub_categories":["Network"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fdefault-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilverwind%2Fdefault-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fdefault-gateway/lists"}