LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-26-2004, 10:52 AM   #1
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Problems with port forwarding


Hi,

I am having a problem with port forwarding on my Slackware machine.

The Windows 2000 server had to be moved to a new IP, but since this is only temporary, all of the clients couldn't be reconfigured to allow for this change. So I decided to put my Slackware server (usually a file/FTP server) at the IP that the clients would expect the Win2K server to be, and I planed on forwarding any ports to the Win2K server's new IP.

I wrote a very simple script to allow forwarding of DNS, WINS, SMTP (25 and 110), and HTTP to the new IP. But for some reason, only WINS, DNS and port 110 will work. HTTP and port 25 are not forwarded.

Here is my script:

Code:
# Make sure port forwarding is enabled
echo 1 > /proc/sys/net/ipv4/ip_forward
#
# Flush all rules
iptables -F
#
# Declare variables
DEST_IP=(10.16.50.11)
INT_NET=(10.16.0.0/24)

#
# Add forwarding rules
#
# Forward external services
# Web
iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0 -j DNAT --to $DEST_IP
# Incoming mail
iptables -t nat -A PREROUTING -p udp --dport 25 -i eth0 -j DNAT --to $DEST_IP
# Outgoing mail
iptables -t nat -A PREROUTING -p tcp --dport 110 -i eht0 -j DNAT --to $DEST_IP

# Forward WINS request ONLY for clients on the internal network
iptables -t nat -A PREROUTING -p udp -s $INT_NET --dport 1512 -i eth0 -j DNAT --to $DEST_IP
iptables -t nat -A PREROUTING -p tcp -s $INT_NET --dport 1512 -i eth0 -j DNAT --to $DEST_IP
# Forward DNS request
iptables -t nat -A PREROUTING -p udp --dport 53 -i eth0 -j DNAT --to $DEST_IP
iptables -t nat -A PREROUTING -p tcp --dport 53 -i eth0 -j DNAT --to $DEST_IP
# Print message
echo Port Forwarding configured
Keep in mind that while this system has only one interface (eth0) it has both a public and private IP. This is possible because the state network (which provides our internet connection) NATs our two public IPs to two private IPs that were assigned to us. Therefore, any machine that takes the private IP given to us by the state will also respond to the public IP.

Any help would be appreciated, since I have a hundred or so people who don't like to be without email.
 
Old 01-26-2004, 08:55 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Original Poster
Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Anybody?

I have found that port 25 and 110 are being properly routed from the internet into the mail server, but routing inside the net is not working.
 
Old 01-27-2004, 08:38 AM   #3
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Original Poster
Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
OK, now it looks like port 25 isn't getting routed properly from the internet. I know that mail isn't getting in from the state, so it is a good bet it is closed.

Why won't this script route anything properly (except for DNS, which doesn't seem to work through telnet, but I can access the DNS server through it)?

I really need help getting port 25 and 80 to the server, the staff is getting more annoying by the day.
 
Old 01-27-2004, 03:03 PM   #4
Half_Elf
LQ Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 46
is the other end has any firewall or such?
I just tried to follow a SMTP connection (using telnet) between my box and my SMTP server and look like the server request a connection trought AUTH port (113) during the process. And since you aren't forwarding 113 as well, your client connection die as this time. I have no idea with 110 is but it is probably the same problem
Sorry dude, you'll need a firewall on your Win2k box (if that thing is possible)
Make sure to use tcpdump next time
 
Old 01-27-2004, 03:22 PM   #5
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Original Poster
Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
I actually just fixed the problem about 5 minutes ago.

Apparently the entire machine was screwed up. It was missing modules that it never bothered to mention, couldn't compile software, and the iptables scripts did nothing.

I just used the same method on a different Slackware machine, and it all worked fine.
 
  


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
Iptables problems with port forwarding jebaird Linux - Networking 3 08-05-2005 12:35 PM
iptables port forwarding problems JCdude2525 Linux - Networking 18 02-09-2005 04:25 PM
IPTable Problems (Port Forwarding)... Arch3Angel Linux - Security 3 12-04-2004 04:56 PM
NAT Port forwarding problems! nidputerguy Linux - Networking 4 01-31-2004 10:29 AM
port forwarding problems robiewp Linux - Networking 43 10-21-2003 09:08 AM

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

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