Skip to content

Instantly share code, notes, and snippets.

@jhanley-com
Last active November 29, 2023 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhanley-com/e4c7d477b0105eebd36741fd4fa79ace to your computer and use it in GitHub Desktop.
Save jhanley-com/e4c7d477b0105eebd36741fd4fa79ace to your computer and use it in GitHub Desktop.
Civo CLI (Windows): Create Firewall and Rules to Allow Traffic From Home
:: This script is for Windows
:: Firewall rule name
set NAME=allow_from_home
:: update the IP address with yours
set CIDR=1.2.3.4/32
:: Create a new firewall
call civo firewall create %NAME% --create-rules=false --network=default
@if errorlevel 1 goto err_out
:: Create a rule allowing TCP
call civo firewall rule create %NAME% ^
--protocol=TCP ^
--startport=1 ^
--endport=65535 ^
--direction=ingress ^
--label="Allow all TCP traffic from home" ^
--action="allow" ^
--cidr=%CIDR^
@if errorlevel 1 goto err_out
:: Create a rule allowing UDP
civo firewall rule create %NAME% ^
--protocol=UDP ^
--startport=1 ^
--endport=65535 ^
--direction=ingress ^
--label="Allow all UDP traffic from home" ^
--action="allow" ^
--cidr=%CIDR^
@if errorlevel 1 goto err_out
:: Create a rule allowing ICMP
civo firewall rule create %NAME% ^
--protocol=ICMP ^
--startport=1 ^
--direction=ingress ^
--label="Allow all ICMP traffic from home" ^
--action="allow" ^
--cidr=%CIDR^
@if errorlevel 1 goto err_out
:err_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment