What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

User Script runs... but doesn't?

Dulanic

New Around Here
I am attempting to route traffic to a specific IP to a local network IP due to loopback issues with my ISP's device. I have researched some and this command when run on the router seems to correct my issue:
Code:
iptables -t nat -A PREROUTING -p tcp -d 123.123.123.123 -j DNAT --to 192.168.2.155
So to run this automatically I telnet into the router and went to /jffs/scripts and created a file for nat-start and it does run per the log. It is also enabled in the Admin/System tab.
Code:
Jul 31 19:00:14 custom script: Running /jffs/scripts/nat-start
This is my script and it's permissions. I've also tried adding sleep to it to delay it some?
Code:
#!/bin/sh
sleep 30
iptables -t nat -A PREROUTING -p tcp -d 123.123.123.123 -j DNAT --to 192.168.2.155
Code:
-rwxrwxrwx    1 me root           103 Nov 19 19:48 nat-start
-rwxrwxrwx    1 me root           103 Nov 19 19:53 services-start

It works if I run ./nat-start and traffic is properly routed so I assume it's not a script problem... maybe it's a timing issue? But if thats the case, I would think the sleep would fix it?
 
How did you create the script? If you didn't use vi or nano on the router, telnet/ssh to the router and run

dos2unix /jffs/scripts/nat-start
 
Try inserting the rule instead of adding it.....

-I PREROUTING instead of -A PREROUTING
 
Same result, works if I run the script manually but no change on boot even though it runs...

Jul 31 19:00:14 custom script: Running /jffs/scripts/nat-start
 
OK so not sure what fixed it... I still had sleep in there and I removed that to be sure that wasn't the problem but I also had a extra line before sleep. Removed both and it worked this time /w -I so maybe it was the -I maybe it was the sleep maybe it was the extra line.. not sure. But it worked this reboot!

Thanks!
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top