Could not open a raw socket Error permission denied(13)
I was trying to be familiar with nmap , so I installed nmap
using snap
in Ubuntu 20.04.
But when I ran some nmap command , I got below error messages:
Couldn't open a raw socket. Error: Permission denied (13)
Solution
snap connect nmap:network-control
Above command gives nmap network-control access.
Wait, but Why
Because I installed nmap via snap but not apt.
At first we can see nmap:network-control is not been connected to slot
root@ubuntu:~# snap connections nmap
Interface Plug Slot Notes
home nmap:home :home -
network nmap:network :network -
network-bind nmap:network-bind :network-bind -
network-control nmap:network-control - -
And after we connected it , the output looks like below
root@ubuntu:~# snap connections nmap
Interface Plug Slot Notes
home nmap:home :home -
network nmap:network :network -
network-bind nmap:network-bind :network-bind -
network-control nmap:network-control :network-control manual
And now nmap command works well
root@ubuntu:~# nmap -p 80 bing.com
Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-03 18:52 PDT
Couldn't open a raw socket. Error: Permission denied (13)
root@ubuntu:~# snap connect nmap:network-control
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# nmap -p 80 bing.com
Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-03 19:00 PDT
Nmap scan report for bing.com (204.79.197.200)
Host is up (0.0053s latency).
Other addresses for bing.com (not scanned): 13.107.21.200 2620:1ec:c11::200
rDNS record for 204.79.197.200: a-0001.a-msedge.net
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 0.31 seconds
root@ubuntu:~#