Koozali.org: home of the SME Server

Invalid target name `DROP' when doing a template fragment on Windows PC [Resolved]

Offline rcblackwell

  • *
  • 8
  • +0/-0
I'm having no end of trouble attempting block a single IP and a range of IP addresses using information found at http://wiki.contribs.org/Firewall. Specifically, the section that describes who to Block incoming IP address. I've followed the instruction on that page exactly as written however I'm unable to restart masq without errors. My custom template is stored in the /etc/e-smith/templates-custom/etc/rc.d/init.d/masq as described in the wiki. The template file is named 40DenyRiffRaff and contains two lines;

Code: [Select]
/sbin/iptables -A INPUT -s 37.140.141.0/24 -j DROP
/sbin/iptables -A INPUT -s 58.218.199.250 -j DROP


After saving the above noted file I execute the commands;

Code: [Select]
/sbin/e-smith/expand-template /etc/rc.d/init.d/masq
/etc/init.d/masq restart

This results in the an error;

Code: [Select]
Shutting down IP masquerade and firewall rules:         Done!

'nabling IP masquerading: iptables v1.3.5: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
Bad argument `/sbin/iptables'
Try `iptables -h' or 'iptables --help' for more information.
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
done

I've checked my entries several times and have tried one line at a time however the above noted error or a similar error occurs;

Code: [Select]
Shutting down IP masquerade and firewall rules:         Done!

Enabling IP masquerading: Bad argument `/sbin/iptables'
Try `iptables -h' or 'iptables --help' for more information.
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
done

I have searched the FAQ's and Googled the error without resolve. Please advise what I might be doing incorrectly so that I may correct my error and block the offending IP's from pounding on my server.

With appreciation
« Last Edit: October 13, 2012, 09:32:10 PM by rcblackwell »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
I suspect your post is off-topic for this particular forum, since it concerns your  own customisations.

This post:

http://www.redhat.com/archives/enigma-list/2002-March/msg01584.html

suggests that you have created your template fragment on Windows, and using 'dos2unix' will correct the problem.

If you run:

sh -x /etc/rc.d/init.d/masq stop
sh -x /etc/rc.d/init.d/masq start

you will be able to isolate the line causing the problem.

Using 'cat -v /etc/rc.d/init.d/masq' will visualize any non-printable characters.

Offline zatnikatel

  • *****
  • 190
  • +0/-0
should it not be /sbin/iptables -A INPUT -s TCP 37.140.141.0/24 -j DROP not sure if the TCP should be in caps

/sbin/iptables -A INPUT -p tcp -m tcp -s 10.5.2.0/23 --dport 22 -j DROP here is another so you get an idea of iptables this one just drops an internal lan one port but i gives you more of an idea were you are going wrong the --dport 22 just blokes port 22 on the internal lan i am not a guru in iptables some one else may have a better idea

I'm having no end of trouble attempting block a single IP and a range of IP addresses using information found at http://wiki.contribs.org/Firewall. Specifically, the section that describes who to Block incoming IP address. I've followed the instruction on that page exactly as written however I'm unable to restart masq without errors. My custom template is stored in the /etc/e-smith/templates-custom/etc/rc.d/init.d/masq as described in the wiki. The template file is named 40DenyRiffRaff and contains two lines;

Code: [Select]
/sbin/iptables -A INPUT -s 37.140.141.0/24 -j DROP
/sbin/iptables -A INPUT -s 58.218.199.250 -j DROP


After saving the above noted file I execute the commands;

Code: [Select]
/sbin/e-smith/expand-template /etc/rc.d/init.d/masq
/etc/init.d/masq restart

This results in the an error;

Code: [Select]
Shutting down IP masquerade and firewall rules:         Done!

'nabling IP masquerading: iptables v1.3.5: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
Bad argument `/sbin/iptables'
Try `iptables -h' or 'iptables --help' for more information.
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
done

I've checked my entries several times and have tried one line at a time however the above noted error or a similar error occurs;

Code: [Select]
Shutting down IP masquerade and firewall rules:         Done!

Enabling IP masquerading: Bad argument `/sbin/iptables'
Try `iptables -h' or 'iptables --help' for more information.
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
done

I have searched the FAQ's and Googled the error without resolve. Please advise what I might be doing incorrectly so that I may correct my error and block the offending IP's from pounding on my server.

With appreciation
« Last Edit: October 13, 2012, 07:08:39 AM by zatnikatel »

Offline rcblackwell

  • *
  • 8
  • +0/-0
I suspect your post is off-topic for this particular forum.........

This post:

http://www.redhat.com/archives/enigma-list/2002-March/msg01584.html

suggests that you have created your template fragment on Windows......

I suspect your post is off-topic for this particular forum, since it concerns your  own customisations.

.... suggests that you have created your template fragment on Windows

Charlie,

Your hunch was right on the mark! Although I was using Notepad++ in Unix mode to create and save my file, it appears proper 'nix line endings were not being created. Creating the file with nano then executing masq rebuild and restart commands resolved the issue.

Thanks for pointing me in the right direction.

As an aside, I wasn't sure which forum to select when posting. I chose this one thinking it was a 'configuration' issue not one of customization. For future reference, which forum should questions such as this be posted?

Robert Blackwell

Offline janet

  • *****
  • 4,812
  • +0/-0
rcblackwell

Quote
As an aside, I wasn't sure which forum to select when posting. I chose this one thinking it was a 'configuration' issue not one of customization. For future reference, which forum should questions such as this be posted?

That should be easy to determine based on the following forum heading:

SME 8.x Contribs
Discussions related to development and use of addons for SME Server. Discuss user-contributed rpms, howto's and scripts here.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Moving to General Discussions and amending Subject to make it easier for search.  Good topic, should be documented in the Wikis if not there already.

Note:
"Discussions about contribs.org, Linux in general, and other topics that don't belong in the other forums.
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.