Skip to content

justcodeSK/CYB_TSK-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task 4 – Firewall Configuration and Traffic Filtering

1. Open Firewall Configuration Tool

For Linux used UFW (Uncomplicated Firewall) as the firewall management tool.

sudo apt update

sudo apt install ufw -y

man ufw

vim /etc/default/ufw

sudo systemctl start ufw

sudo ufw enable

Default rule setup

  • For fire wall Status to show results we need to first set up basic system firewall rules.

    sudo ufw status

    sudo ufw default deny incoming

    sudo ufw default allow outgoing

  • If web servers hosted locally or public are not working just we could disabe the ufw completely.

    sudo systemctl status ufw

    sudo systemctl stop ufw

Setting Up some common ports

  • PORTS : http-80, https-443, ssh-22, ftp-20/21

    sudo ufw ssh sudo ufw https sudo ufw http sudo allow ftp

IMPORTANT: BEFORE RESETTING RULES

Always remember to disable UFW so that you still have access to web servers, SSH, or Telnet services you are using.
If you mistakenly set a rule that locks you out, this can be solved by disabling UFW.
Even if you are locked out while using Linode (it has its own command-line interface), you can simply reset the firewall using it.

sudo ufw reset

2.Check UFW status

sudo ufw status verbose

3.List Current Firewall Rules

sudo ufw status numbered or sudo ufw status /// simply show the state and rules set in firewall.

4.Add a Rule to Block Inbound Traffic on a Specific Port (Telnet - Port 23)

sudo ufw deny 23

##4. Test the Rule telnet 192.168.56.103 on Guest System-1

Add a Rule to Block Inbound Traffic on a Specific Port (Telnet - Port 23)

sudo ufw deny 23

5. Add Rule to Allow SSH (Port 22) on Linux

sudo ufw allow 22

6. Remove the Test Block Rule to Restore Original State

sudo ufw status numbered

  • [ 1] 23/tcp DENY Anywhere
  • [ 2] 22/tcp ALLOW Anywhere

sudo ufw delete 1

How Firewall Filters Traffic

  • A firewall works by applying a set of rules to control network traffic.
  • Permits traffic matching specific conditions (IP, port, protocol).
  • Blocks traffic that matches the rule.
  • The firewall inspects packets and either forwards or drops them based on defined rules.

Extra Learned

  • We can set rule to a perticular connection

    sudo ufw allow form 192.168.56.103

  • Also do the same to a perticular port.

    sudo ufw allow form 192.168.56.103 to any port 22

  • We can also set rule to an entire subnet access.

    sudo ufw allow form 192.168.56.0/24

  • We can also use the same to deny also.

  • Learned to setup telnet local host and also on remote.

  • Learned to set up remote access SSH and used toget ipaddrss of guest-1 to guest-2.

About

Elevate Labs : CYBER SECURITY INTERNSHIP : Setup and Use a Firewall on Windows/Linux

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors