The previous thread on this subject is old, from 2015, and morphed into a discussion of version numbers and dos2unix without a complete answer on why it wouldn't run so I have started this thread.
Background:
The need here is to block specific inbound IP addresses per the request of the VoIP service provider, as these addresses are known sources of VoIP server hack attempts but VoIP ports must stay open. This is on an AC-1900P router flashed the latest RT-AC68U Merlin firmware (384.5)
I am DOS/Windows/computer/microcontroller assembly savvy, but pretty much a Linux nOOb. By that I mean that I can run command line interface and will understand the theory of what you might tell me but not the details of any specific commands other than the most basic ones without clear explanations. I hope that helps you frame any answers.
Up to this point I have used the information in the 2015 thread (https://www.snbforums.com/threads/solved-blocking-specific-incoming-ip-addresses.28805/page-2) along with other research and created this firewall-start script in /jffs/scripts. The script was created using vi so there is no DOS-Unix file format issue.
The system log only shows that the script was called but nothing else happens:
Jun 5 09:51:47 rc_service: ntp 443:notify_rc restart_diskmon
Jun 5 09:51:47 rc_service: waitting "start_firewall" via udhcpc ...
Jun 5 09:51:48 nat: apply nat rules (/tmp/nat_rules_eth0_eth0)
Jun 5 09:51:49 nat: apply nat rules (/tmp/nat_rules_eth0_eth0)
Jun 5 09:51:49 kernel: nf_conntrack_rtsp v0.6.21 loading
Jun 5 09:51:49 kernel: nf_nat_rtsp v0.6.21 loading
Jun 5 09:51:50 custom_script: Running /jffs/scripts/firewall-start (args: eth0)
Jun 5 09:51:50 rc_service: udhcpc 425:notify_rc start_upnp
Jun 5 09:51:50 rc_service: waitting "stop_upnp" via udhcpc ...
Jun 5 09:51:50 disk_monitor: Finish
Jun 5 09:51:52 disk_monitor: be idle
Jun 5 09:51:52 miniupnpd[555]: HTTP listening on port 47121
Jun 5 09:51:52 miniupnpd[555]: Listening for NAT-PMP/PCP traffic on port 5351
Jun 5 09:51:52 dhcp_client: bound 192.168.0.194 via 192.168.0.1 during 86400 seconds.
Jun 5 09:52:20 crond[280]: time disparity of 686272 minutes detected
The file permissions seem correct:
-rwxr-xr-x 1 admin root 341 Jun 5 10:55 firewall-start
In the router settings:
Format JFFS partition at next boot = No
Enable JFFS custom scripts and configs = Yes
When I run the script from the command line it appears to work. I know that because the two start and stop files were created in the /tmp directory and this line is in the system log:
Jun 5 11:30:35 admin: Applying firewall-start rules
I'm sure that I am missing something obvious to a knowledgeable Linux user. Anything that would point me in the right direction would be appreciated.
Background:
The need here is to block specific inbound IP addresses per the request of the VoIP service provider, as these addresses are known sources of VoIP server hack attempts but VoIP ports must stay open. This is on an AC-1900P router flashed the latest RT-AC68U Merlin firmware (384.5)
I am DOS/Windows/computer/microcontroller assembly savvy, but pretty much a Linux nOOb. By that I mean that I can run command line interface and will understand the theory of what you might tell me but not the details of any specific commands other than the most basic ones without clear explanations. I hope that helps you frame any answers.
Up to this point I have used the information in the 2015 thread (https://www.snbforums.com/threads/solved-blocking-specific-incoming-ip-addresses.28805/page-2) along with other research and created this firewall-start script in /jffs/scripts. The script was created using vi so there is no DOS-Unix file format issue.
Code:
#!/bin/sh
touch /tmp/000firewall-start
logger "Applying firewall-start rules"
iptables -I FORWARD -s xxx.172.121.124 -j DROP
iptables -I FORWARD -s xxx.23.181.142 -j DROP
iptables -I FORWARD -s xxx.154.41.135 -j DROP
iptables -I FORWARD -s xxx.210.157.169 -j DROP
iptables -I FORWARD -s xxx.83.138.191 -j DROP
touch /tmp/000firewall-stop
The system log only shows that the script was called but nothing else happens:
Jun 5 09:51:47 rc_service: ntp 443:notify_rc restart_diskmon
Jun 5 09:51:47 rc_service: waitting "start_firewall" via udhcpc ...
Jun 5 09:51:48 nat: apply nat rules (/tmp/nat_rules_eth0_eth0)
Jun 5 09:51:49 nat: apply nat rules (/tmp/nat_rules_eth0_eth0)
Jun 5 09:51:49 kernel: nf_conntrack_rtsp v0.6.21 loading
Jun 5 09:51:49 kernel: nf_nat_rtsp v0.6.21 loading
Jun 5 09:51:50 custom_script: Running /jffs/scripts/firewall-start (args: eth0)
Jun 5 09:51:50 rc_service: udhcpc 425:notify_rc start_upnp
Jun 5 09:51:50 rc_service: waitting "stop_upnp" via udhcpc ...
Jun 5 09:51:50 disk_monitor: Finish
Jun 5 09:51:52 disk_monitor: be idle
Jun 5 09:51:52 miniupnpd[555]: HTTP listening on port 47121
Jun 5 09:51:52 miniupnpd[555]: Listening for NAT-PMP/PCP traffic on port 5351
Jun 5 09:51:52 dhcp_client: bound 192.168.0.194 via 192.168.0.1 during 86400 seconds.
Jun 5 09:52:20 crond[280]: time disparity of 686272 minutes detected
The file permissions seem correct:
-rwxr-xr-x 1 admin root 341 Jun 5 10:55 firewall-start
In the router settings:
Format JFFS partition at next boot = No
Enable JFFS custom scripts and configs = Yes
When I run the script from the command line it appears to work. I know that because the two start and stop files were created in the /tmp directory and this line is in the system log:
Jun 5 11:30:35 admin: Applying firewall-start rules
I'm sure that I am missing something obvious to a knowledgeable Linux user. Anything that would point me in the right direction would be appreciated.