• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

iptables script.....

Dark Atheist

Moderator
Staff member
Political User
#1
on which i think i have dropped the proverbial nad

#!/bin/bash
ext_if=eth0
int_if=eth1
iptables -F INPUT
iptables -P INPUT DROP
iptables -F OUTPUT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
accept_port="80 443 2010 9000:9000"
names="some.dns.name1 some.dns.name2 some.dns.name3 some.dns.name4"
iptables -A INPUT -i $ext_if -j DROP
iptables -A INPUT -i $int_if -s 164.168.1.1/24 -j ACCEPT
iptables -A INPUT -i $ext_if -s 192.168.1.1/24 -j ACCEPT
for ip in $names
do
for port in $accept_ports
do
iptables -A INPUT -i $ext_if -s $ip --dport $ip --syn -m state --state NEW -j ACCEPT
done
done

is what i believe should give me control about who can access certain things on my server (web fftp)

thing is since running this script it is also blocking me on the lan too!!!! i cant see web pages or connect to my own ftp :(

any Sharpe eyed person out there see where i messed up (and no saying well you wrote it is neither a reason nor helpful, it also wont get you reps or a cookie)
 

Dark Atheist

Moderator
Staff member
Political User
#4
seems it was iptables -A INPUT -i $ext_if -j DROP that line looks like i might have it in the rong place - still least i can connect to my server now, and also shame i have blocked other ports :p still i can add them
 

Members online

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,242
Members
89,017
Latest member
Seggar