05 How To Allow Custom Ports in Firewall | Allow Multiple Ports in Firewall | Working with firewall-cmd command line

How To Allow Custom Ports in Firewall | Allow Multiple Ports in Firewall
How To Allow Custom Ports in Firewall | Allow Multiple Ports in Firewall


In this topic we will add custom single and multiple ports in firewall

We will add 10000 TCP and 10001 UDP port in linuxtopic zone , below command

To add single port in firewall
firewall-cmd --list-all
firewall-cmd --zone=linuxtopic --add-port=10000/tcp
firewall-cmd --zone=linuxtopic --add-port=10001/udp

Note: Here we add both ports temporary to add permanently you can add  --permanent 

To add firewall ports in permanent
firewall-cmd --zone=linuxtopic --add-port=10000/tcp --permanent
firewall-cmd --zone=linuxtopic --add-port=10001/udp --permanent
To add multiple ports in firewalld

We will add 10010 to 10020 tcp and 10010 to 10015 udp ports in firewall
firewall-cmd --zone=linuxtopic --add-port=10010-10020/tcp --permanent
firewall-cmd --zone=linuxtopic --add-port=10010-10015/udp --permanent
firewall-cmd --reload

How to allow port Instead of service in firewall, first we will check which ports is used by service. we can get info with following command, for the example of samba service
firewall-cmd --info-service=samba

Here we get 137/tcp 138/udp 139/tcp and 445/tcp port used by samba. Now we have all ports of samba
firewall-cmd --zone=linuxtopic --add-port=137/tcp --permanent
firewall-cmd --zone=linuxtopic --add-port=138/udp --permanent
firewall-cmd --zone=linuxtopic --add-port=139/tcp --permanent
firewall-cmd --zone=linuxtopic --add-port=445/tcp --permanent
firewall-cmd --reload





Thanks






1 comment:

  1. Great Article
    Cyber Security Projects

    projects for cse

    Networking Projects

    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete

Powered by Blogger.