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 02-04-2006, 04:10 PM   #1
palesths
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Rep: Reputation: 0
Pls help with iptables +NAT


Hello,

I'm trying for a couple of days not to forward port 3389 to an internal machine but with no luck.

I've done this before successfully but i think that because there are two internet connections on this linux box maybe i'm doing something wrong..
This is my 'ifconfig' output:

eth0 Link encap:Ethernet HWaddr 00:0A:5E:20:60:A1
inet addr:X.X.X.X Bcast:X.X.X.Y Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17758821 errors:0 dropped:0 overruns:1 frame:0
TX packets:19711510 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1060501715 (1011.3 Mb) TX bytes:3181393850 (3034.0 Mb)
Interrupt:22 Base address:0xc000

eth0:0 Link encap:Ethernet HWaddr 00:0A:5E:20:60:A1
inet addr:10.0.0.2 Bcast:10.0.0.3 Mask:255.255.255.252
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:22 Base address:0xc000

eth1 Link encap:Ethernet HWaddr 00:0A:5E:22:A3:E8
inet addr:10.0.0.6 Bcast:10.0.0.7 Mask:255.255.255.252
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5666902 errors:134 dropped:0 overruns:1 frame:134
TX packets:4680175 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2439193889 (2326.1 Mb) TX bytes:555740239 (529.9 Mb)
Interrupt:18 Base address:0xc400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:29175 errors:0 dropped:0 overruns:0 frame:0
TX packets:29175 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1731640 (1.6 Mb) TX bytes:1731640 (1.6 Mb)

ppp0 Link encap:Point-to-Point Protocol
inet addr:Y.Y.Y.Y P-t-P:62.103.1.96 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:5630199 errors:0 dropped:0 overruns:0 frame:0
TX packets:4646066 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2312349915 (2205.2 Mb) TX bytes:451480157 (430.5 Mb)


So, i want to forward from Y.Y.Y.Y:3389 to let's say 192.168.0.10:3389.

i did check if ip forward is enabled:

root@router:~# cat /proc/sys/net/ipv4/ip_forward
1
root@router:~#

and i did this on iptables:

iptables -A FORWARD -i ppp0 -o eth1 -p tcp --dport 3389 -j ACCEPT

iptables -A PREROUTING -t nat -p tcp -d Y.Y.Y.Y --dport 3389 -j DNAT --to 192.168.0.10:3389


But no luck, am i missing something?

Thanx in advance
 
Old 02-04-2006, 07:36 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Well, are you otherwise doing IP Masq on this box? You need some rule to get the traffic back out to the internet. Also, is Y.Y.Y.Y one of your IPs? If so, I would use -i INTERFACE instead (cleaner rules).
 
Old 02-06-2006, 02:00 AM   #3
palesths
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Hello Matir and thanks for your reply,

i use this rule for masq:

iptables -t nat -A POSTROUTING -d 10.0.0.0/24 -j MASQUERADE

Should i do something else too?

and yes, Y.Y.Y.Y is one of my external IP's to the internet on the ppp0 interface..
 
Old 02-06-2006, 10:28 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Why are you masquerading packets TO the local net? I use 'iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQ'.
 
Old 02-07-2006, 02:30 AM   #5
palesths
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Hello again,

Matir do u have MSN or something so we can talk from there?
Mine is palesths@hotmail.com

Please add me if you can so i can send you my iptables script, the real IP's and everything

P.S. I used the command u just sent but still not working :-/
 
Old 02-07-2006, 08:51 AM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I don't have MSN, but I have AIM (info's in my profile). Do other outbound connections work?
 
Old 02-08-2006, 06:43 AM   #7
palesths
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Hi again,

Yes everything seems to work fine, this box is also an internet gateway.. and all the boxes behind this linux works fine.
The only thing that's not working is the port forward thing :-/

I think that maybe because there are 2 DSL connections on this box i'm getting confused about the rules i have to use.. i'll right a more specific diagram on the network setup and the interfaces on that box and i'll send them to you when i get the chance to go there again.

Thanks for your help
 
  


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 : build NAT using IPTABLES joseph Linux - Networking 4 04-23-2004 05:08 AM
iptables and NAT arrruken Linux - Networking 8 10-03-2003 04:17 AM
iptables help!!! pls.... zaldyd Linux - Networking 3 07-15-2003 01:10 AM
IPtables Noob Help pls Phat420 Linux - Networking 6 03-11-2003 09:55 PM
IPtables +NAT daromer Linux - Networking 1 01-07-2002 11:15 AM

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

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