LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-28-2008, 01:22 PM   #1
starmonche
Member
 
Registered: Jan 2007
Location: Overland Park
Distribution: Centos6
Posts: 60

Rep: Reputation: 15
port forwarding


this is a two part question =)

we have a secure ftp server that we're trying to protect by putting an extra layer between it and the 'net. the idea is to keep the SFTP server on the LAN and have a machine in the DMZ port forward the necessary ports (990 and 28000-28030) to it. eth0 connects to the internet and eth1 connects to the LAN.

first question: is this a good idea or is there a better way? (we don't want to put the SFTP server itself in the DMZ since local users here need to put files on it frequently)

second question: why in the world doesn't this script work? (note that i'm using port 80 to test since http should be fairly simple to get going)

/proc/sys/net/ipv4/ip_forward is set to 1 already

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -m --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.109
iptables -A FORWARD -s 10.0.0.109 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
 
Old 04-28-2008, 01:43 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I don't really see the point of what you're suggesting. The point of a DMZ is to hold a system in an intermediate security level between the internal LAN and external internet bedlam. What you're doing would totally invalidate the DMZ, as you would have a single TCP connection right from the net into your secure network. If you were going to have an intermediate system then you would generally convert the protocol at that point, or at the absolute least genuinely proxy the data to stop many attacks getting through.

A DMZ is also not necessarily inaccessible from the internal network, the only standard logic is that you can only pass form the internal network to the DMZ one, not the other way round, due to firewall constraints.
 
Old 04-28-2008, 04:39 PM   #3
starmonche
Member
 
Registered: Jan 2007
Location: Overland Park
Distribution: Centos6
Posts: 60

Original Poster
Rep: Reputation: 15
chris, what you're saying makes sense. we're using apache to proxy 443 and 80 to our internal web server but we couldn't find a tool to do the same with SFTP's ports. is it your consensus that the safest thing would be to keep the SFTP server in the DMZ and not allow it to touch the internal LAN at all?
 
Old 04-28-2008, 04:42 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
what product are you actually using? sftp is just ssh with a secondary subsystem in it... just port 22 and nothing else. google says you're actually trying to play blockland...

well *THE* safest thing is to have a literal airgap in the architecture, sharing power supplies and nothing else, but in reality there's little wrong in allowing some access through a firewall from lan to dmz, just not in the other direction.

Last edited by acid_kewpie; 04-28-2008 at 04:46 PM.
 
Old 04-29-2008, 06:29 AM   #5
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
Quote:
Originally Posted by starmonche View Post
this is a two part question =)
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -m --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.109
iptables -A FORWARD -s 10.0.0.109 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
Code:
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
EDIT: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.109 this is better.. otherwise it will send all of tcp 80 requests to 10.0.0.109

Last edited by maxut; 04-29-2008 at 06:32 AM.
 
Old 04-29-2008, 09:30 AM   #6
starmonche
Member
 
Registered: Jan 2007
Location: Overland Park
Distribution: Centos6
Posts: 60

Original Poster
Rep: Reputation: 15
Chris, we're using GlobalSCAPE Secure FTP for our SFTP needs.

Maxut, is your code snippet with the forward intended to replace my line with the forward?

Would it help security in any way if we had a linux box port forwarding 990 and 28000-28030 to the SFTP server even with the SFTP server in the DMZ also? We just want it to be as solid and safe as possible.
 
Old 04-29-2008, 09:55 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ok, well looking at that product, if you're using sftp, then those port ranges are irrelevant... are you really sure what actual protocol you are using? if you do want to use sftp, then that'd just be single port 22, nice and simple (and recommended by them on their KB it seems)
 
  


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
Unable to allocate port with port forwarding software djeepp Linux - Networking 3 01-29-2008 07:28 AM
port forwarding on Belkin 4-port Cable/DSL Gateway Router sycamorex Linux - Networking 5 03-05-2007 03:27 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

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

All times are GMT -5. The time now is 06:41 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