Practical  10_Windows_Firewall_Blocking    Aim  To  configure  Windows  Firewall  to  block  ports,  programs,  and  
websites.
 What  is  Windows  Firewall?  Windows  Firewall  is  a  security  feature  in  Windows  that  
controls
 
incoming
 
and
 
outgoing
 
network
 
connections.
 In  this  practical,  we  learn  how  to  create  firewall  rules  to  block  a  
port,
 
block
 
a
 
program,
 
and
 
block
 
access
 
to
 
a
 
website.
   10.1  Blocking  a  Port  What  is  a  Port?  A  port  is  a  logical  communication  endpoint  used  by  
applications
 
and
 
network
 
services.
 Examples:  Port  80  →  HTTP  Port  443  →  HTTPS  Port  21  →  FTP   Procedure  Step  1:  Press:  Windows  +  R  Step  2:  Type:  Wf.msc   

 and  press  Enter.   Step  3:  In  the  left  panel,  select:  Inbound  Rules  
  Step  4:  Click:  New  Rule  
 Step  5:  Select:  Port  →  Next  

 Step  6:  Select  TCP  or  UDP  according  to  the  requirement.  Step  7:  Enter  the  port  number.  Example:  80   

 Step  8:  Select:  Block  the  connection  

 Step  9:  Select  the  profiles  where  the  rule  should  apply:  Domain  Private  Public  

 Step  10:  Give  the  rule  a  name:  Block  Port  80  Click  Finish.   

   2.  Blocking  a  Program  in  Windows  Firewall  1.  Open  wf.msc.  
 2.  Go  to  Outbound  Rules  →  New  Rule.  

 3.  Select  Program  →  Next.   4.  Browse  and  select  the  program’s  .exe  file  (e.g.,  C:\Program  Files\App\App.exe).  

 5.  Choose  Block  the  connection.  

 6.  Select  profiles  (Domain,  Private,  Public).  

 7.  Give  the  rule  a  name  (e.g.,  Block  Chrome)  →  Finish.   

          

3.  Blocking  a  Website  Windows  Firewall  doesn’t  directly  block  websites  by  URL.  You  
can
 block  them  via  IP  addresses  or  by  editing  the  Hosts  file.  Option  A:  Using  Firewall  (via  IP  Address)  Step  1:  Find  the  Website’s  IP  Address   1.  Open  Command  Prompt:  o  Press  Windows  +  R,  type  cmd,  and  hit  Enter.  
 2.  Type  the  following  command  and  press  Enter:  3.  ping  example.com  4.  Note  the  IP  address  shown  in  the  response.  For  example,  if  you  see:  5.  Pinging  example.com  [93.184.216.34]  with  32  bytes  of  data:  The  IP  address  is  93.184.216.34.   Step  2:  Open  Windows  Defender  Firewall  with  Advanced  
Security
 1.  Press  Windows  +  R,  type:  2.  wf.msc  and  press  Enter.  3.  This  opens  the  Windows  Defender  Firewall  with  Advanced  

Security  window.   Step  3:  Create  a  New  Outbound  Rule  1.  In  the  left  pane,  click  Outbound  Rules.  2.  In  the  right  pane,  click  New  Rule...  3.  In  the  New  Outbound  Rule  Wizard,  select  Custom  and  click  Next.  
  Step  4:  Apply  Rule  to  All  Programs  1.  On  the  Program  screen,  select  All  programs  and  click  Next.   Step  5:  Configure  Protocol  and  Ports  1.  On  the  Protocol  and  Ports  screen,  leave  the  default  Any  for  protocol  type.  2.  Click  Next.   Step  6:  Set  Scope  (Specify  Remote  IP  Address)   

1.  On  the  Scope  screen,  under  Remote  IP  address,  select  
These
 
IP
 addresses.  2.  Click  Add...  3.  Enter  the  IP  address  you  got  from  the  ping  command  (e.g.,  93.184.216.34)  and  click  OK.  4.  Click  Next.  
  Step  7:  Choose  Action  (Block  the  Connection)   1.  Select  Block  the  connection.  2.  Click  Next.  

  Step  8:  Specify  When  the  Rule  Applies  1.  On  the  Profile  screen,  check  all  options:  o  Domain  o  Private  o  Public  2.  Click  Next.  

  Step  9:  Name  Your  Rule  1.  Enter  a  name  for  the  rule,  like:  2.  Block  example.com  3.  Optionally,  add  a  description.  4.  Click  Finish.   
 

  Option  B:  Using  Hosts  File  How  to  Block  Instagram  in  Google  Chrome  Using  
the
 
HOSTS
 
File
 Step  1:  Edit  the  HOSTS  File  1.  Open  Notepad  as  Administrator:  o  Click  Start,  type  Notepad.  o  Right-click  Notepad  →  Run  as  administrator.  2.  Open  HOSTS  File:  o  In  Notepad,  click  File  >  Open.  o  Navigate  to:  o  C:\Windows\System32\drivers\etc\  

o  Change  file  type  to  All  Files  and  open  the  file  
named
 hosts.   3.  Add  Instagram  Entries  at  the  bottom:  4.  127.0.0.1  instagram.com  5.  127.0.0.1  www.instagram.com  6.  127.0.0.1  help.instagram.com  7.  127.0.0.1  i.instagram.com  8.  127.0.0.1  api.instagram.com  9.  Save  the  file  and  close  Notepad.   Step  2:  Flush  DNS  Cache  1.  Press  Windows  +  R,  type  cmd,  then  press  Ctrl  
+
 
Shift
 
+
 
Enter
 
to
 open  Command  Prompt  as  admin.  2.  Run  this  command:  3.  ipconfig  /flushdns   Step  3:  Disable  DNS  Over  HTTPS  (DoH)  in  
Chrome
 1.  Open  Chrome.  2.  Go  to:  3.  chrome://settings/security  4.  Scroll  to  Use  secure  DNS  and  turn  it  OFF  
(toggle
 
it
 
off).
 

o  This  makes  Chrome  use  the  OS  DNS  resolver,  
respecting
 your  HOSTS  file.   Step  4:  Restart  Chrome  and  Test   Close  all  Chrome  windows  and  reopen.  Visit  instagram.com  or  its  subdomains.  The  site  should  not  load  (blocked).   Optional:  Clear  Browser  Cache  or  try  Incognito  
Mode
 
for
 
testing.
