LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2009, 05:14 AM   #1
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Rep: Reputation: 0
rc.local is not executable


Hi guys!

Im using squid for a SOHO running on Debian etch. It worked fine for a couple of weeks before I tried to block all ports except for the ones we will need in iptables.

The thing is, I edited the rc.local script to enter the new rules I found online using my windows workstation.

When I restarted the script by ./rc.local, it gave me the error -bash: ./rc.local: Bad interpreter bin/sTh and then my box stoped giving clients on the network connection to the internet.

I then tried to put back my original configuration in rc.local which is /sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

but then again, same errors. it seemed that the rules were no longer executable cause they were no longer color coded.

I would appreciate any help from you masters.

Thanks!
 
Old 01-28-2009, 05:38 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
./rc.local, it gave me the error -bash: ./rc.local: Bad interpreter bin/sTh
Take a look at the 1st line of rc.local because the sebang is wrong. It should be
Code:
#!/bin/sh
 
Old 01-28-2009, 08:44 AM   #3
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks bathory. had it fixed immediately.

If you dont mind me asking one more thing though. This is actually the very reason why my proxy got screwed in the 1st place.

How do i block all ports from the server and only allow the common ports we need like 80, 8080, 25, 110, 143, 993, 22, 1863 and then all else is blocked.

Thanks in advance!
 
Old 01-28-2009, 09:12 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You can use something like the following:
Code:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
...
<same as above changing the port number you want to allow>
...
iptables -A INPUT -i eth0 -p tcp --dport 0:65535 -j DROP
Regards
 
Old 01-28-2009, 09:28 AM   #5
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks sir! will try this immediately
 
Old 01-29-2009, 01:05 AM   #6
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Hi sir,

it seems that i can still download from limewire and ftp sites.

I followed the rules you gave me and wrote it in my rc.local script.

i know this sounds a bit dumb but do i have to lose the line

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

in my rc.local script?

currently this is what i have:

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
......(for other ports i need opened)
iptables -A INPUT -i eth0 -p tcp --dport 0:65535 -j DROP

thanks in advance.
 
Old 01-29-2009, 02:30 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
i know this sounds a bit dumb but do i have to lose the line
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
These rules are for NAT and port forwarding. So it's up to you to see if you need them.
Mind that you don't have to put any iptables rules in rc.local. You can create a rc.firewall file (just make sure it's executable) and write there your rules. Slackware by default looks for this file on boot and if it find it, it executes it.
There is also a nice script named quicktables you can use to create the rc.firewall file.
 
Old 01-29-2009, 02:48 AM   #8
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks! I'll take a look at it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i add a local Folder on local Hard Disk as Yum Repository ?? vahid_p Fedora 4 02-22-2007 10:43 AM
Setup local machine to allow lan machines to retrieve its local user mail. Brian1 Linux - Networking 3 03-30-2006 05:04 AM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
Local webserver -- How to deny all client install their local web server--Please help b:z Linux - Networking 13 04-16-2005 07:11 PM
Webmin: The Apache server executable /usr/local/apache2/bin does not exist hektor Linux - Software 0 01-14-2005 06:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration