{"id":19388406,"url":"https://github.com/mk-fg/pfsense-scripts","last_synced_at":"2025-04-23T23:31:37.567Z","repository":{"id":144996311,"uuid":"42046016","full_name":"mk-fg/pfsense-scripts","owner":"mk-fg","description":"Misc ad-hoc helper scripts for pfSense boxes","archived":true,"fork":false,"pushed_at":"2015-09-07T16:31:05.000Z","size":168,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-13T12:29:21.348Z","etag":null,"topics":["bash","networking","pfsense","scraps"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/mk-fg.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2015-09-07T10:10:47.000Z","updated_at":"2023-11-05T19:48:18.000Z","dependencies_parsed_at":"2023-04-07T04:56:34.529Z","dependency_job_id":null,"html_url":"https://github.com/mk-fg/pfsense-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk-fg%2Fpfsense-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk-fg%2Fpfsense-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk-fg%2Fpfsense-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mk-fg%2Fpfsense-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mk-fg","download_url":"https://codeload.github.com/mk-fg/pfsense-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250532053,"owners_count":21446107,"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":["bash","networking","pfsense","scraps"],"created_at":"2024-11-10T10:12:37.200Z","updated_at":"2025-04-23T23:31:37.310Z","avatar_url":"https://github.com/mk-fg.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"pfsense-scripts\n===============\n\nMisc ad-hoc helper scripts for `pfSense \u003chttps://www.pfsense.org/\u003e`_ boxes.\n\n\n.. contents::\n  :backlinks: none\n\n\n\nInstallation\n------------\n\nThe Right Way to install these scripts to pfSense machine is to upload them\nthrough \"Filer\" package, with executable bit, and setup to run through Filer's\n\"Script/Command\" option.\n\n\"Filer\" package can be installed from WebUI's \"System - Packages\" menu.\n\nAfter that, individual scripts should be uploaded through \"Diagnostics - Filer\"\nWebUI form, with the following fields set:\n\n* ``File: /usr/local/etc/\u003cscript_name\u003e``\n* ``Permissions: 0755``\n* ``File Contents: \u003cscript_contents\u003e``\n* ``Script/Command: /usr/local/etc/\u003cscript_name\u003e \u003cscript_args\u003e``\n* ``Description`` field can be filled with anything you like.\n\nSubstitute \u003cscriptname\u003e and \u003cscript_contents\u003e above with name/contents for the\nspecific script and \u003cscript_args\u003e with any parameters that it expects on the\ncommand line (see script descriptions below for these).\n\nScripts that are configurable can also have values that can be changed when\ncopying script contents, usually at the very top.\n\nAny scripts installed that way will be stored in the pfSense config, and can be\nbacked-up/restored along with all the other pfSense configuration parameters\n(e.g. through \"Diagnostics - Backup/restore\" in WebUI).\n\n\n\nScripts\n-------\n\nInstall these via \"Filer\" package, as described in the \"Installation\" section.\n\niface_check_restart.sh\n``````````````````````\n\nScript to detect when interface goes down and restart it::\n\n  Usage: iface_check_restart.sh interface_label [check_interval]\n\nCommand-line arguments:\n\n* interface_label: interface name, same as it is set/shown in pfSense WebUI.\n\n  For example, default wan/lan interface names in pfSense are WAN and LAN.\n  Upper/lower case matters.\n\n* check_interval (optional): interval between iface state checks, in seconds.\n\n  Default: 60\n\nExample Filer's \"Script/Command\" setting (for WAN interface)::\n\n  /usr/local/etc/iface_check_restart.sh WAN\n\nRuns in an endless loop, checking specified interface state every N seconds and\nrestarting it if check fails.\n\nRestart is done via ``interface_reconfigure($iface)`` from php, which cycles\niface state down/up.\n\ngateway_change_conn_reset.sh\n````````````````````````````\n\nScript to detect when default gateway interface changes and forcefully kill all\nconnections still hanging throu old gateway interface::\n\n  Usage: gateway_change_conn_reset.sh [check_interval]\n\nCommand-line arguments:\n\n* check_interval (optional): interval gateway checks, in seconds.\n\n  Default: 60\n\nRuns in an endless loop, getting list of interfaces (os-level, e.g. em0) for\ngateways marked as \"defaultgw\" and dumping list of these to a file in /tmp\n(configurable in script via PFx_STATE_FILE), checking old contents of it against\nthis list and running ``/etc/rc.kill_states \u003ciface\u003e`` for interfaces that are\nnot longer used for default gw.\n\n\n\nDebugging\n---------\n\nSome (or all) scripts check if PFx_DEBUG env variable is non-empty and echo some\nextra debug information to stderr when that's the case.\n\nBest way to see this output would be to run the scripts manually from the shell,\nor with output redirection, i.e.::\n\n  % PFx_DEBUG=t /usr/local/etc/gateway_change_conn_reset.sh 5\n  gw_ifaces :: em1\n  gw_ifaces_old :: em1\n  gw_ifaces :: em1\n  gw_ifaces_old :: em1\n  gw_ifaces :: em0\n  gw_ifaces_old :: em1\n  rc.kill_states :: em1\n  gw_ifaces :: em0\n  gw_ifaces_old :: em0\n  ...\n\nFor conventional output redirection via e.g. ``2\u003e/tmp/debug.log``, make sure\n\"sh\" shell is being used, as tcsh has its own syntax for that::\n\n  % ps -p$$\n    PID TT  STAT    TIME COMMAND\n  43600  0  S    0:00.01 /bin/tcsh\n\n  % sh\n  % ps -p$$\n    PID TT  STAT    TIME COMMAND\n  97458  0  S    0:00.00 sh\n\n  % PFx_DEBUG=t nohup /usr/local/etc/gateway_change_conn_reset.sh 5 2\u003e/tmp/debug.log \u0026\n  % exit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmk-fg%2Fpfsense-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmk-fg%2Fpfsense-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmk-fg%2Fpfsense-scripts/lists"}