How to close all the ports in ubuntu except those I need them
来源:互联网 发布:淘宝神笔 编辑:程序博客网 时间:2024/05/18 04:53
https://askubuntu.com/questions/843395/how-to-close-all-the-ports-in-ubuntu-except-those-i-need-them
down vote
You can use nmap
to show you all open ports.
Open a terminal and install the nmap
application:
sudo apt install nmap
The nmap man pages can be brought up using man nmap
which can show you all the commands you can use after it is installed.
After it is installed, you can scan all the ports that are open on your host with the -p
switch of nmap
like the following (I set it to scan all ports from 1 to 65535):
terrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100Starting Nmap 7.01 ( https://nmap.org ) at 2016-10-29 23:28 MDTNmap scan report for terrance-ubuntu.local (10.0.0.100)Host is up (0.00025s latency).Not shown: 65522 closed portsPORT STATE SERVICE21/tcp open ftp22/tcp open ssh25/tcp open smtp139/tcp open netbios-ssn445/tcp open microsoft-ds902/tcp open iss-realsecure1936/tcp open unknown10000/tcp open snet-sensor-mgmt17500/tcp open db-lsp32400/tcp open unknown32469/tcp open unknown33400/tcp open unknown33443/tcp open unknown
You can kill the process that has the port open like webmin (or port 10000) on my list, or you can use iptables
to create a simple rule to DROP
the packets to that port for the time being until next reboot (If you want them permanent you might want to install the iptables-persistent
package):
sudo iptables -A INPUT -p tcp --dport 10000 -j DROP
Then if you want to add it back for this session, delete the 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 DROPterrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100Starting Nmap 7.01 ( https://nmap.org ) at 2016-10-29 23:49 MDTNmap scan report for terrance-ubuntu.local (10.0.0.100)Host is up (0.00028s latency).Not shown: 65522 closed portsPORT STATE SERVICE21/tcp open ftp22/tcp open ssh25/tcp open smtp139/tcp open netbios-ssn445/tcp open microsoft-ds902/tcp open iss-realsecure1936/tcp open unknown10000/tcp filtered snet-sensor-mgmt17500/tcp open db-lsp32400/tcp open unknown32469/tcp open unknown33400/tcp open unknown33443/tcp open unknownNmap done: 1 IP address (1 host up) scanned in 4.13 secondsterrance@terrance-ubuntu:~$ sudo iptables -D INPUT -p tcp --dport 10000 -j DROPterrance@terrance-ubuntu:~$ nmap -p1-65535 10.0.0.100Starting Nmap 7.01 ( https://nmap.org ) at 2016-10-29 23:49 MDTNmap scan report for terrance-ubuntu.local (10.0.0.100)Host is up (0.00027s latency).Not shown: 65522 closed portsPORT STATE SERVICE21/tcp open ftp22/tcp open ssh25/tcp open smtp139/tcp open netbios-ssn445/tcp open microsoft-ds902/tcp open iss-realsecure1936/tcp open unknown10000/tcp open snet-sensor-mgmt17500/tcp open db-lsp32400/tcp open unknown32469/tcp open unknown33400/tcp open unknown33443/tcp open unknownNmap done: 1 IP address (1 host up) scanned in 4.10 seconds
Hope this helps!
- How to close all the ports in ubuntu except those I need them
- 【转】Programmers Need To Learn Statistics Or I Will Kill Them All
- 【转】Programmers Need To Learn Statistics Or I Will Kill Them All
- 3.You need to extract details of those products in the SALES table where the PROD_ID column contains
- All I Need To Know To Be A Better Programmer I Learned In Kindergarten
- How to close all browsers from QTP?
- How to say all the keyboard symbols in English
- How to see all the application errors related to SQL Server and export them to a .csv file.
- How to close firewall in Fedora
- how to install the chrome in the Ubuntu platform
- All except the music
- How to Close All Open Browsers Using QTP
- Magento: How to list all the products in a single category in a sidebar block
- How to get all the members in user group by using LDAP in Perl?
- How to identify all the Corrupted Objects in the Database reported by RMAN
- How can i get hold of all of the visible items in my QListView?
- How to Change The Bootsplash In Ubuntu 8.10
- How to setup the 3D Feature in Ubuntu
- windows下安装pyv8,并在pycharm中引用
- c++中vector的用法详解
- pgsql:删除表中重复数据保留其中的一条
- JavaScript获取非行间样式的方法
- app启动融云数据库出错小记
- How to close all the ports in ubuntu except those I need them
- hdu1029_大水题(思维)
- Ubuntu之间配置互相SSh免密登陆
- C#学习笔记(二)---在C#中创建类(上)
- Ubuntu 16.10用户密码找回
- EventBus的使用与原理 组件通信 线程通信(1)
- 李炎恢JQuery EasyUI视频培训视频教程下载
- 推荐Leangoo团队协作的20个理由
- linux mkdir