server - How to close all the ports in ubuntu except those I need them - Ask Ubuntu
i new in field of security understand it´s helpful know such things. may ask how see open ports in ubuntu , how close ports except need them. nicolae
you can use nmap
show open ports.
open terminal , install nmap
application:
sudo apt install nmap
the nmap man pages can brought using man nmap
can show commands can use after installed.
after installed, can scan ports open on host -p
switch of nmap
following (i set scan ports 1 65535):
terrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100 starting nmap 7.01 ( https://nmap.org ) @ 2016-10-29 23:28 mdt nmap scan report terrance-ubuntu.local (10.0.0.100) host (0.00025s latency). not shown: 65522 closed ports port state service 21/tcp open ftp 22/tcp open ssh 25/tcp open smtp 139/tcp open netbios-ssn 445/tcp open microsoft-ds 902/tcp open iss-realsecure 1936/tcp open unknown 10000/tcp open snet-sensor-mgmt 17500/tcp open db-lsp 32400/tcp open unknown 32469/tcp open unknown 33400/tcp open unknown 33443/tcp open unknown
you can kill process has port open webmin (or port 10000) on list, or can use iptables
create simple rule drop
packets port time being until next reboot (if want them permanent might want install iptables-persistent
package):
sudo iptables -a input -p tcp --dport 10000 -j drop
then if want add session, delete rule:
sudo iptables -d input -p tcp --dport 10000 -j drop
examples below:
terrance@terrance-ubuntu:~$ sudo iptables -a input -p tcp --dport 10000 -j drop terrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100 starting nmap 7.01 ( https://nmap.org ) @ 2016-10-29 23:49 mdt nmap scan report terrance-ubuntu.local (10.0.0.100) host (0.00028s latency). not shown: 65522 closed ports port state service 21/tcp open ftp 22/tcp open ssh 25/tcp open smtp 139/tcp open netbios-ssn 445/tcp open microsoft-ds 902/tcp open iss-realsecure 1936/tcp open unknown 10000/tcp filtered snet-sensor-mgmt 17500/tcp open db-lsp 32400/tcp open unknown 32469/tcp open unknown 33400/tcp open unknown 33443/tcp open unknown nmap done: 1 ip address (1 host up) scanned in 4.13 seconds terrance@terrance-ubuntu:~$ sudo iptables -d input -p tcp --dport 10000 -j drop terrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100 starting nmap 7.01 ( https://nmap.org ) @ 2016-10-29 23:49 mdt nmap scan report terrance-ubuntu.local (10.0.0.100) host (0.00027s latency). not shown: 65522 closed ports port state service 21/tcp open ftp 22/tcp open ssh 25/tcp open smtp 139/tcp open netbios-ssn 445/tcp open microsoft-ds 902/tcp open iss-realsecure 1936/tcp open unknown 10000/tcp open snet-sensor-mgmt 17500/tcp open db-lsp 32400/tcp open unknown 32469/tcp open unknown 33400/tcp open unknown 33443/tcp open unknown nmap done: 1 ip address (1 host up) scanned in 4.10 seconds
hope helps!
Comments
Post a Comment