Port Enable and Open

  • Steps

    1. install ufw

    
                      sudo apt update
                      sudo apt install ufw
    
                      sudo ufw enable
    
                      reboot
    
                      

    2. Enbale iptables

    
                      sudo iptables -A INPUT -p <protocol> --dport <port_number> -j ACCEPT
    
                      eg:    sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
                      
    List the rules
    
                      sudo iptables -L
                     

    3. Allow ports

    
                     sudo ufw allow <port_number>/<optional_protocol>
    
                     eg: sudo ufw allow 8080/tcp              
                     
    
                    
    Add port range
    
                    sudo ufw allow 50000:50100/tcp
    
    reload the ufw
    
                  sudo ufw reload
                    
    Check status
    
                    sudo ufw status verbose
                  

    4. check the port

    
                  telnet <IP_address> <port_number>
    
                  OR
    
                  nmap -p <port_number>  <IP_address>