Iptables
Greetings,
Sort of still a newbie with iptables! I ve been at it for a while, but struggle to understand when things don't work when I think they are right.
OK heres the problem:
I have a dns server configure, master zone int network, slave is external dns box.
Dhcp server only internal.
Iptables must do the following:
allow one int ip (me) to the external int face for everything. (the external interface is actually our other internal network which has the gateway to the internet)
when I set my default policy to drop, my DNS and windows file sharing from the ext network doesn't work. My mail and internet still work. I have removed the broken lines and set my policy back to ACCEPT. But I would feel much safer if it were drop and only allow services that I choose. As it is now, I can access the net, mail and windows file shares, the dns for the FTP server is working and all is bliss.
How do I make this more secure?
etel is our gateway
my router has 6 cards in it. 5 are bond0 1 eth0 int and ext respectively.
Attached is my iptables file,
Please could some one show me what is wrong I can't figure it out.
Signature · 8 lines
Chadley Wilson Redhat Certified Technician Cert Number: 603004708291270 Pinnacle Micro Manufacturers of Proline Computers ==================================== Exercise freedom, Use LINUX =====================================
######## Firewall Setup ##################
######## Config ##################
#set -x
ipt="/usr/sbin/iptables"
ext="eth0"
int="bond0"
lo="127.0.0.1"
chad="192.168.2.5"
etel="196.25.100.28"
#################################################
#################################################
#### #### #### BASIC SETUP #### #### ####
#################################################
#Enable IP Forwarding
echo "1" >> /proc/sys/net/ipv4/ip_forward
#Clear All Tables
${ipt} -t filter -F
${ipt} -t nat -F
## Allow all from local interfaces [localhost]
${ipt} -t filter -A INPUT -s ${lo} -j ACCEPT
## Allow all prerouting
${ipt} -t nat -A PREROUTING -s 192.168.2.0/255.255.255.0 -j ACCEPT ${ipt} -t nat -A PREROUTING -s 196.25.100.5/255.255.255.0 -j ACCEPT
## Allow all forwarding
${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -m state --state RELATED,ESTABLISHED -j ACCEPT ${ipt} -t filter -A FORWARD -i ${ext} -o ${int} -m state --state RELATED,ESTABLISHED -j ACCEPT
## Allow pings
${ipt} -t filter -A INPUT -p icmp -j ACCEPT
## Keep established connections on all interfaces
${ipt} -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT ${ipt} -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
## Accept www from internet {ext}
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 80 -j ACCEPT
#################################################
#### #### #### RULES #### #### ####
#################################################
## Masquerade {chad} outgoing to internet
${ipt} -t nat -A POSTROUTING -o ${ext} -s ${chad} -j MASQUERADE ${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -s ${chad} -j ACCEPT
## Accept SSH from {etel}
${ipt} -t filter -A INPUT -i ${ext} -s ${etel} -p tcp --dport 22 -j ACCEPT
## Accept ssh from all internal
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 22 -j ACCEPT
## Accept telnet
${ipt} -t filter -A INPUT -p tcp --dport 23 -j ACCEPT ${ipt} -t filter -A INPUT -p udp --dport 23 -j ACCEPT
## Accept incoming SMTP
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 25 -j ACCEPT
## Accept external POP3
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 110 -j ACCEPT
## Allow mail from ext to int
${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 25 --state NEW,ESTABLISHED,RELATED -j ACCEPT ${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 110 --state NEW,ESTABLISHED,RELATED -j ACCEPT
## Allow DNS updates
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 53 -j ACCEPT ${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 53 -j ACCEPT
## Accept all from local interfaces
${ipt} -t filter -A INPUT -i ${int} -j ACCEPT
${ipt} -t filter -A INPUT -i ${int} -j ACCEPT
## Drop all the rest, incoming , and forward between interfaces #${ipt} -t filter -A INPUT -j DROP
#${ipt} -t filter -A FORWARD -j DROP
### END OF FIREWALL ###
rebuilding an OpensourceVideoconferencechattool
Hello richard, Experts ,
Sorry for my offtopic post,
During our maillinglist disscussions
in the emac-list i thought of making an announcement.
Long times ago, there was a smart video chat tool, called CuSeeMe. I am tied a little bit on the tool. Nowadays with the all this Streaming Servers the time for video chat tools is coming back with power.
So, I thought, it would be a smart idea to
bring CuSeeMee back.
Now I found, that the sources of CuSeeMe are
no longer available. Somehow they are gone.
What do you think about the idea of rebuilding it ?
i am looking for people that want to join this
free open source project.
based on: <http://quicktimetcl.sourceforge.net/>
and <http://www.openquicktime.org/>
this could help<http://homepage.mac.com/netmaster_bruce/>
and this: <http://ashcast.org/>
more about the cuseeme history:
<http://www.geektimes.com/michael/CU-SeeMe/internetTVwithCUSeeMe/index.html>
CU-SeeMe WAS a free peer-to-peer videoconferencing program that allows interactive multiparty video and voice communication over the Internet or any local TCP/IP-based network.
a free downloadable version for osx 10.41 tiger ROARR!!
http://vchat.cu-seeme.org/download.html
and my testreflctor
cuseeme:// 207.44.156.3 CID 0
Max send.14 Max. Recieve.40
more about configuration;
and i am happy for anyone who is interested joining this great opensource project and
will answer any question regarding this waiting for any replys.
So once again, sorry for bothering you with, perhaps an Off-Topic theme.
have a nice day or night
Greetings from old europe
please spread the word
marc manthey
Signature · 10 lines
"In a world without walls or fences, who needs Windows and Gates?" Les Enfants Terribles Network office: 0049.221.355.80.32 mobile: 0049.177.341.54.81 http://www.cuseeme.de http://brain.let.de http://www.applehelpers.com aim://macfreak2004 [email protected]
Quoted 47 lines · Chadley Wilson
Greetings,
Sort of still a newbie with iptables! I ve been at it for a while, but struggle to understand when things don't work when I think they are right.
OK heres the problem:
I have a dns server configure, master zone int network, slave is external dns box.
Dhcp server only internal.
Iptables must do the following:
allow one int ip (me) to the external int face for everything. (the external interface is actually our other internal network which has the gateway to the internet)when I set my default policy to drop, my DNS and windows file sharing from the ext network doesn't work. My mail and internet still work. I have removed the broken lines and set my policy back to ACCEPT. But I would feel much safer if it were drop and only allow services that I choose. As it is now, I can access the net, mail and windows file shares, the dns for the FTP server is working and all is bliss.
How do I make this more secure?etel is our gateway
my router has 6 cards in it. 5 are bond0 1 eth0 int and ext respectively.Attached is my iptables file,
Please could some one show me what is wrong I can't figure it out.
######## Firewall Setup ##################
######## Config ##################
#set -x
ipt="/usr/sbin/iptables"
ext="eth0"
int="bond0"
lo="127.0.0.1"
chad="192.168.2.5"
etel="196.25.100.28"
##################################################################################################
#### #### #### BASIC SETUP #### #### ####
Quoted 8 lines
#################################################
#Enable IP Forwarding
echo "1" >>/proc/sys/net/ipv4/ip_forward#Clear All Tables
${ipt} -t filter -F
${ipt} -t nat -F
there's also a mangle table...
iptables -t mangle -F
Quoted 7 lines
## Allow all from local interfaces [localhost]
${ipt} -t filter -A INPUT -s ${lo} -j ACCEPT## Allow all prerouting
${ipt} -t nat -A PREROUTING -s 192.168.2.0/255.255.255.0 -j ACCEPT ${ipt} -t nat -A PREROUTING -s 196.25.100.5/255.255.255.0 -j ACCEPT
um--what exactly are you trying to accomplish with these?
Quoted 3 lines
## Allow all forwarding
${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -m state --state RELATED,ESTABLISHED -j ACCEPT ${ipt} -t filter -A FORWARD -i ${ext} -o ${int} -m state --state RELATED,ESTABLISHED -j ACCEPT
how about just:
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
Quoted 5 lines
## Allow pings
${ipt} -t filter -A INPUT -p icmp -j ACCEPT## Keep established connections on all interfaces
${ipt} -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
we just did this above...
Quoted 4 lines
${ipt} -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
## Accept www from internet {ext}
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 80 -j ACCEPT
you run a web server on your firewall?
Quoted 13 lines
#################################################
#### #### #### RULES #### #### #####################################################
## Masquerade {chad} outgoing to internet
${ipt} -t nat -A POSTROUTING -o ${ext} -s ${chad} -j MASQUERADE ${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -s ${chad} -j ACCEPT## Accept SSH from {etel}
${ipt} -t filter -A INPUT -i ${ext} -s ${etel} -p tcp --dport 22 -j ACCEPT
Quoted 6 lines
## Accept ssh from all internal
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 22 -j ACCEPT## Accept telnet
${ipt} -t filter -A INPUT -p tcp --dport 23 -j ACCEPT ${ipt} -t filter -A INPUT -p udp --dport 23 -j ACCEPT
1) telnet only uses TCP, not UDP.
2) telnet? c'mon, what is this? 1997?
Quoted 5 lines
## Accept incoming SMTP
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 25 -j ACCEPT## Accept external POP3
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 110 -j ACCEPT
you run SMTP and POP3 servers on your firewall too? i'm sensing a pattern here...
Quoted 3 lines
## Allow mail from ext to int
${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 25 --state NEW,ESTABLISHED,RELATED -j ACCEPT ${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 110 --state NEW,ESTABLISHED,RELATED -j ACCEPT
um--we've already ACCEPTed all ESTABLISHED,RELATED packets in FORWARD--so it's redundant to keep using them in rules. so we need to create rules that allow packets that are NEW. if you're trying to allow $chad to connect to 196.25.100.21 on SMTP and POP3--those should be dport, not sport:
iptables -A FORWARD -i $int -o $ext -p tcp -s $chad \
-d 196.25.100.21 --dport 25 -j ACCEPT
iptables -A FORWARD -i $int -o $ext -p tcp -s $chad \
-d 196.25.100.21 --dport 110 -j ACCEPTfrom the text of you message, you want to allow $chad out on any service, though--right? then how about:
iptables -A FORWARD -i $int -o $ext -p tcp -s $chad -j ACCEPT
(which you already have in here if we scroll back up a bit)
Quoted 3 lines
## Allow DNS updates
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 53 -j ACCEPT ${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 53 -j ACCEPT
the DNS server runs on the firewall too, eh? how's about:
iptables -A INPUT -p tcp --dport 53 -j ACCEPT iptables -A INPUT -p udp --dport 53 -j ACCEPT
(you need TCP for zone transfers, and UDP for regular name resolution requests)
Quoted 3 lines
## Accept all from local interfaces
${ipt} -t filter -A INPUT -i ${int} -j ACCEPT
${ipt} -t filter -A INPUT -i ${int} -j ACCEPT
a rule so nice, we need it twice?
Quoted 3 lines
## Drop all the rest, incoming , and forward between interfaces #${ipt} -t filter -A INPUT -j DROP
#${ipt} -t filter -A FORWARD -j DROP
-j
--
"Peter: Hey, Brian. If cops are pigs, does that make you a Snausage?
Brian: Clever, Peter. Did you stay up all night writing that?
Peter: No, I got to bed around two, two-thirty."
--Family Guy
Quoted 17 lines · Jason Opperisano
Quoted 17 lines
######## Firewall Setup ##################
######## Config ##################
#set -x
ipt="/usr/sbin/iptables"
ext="eth0"
int="bond0"
lo="127.0.0.1"
chad="192.168.2.5"
etel="196.25.100.28"
##################################################################################################
#### #### #### BASIC SETUP #### #### #####################################################
Quoted 8 lines
Quoted 6 lines
#Enable IP Forwarding
echo "1" >>/proc/sys/net/ipv4/ip_forward#Clear All Tables
${ipt} -t filter -F
${ipt} -t nat -Fthere's also a mangle table...
How would the mangle table work for me?
Well actually what does mangle do in english, I have read the man pages and some docs I found on google and tldp, but I don't quite grasp the idea.
Quoted 11 lines
iptables -t mangle -F
Quoted 7 lines
## Allow all from local interfaces [localhost]
${ipt} -t filter -A INPUT -s ${lo} -j ACCEPT## Allow all prerouting
${ipt} -t nat -A PREROUTING -s 192.168.2.0/255.255.255.0 -j ACCEPT ${ipt} -t nat -A PREROUTING -s 196.25.100.5/255.255.255.0 -j ACCEPTum--what exactly are you trying to accomplish with these?
I think it had some thing to do with setting the default policy to drop! and having no access to any services, I never really worked out if this was the cause.
Quoted 7 lines
Quoted 5 lines
## Allow all forwarding
${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -m state --state RELATED,ESTABLISHED -j ACCEPT ${ipt} -t filter -A FORWARD -i ${ext} -o ${int} -m state --state RELATED,ESTABLISHED -j ACCEPThow about just:
Cool, it take it this achieves the same goal?
Quoted 9 lines
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPTQuoted 6 lines
## Allow pings
${ipt} -t filter -A INPUT -p icmp -j ACCEPT## Keep established connections on all interfaces ${ipt} -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
Quoted 8 lines
we just did this above...
Quoted 4 lines
${ipt} -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
## Accept www from internet {ext}
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 80 -j ACCEPTyou run a web server on your firewall?
Uh no I ctually run an FTP server, I thought I needed to open port 80 to access the internet. (as I said before I am a newbie, still wet behind the ears :) )
Quoted 17 lines
Quoted 17 lines
#################################################
#### #### #### RULES #### #### #####################################################
## Masquerade {chad} outgoing to internet
${ipt} -t nat -A POSTROUTING -o ${ext} -s ${chad} -j MASQUERADE ${ipt} -t filter -A FORWARD -i ${int} -o ${ext} -s ${chad} -j ACCEPT## Accept SSH from {etel}
${ipt} -t filter -A INPUT -i ${ext} -s ${etel} -p tcp --dport 22 -j ACCEPT## Accept ssh from all internal
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 22 -j ACCEPT
Quoted 7 lines
Quoted 3 lines
## Accept telnet
${ipt} -t filter -A INPUT -p tcp --dport 23 -j ACCEPT ${ipt} -t filter -A INPUT -p udp --dport 23 -j ACCEPT1) telnet only uses TCP, not UDP.
2) telnet? c'mon, what is this? 1997?
Our SCO-Unix box has not got ssh and it is linked nationwide to 500 dial-up and dial-in sites all of which were setup in "1997" :} by someone else. So we have to be able to telnet in and out of it. Offen I have files on my server, which I need to access from a remote site via the SCO box using telnet. :(
Quoted 8 lines
Quoted 5 lines
## Accept incoming SMTP
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 25 -j ACCEPT## Accept external POP3
${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 110 -j ACCEPTyou run SMTP and POP3 servers on your firewall too? i'm sensing a pattern here...
No but I need to able to receive mail from my mail box on the ${ext} interface!
I take it this is wrong hey!
Quoted 8 lines
Quoted 7 lines
## Allow mail from ext to int
${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 25 --state NEW,ESTABLISHED,RELATED -j ACCEPT ${ipt} -t filter -A FORWARD -p tcp -m tcp -m state -s ${chad} -d 196.25.100.21 -o ${ext} --sport 110 --state NEW,ESTABLISHED,RELATED -j ACCEPT
Quoted 6 lines
um--we've already ACCEPTed all ESTABLISHED,RELATED packets in FORWARD--so it's redundant to keep using them in rules. so we need to create rules that allow packets that are NEW. if you're trying to allow $chad to connect to 196.25.100.21 on SMTP and POP3--those should be dport, not sport:
OK! I see the logic.
This is a new trick for me, Thanks
I haven't read about -d <ip_addr> before!
Quoted 12 lines
iptables -A FORWARD -i $int -o $ext -p tcp -s $chad \ -d 196.25.100.21 --dport 25 -j ACCEPT iptables -A FORWARD -i $int -o $ext -p tcp -s $chad \ -d 196.25.100.21 --dport 110 -j ACCEPTfrom the text of you message, you want to allow $chad out on any service, though--right? then how about:
iptables -A FORWARD -i $int -o $ext -p tcp -s $chad -j ACCEPT
Quoted 8 lines
(which you already have in here if we scroll back up a bit)
Quoted 3 lines
## Allow DNS updates
${ipt} -t filter -A INPUT -i ${int} -p tcp --dport 53 -j ACCEPT ${ipt} -t filter -A INPUT -i ${ext} -p tcp --dport 53 -j ACCEPTthe DNS server runs on the firewall too, eh? how's about:
Yes the firewall is a DNS and DHCP server too. (I only have linux PC so I make it work).
Current with the default policy accept on the 196.25.100.0 network we can resolve the ftp url i.e ftp://ns.teq/
if I take out the ${ext} rule it doen't work.
Quoted 5 lines
iptables -A INPUT -p tcp --dport 53 -j ACCEPT iptables -A INPUT -p udp --dport 53 -j ACCEPT(you need TCP for zone transfers, and UDP for regular name resolution requests)
OK,
Quoted 7 lines
Quoted 4 lines
## Accept all from local interfaces
${ipt} -t filter -A INPUT -i ${int} -j ACCEPT
${ipt} -t filter -A INPUT -i ${int} -j ACCEPTa rule so nice, we need it twice?
Oops thats a mistake :)
Quoted 6 lines
Quoted 3 lines
## Drop all the rest, incoming , and forward between interfaces #${ipt} -t filter -A INPUT -j DROP
#${ipt} -t filter -A FORWARD -j DROP-j
Thanks Jason,
I have learn't quite a bit from this, I shall save this mail for future use. By the way, this is my first attempt at my own firewall, mostly an effort to learn and understand. I always used the Redhat default or Susefirewall2. But am not confident that they do the job right, also I never really understood how to customise them. Hence build your own, Ha hA, not s easy when you haven't got the knowledge, but I am sure I will get there.
Thanks again,
Signature · 8 lines
Chadley Wilson Redhat Certified Technician Cert Number: 603004708291270 Pinnacle Micro Manufacturers of Proline Computers ==================================== Exercise freedom, Use LINUX =====================================
Quoted 6 lines · Chadley Wilson
I have learn't quite a bit from this, I shall save this mail for future use. By the way, this is my first attempt at my own firewall, mostly an effort to learn and understand. I always used the Redhat default or Susefirewall2. But am not confident that they do the job right, also I never really understood how to customise them. Hence build your own, Ha hA, not s easy when you haven't got the knowledge, but I am sure I will get there.
might i suggest a reading of Oskar's tutorial:
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
-j
--
"Peter: Oh, and sorry about that comment earlier. I have that disease
that makes you swear involuntarily. Sonofabitch. Sonofabitch. Sonofabitch. See?"
--Family Guy
Quoted 13 lines · Jason Opperisano
Quoted 7 lines · Chadley Wilson
I have learn't quite a bit from this, I shall save this mail for future use. By the way, this is my first attempt at my own firewall, mostly an effort to learn and understand. I always used the Redhat default or Susefirewall2. But am not confident that they do the job right, also I never really understood how to customise them. Hence build your own, Ha hA, not s easy when you haven't got the knowledge, but I am sure I will get there.
might i suggest a reading of Oskar's tutorial:
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
Quoted 7 lines
-j
--
"Peter: Oh, and sorry about that comment earlier. I have that disease
that makes you swear involuntarily. Sonofabitch. Sonofabitch. Sonofabitch. See?"
--Family Guy
Would it be safe to set the OUTPUT default policy to ACCEPT? Every time I set it to DROP I get locked out, I suppose it has to do with the fact that I have no rules for the OUTPUT chain.
Signature · 8 lines
Chadley Wilson Redhat Certified Technician Cert Number: 603004708291270 Pinnacle Micro Manufacturers of Proline Computers ==================================== Exercise freedom, Use LINUX =====================================
Quoted 3 lines · Chadley Wilson
Would it be safe to set the OUTPUT default policy to ACCEPT? Every time I set it to DROP I get locked out, I suppose it has to do with the fact that I have no rules for the OUTPUT chain.
well, if you're not going to add any rules to OUTPUT, then--yeah, leave it at ACCEPT. the OUTPUT policy as ACCEPT or DROP is really more of an idealogical debate than anything else. personally, i set mine to DROP and only allow the traffic that is absolutely necessary to save me from myself (i.e. don't tempt the fw admin to use the fw as a shell account). things i deem necessary to allow out:
DNS
NTP
FTP/HTTP to update server IP's
ICMP
this is all politic, i don't intend any decree by the statements made here.
-j
--
"Lois: What's going on?
Stewie: We're playing house.
Lois: The boy is all tied up.
Stewie: Roman Polanski's house."
--Family Guy
Quoted 3 lines
Would it be safe to set the OUTPUT default policy to ACCEPT? Every time I set it to DROP I get locked out, I suppose it has to do with the fact that I have no rules for the OUTPUT chain.
A lot of people set OUTPUT policy to ACCEPT.
You can always do something like :
$ipt -P OUTPUT DROP
$ipt -A OUTPUT -p tcp --sport 1024: -j ACCEPT
$ipt -A OUTPUT -p udp --sport 1024: -j ACCEPT
$ipt -A OUTPUT -p icmp -j ACCEPT
This way a program cannot pretend to something like a web- or mailserver. If you check "/proc/sys/net/ipv4/ip_local_port_range" you see the local portrange (sport) your box will use. You can use this range in your rules. E.g. you could use "32768:61000" (if that is your range) instead of "1024:".
Gr,
Rob
Quoted 6 lines
Quoted 3 lines
Would it be safe to set the OUTPUT default policy to ACCEPT? Every time I set it to DROP I get locked out, I suppose it has to do with the fact that I have no rules for the OUTPUT chain.
A lot of people set OUTPUT policy to ACCEPT.
You can always do something like :
Forgot an important rule.. :
Quoted 1 line
$ipt -P OUTPUT DROP
$ipt -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
Quoted 1 line
$ipt -A OUTPUT -p tcp --sport 1024: -j ACCEPT
<...>
Gr,
Rob