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
-
For fire wall Status to show results we need to first set up basic system firewall rules.
sudo ufw statussudo ufw default deny incomingsudo ufw default allow outgoing -
If web servers hosted locally or public are not working just we could disabe the ufw completely.
sudo systemctl status ufwsudo systemctl stop ufw
-
PORTS : http-80, https-443, ssh-22, ftp-20/21
sudo ufw sshsudo ufw httpssudo ufw httpsudo allow ftp
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
sudo ufw status verbose
sudo ufw status numbered or sudo ufw status /// simply show the state and rules set in firewall.
sudo ufw deny 23
##4. Test the Rule
telnet 192.168.56.103 on Guest System-1
sudo ufw deny 23
sudo ufw allow 22
sudo ufw status numbered
- [ 1] 23/tcp DENY Anywhere
- [ 2] 22/tcp ALLOW Anywhere
sudo ufw delete 1
- 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.
-
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.