Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a firewall script that actually isn't a script. This thing won't run and seeing as it 's the first time I've dont something like this problems have come up. The current script is run like this:
Code:
[root@mun-175-25 lorenzo]# ls
plenum.odt CDProgram ethereal-0.10.11 Mu
bluej-205.jar Desktop HOWTOFixYum rules
[root@mun-175-25 lorenzo]# chmod +x rules
[root@mun-175-25 lorenzo]# ./rules
: bad interpreter: No such file or directory
[root@mun-175-25 lorenzo]# ls
plenum.odt CDProgram ethereal-0.10.11 Mu rules~
bluej-205.jar Desktop HOWTOFixYum rules
[root@mun-175-25 lorenzo]#
Code:
#!/bin/sh
# Generated by michaelsanford at linuxquestions.org ;)
# It's always good to have variables for things like this
IPTABLES="/sbin/iptables"
# Flush the tables, zero counters and custom chains (in case the script re-runs while the system is already running)
$IPTABLES -t nat -F
$IPTABLES -t filter -F
$IPTABLES -t nat -Z
$IPTABLES -t filter -Z
$IPTABLES -t nat -X
$IPTABLES -t filter -X
# Set up the POLICY and make the custom chains
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -A POSTROUTING -m mark --mark 0x9 -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j ACCEPT
$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#mangle
$IPTABLES -t mangle -P FORWARD ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 0x9
# The filter table
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
# Create custom chains
$IPTABLES -N in_icmp
$IPTABLES -N in_tcp
$IPTABLES -N syn-flood
$IPTABLES -A FORWARD -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j syn-flood
$IPTABLES -A INPUT -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
..... Similar code the rest of the way using -A
I took a look at this dos2unix thing. I think that may be the problem since i made the script in windows and then uploaded it via FTP. although i did reformat it to be a script I still needed to do the conversion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.