Portsentry is a tool used to avoid ports scanning a variety of activities (especially stealth scanning) is performed by hackers and make your router disappeared from hacker after scanning activity.
With Portsentry on OpenWrt it can detect and protect your router from hacker attack including port scanning, discovery, and mapping attack then block the hosts with iptables temporarily
It is recommended that you install portsentry only on public Wi-Fi or public server not on personal or office network to avoid service lockdown problem.
Requirements
Minimum free space requirement = (125.00KB)Installation
Step 1. Connect your router via web interface
- Select tabs system - software.
- Select Update list.
- In download and install package.
- Fill the search bar with "portsentry".
- Select Ok.
- Run following commands in OpenWrt SSH
- cd /etc
- mkdir portsentry
- cd portsentry
- touch portsentry.ignore
- touch portsentry.history
- touch portsentry.blocked
- vi /etc/portsentry.conf
- Edit the files
IGNORE_FILE="etc/portsentry/portsentry.ignore" IGNORE=FILE="var/run/portsentry/portsentry.ignore" BLOCK_FILE="var/run/portsentry/portsentry.blocked"
To ->
IGNORE_FILE="etc/portsentry/portsentry.ignore" IGNORE_FILE="etc/portsentry/portsentry.history" IGNORE_FILE="etc/portsentry/portsentry.blocked"#KILL_ROUTE="/sbin/route add -host $TARGET$ reject"
KILL_ROUTE="/sbin/route add -host $TARGET$ reject"
Step 3 : Exclude You may want exclude some IP address or port from portsentry blocking to avoid false positive (Recommended) To exclude IP address from portsentry blocking, edit the portsentry.ignore file.
vi /etc/portsentry/portsentry.ignoreThen add the IP address you want to exclude e.g :
- 127.0.0.1
- 192.168.1.1
- 192.168.1.0/24
vi /etc/portsentry.confThen add the port you want to exclude e.g :
- ADVANCED_EXCLUDE_TCP=”22,80″
- ADVANCED_EXCLUDE_UDP=”53″
- Select tabs system - startup
- Find portsentry at initscript
- Click enabled and start
You've finished the steps!
Testing
To test if portsentry work properly.- In Linux
- Install Nmap first
- nmap -T4 -F 192.168.x.xxx (Your router or server ip address)
- After scanning complete try accessing your router web page or ssh
- It will be blocked
- Install port scanner e.g. (Angry IP Scanner, Advanced IP Scanner, or Nmap)
- Point IP address to router/server IP address.
- After scanning complete, try to access router web page or ssh
- It will be blocked
Troubleshooting
If there are port service can't be used or doesn't work after installation of portsentry. It is most likely the port is blocked by the portsentry. Try to read the system log to troubleshoot portsentry and exclude the IP address or port number. - On SSH- "logread"
- Select Tabs Status - System Log
Comments
Post a Comment