LinuxQuestions.org
Review your favorite Linux distribution.
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-2002, 06:59 AM   #16
bbenz3
Member
 
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30

Here is what I did to make mine work.

eth1 is external NIC
192.168.168.11 is the IP of int computer
port# doesn't have to equal each other but for what you want it should.

iptables -t nat -I PREROUTING -p tcp -i eth1 --dport (port#) -j DNAT --to 192.168.168.11port#)

also you should add
another line to make the outgoing side work. I will have to look that one up. I think you can also you this with a range of ports and will look that up as well.
 
Old 04-28-2002, 08:21 AM   #17
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Original Poster
Rep: Reputation: 15
Talking Thx.

Thx. I have now aded the lines

iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 5800 -j DNAT --to 192.168.0.2:5800
and
iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 5900 -j DNAT --to 192.168.0.2:5900

eth0 is my external and 192.168.0.2 is my internal ip.

But that didn't do it.
But I'm waiting for that other line.
I don't realy understand what that wolud do.
Because all outgoing singal is accepted.
But I hope it will fix this hole mess.

 
Old 04-28-2002, 01:33 PM   #18
bbenz3
Member
 
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30
OK here is what I did completely. I have most everything set to drop so I have to allow things to get out.

I am assuming that your int network is on eth1 and ext is on eth0

iptables -I INPUT -p tcp -i eth1 --sport (port#s)
ie) 400:414 to make the range of ports work

Here is the line to get that port range to work:
iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 400:414 -j DNAT --to 192.168.0.2

The only other thing that I can think of is to try and and add the same line except change the tcp function to udp and therefore allow both types of protocols.

Hope that makes it work. If not let me know.
 
Old 04-28-2002, 04:26 PM   #19
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Original Poster
Rep: Reputation: 15
Angry Hm...

I don't get it. It dosen't work.

Now I added

iptables -I INPUT -p tcp -i eth1 --sport 5800
iptables -I INPUT -p udp -i eth1 --sport 5800

iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 5800 -j DNAT --to 192.168.0.2
iptables -t nat -I PREROUTING -p udp -i eth0 --dport 5800 -j DNAT --to 192.168.0.2


Not working......
 
Old 04-28-2002, 07:51 PM   #20
bbenz3
Member
 
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30
Well you will have to post more of your information for me then. Because without that I don't know what else to tell you.
 
Old 04-29-2002, 03:07 AM   #21
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Original Poster
Rep: Reputation: 15
Lightbulb Look on side 1.

If you look on side 1 of this thread.
There you will get more info.
 
Old 04-29-2002, 03:27 AM   #22
bbenz3
Member
 
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30
e-mail me and I will send you my firewall/router script. It is too long to post here.
 
Old 04-29-2002, 08:39 AM   #23
Norel
Member
 
Registered: Apr 2002
Location: Italy
Distribution: RockLinux
Posts: 35

Rep: Reputation: 15
Re: continu...

Quote:
--------------------[Internet]
-----------------------/
----------------------/(eth0)
---------------------/
---------------[Router] (Slackware 8.0)
------------------/
-----------------/(eth1)
----------------/
-------------[Hubb (10Mbit)]
-------------/--------------\
---[Computer 1]-------------[Computer 2]
--- WinXp (Standard)-------WinME
--- Linux Red Hat 7.2-------(192.168.0.22)
----(192.168.0.2)--------------(VNC client)
----(VNC Server and DC)
Only some questions/proposal:
- how do you connect to internet? (dialup, xdsl, cable,...)
- post here #ifconfig output while you are connected to internet (for more privacy just x.x.x.x your internet address)
- are you sure that your router connect to internet directly without any firewall and/or SNAT (masqerade) that prevent you from reciving direct connection? To verify this just temp. start a daemon as telnet or sshd on your router and try to connect from the internet.

Other tests:
- just boot Computer 1 in linux, start sshd (port 22 tcp/udp) or telnet (port 23 tcp/udp), start #tcpdump host 192.168.0.2 and port <22/23> | tee logfile.log

on router:
just to clean and open *all*:
#iptables -F
#iptables -t nat -F
#iptables -P INPUT ACCEPT
#iptables -P OUTPUT ACCEPT
#iptables -P FORWARD ACCEPT
#iptables -t nat -P PREROUTING ACCEPT
#iptables -t nat -P OUTPUT ACCEPT
#iptables -t nat -P POSTROUTING ACCEPT

to make websurfing on:
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+ check websurfing here from Computer 2 to internet

start logging on server:
#tcpdump port <22/23> | tee logfile.log

to activate DNAT:
#iptables -t nat -A PREROUTING -i eth0 --dport <22/23> -j DNAT --to 192.168.0.2
+ try to connect from internet to your router internet address with ssh client (port 22) and/or telnet client (port 23)
+ check Computer 1 for tcpdump output
+ check Router for tcpdump output

Report results here

Last notes:
- this is a lot risky configuration because you are open to the world ... don't stay this way too long
- I ask you to try ssh or telnet in place of VNC because those services are simlper and there no problem with packet size and fragments. Just for the simplest use telnet.
- sorry for long whait for a reply ... just I had too work
 
Old 05-01-2002, 07:56 AM   #24
Jase
Member
 
Registered: May 2001
Location: Panama City Beach, FL
Distribution: *.BSD
Posts: 113

Rep: Reputation: 15
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -A FORWARD -o $EXTIF -s $MYIP -p udp --sport 5800 -j ACCEPT


substitue the $IPTABLES for your path to iptables (/sbin/iptables)
substitue the $EXTIF for eth0 (WAN adapter)
substitue the $MYIP for your 192.168.x.x VNC machine IP


also what does lsmod return for you?

Last edited by Jase; 05-01-2002 at 08:04 AM.
 
Old 05-02-2002, 03:20 AM   #25
Token
LQ Newbie
 
Registered: May 2002
Location: Atlanta
Distribution: RH 7.2
Posts: 20

Rep: Reputation: 0
Do you have a firewall, Zone Alarm, Black Ice, etc....runnin on the 192.168.0.2 box...turn'em off and test if so...

you might also want to try logging everything that your firewall drops and see if you can spot the messup in there somewhere.

Also, grab a sniffer (there's several out there, but for linux I used sniffit or ethereal) and run it on one of your internal machines and see if you can see the packets for vnc coming out of your router to your VNC box. This way you'll at least know if your IPTABLES is forwarding the packets and they're being lost somewhere else.

Here's the way I log stuffs for drops:

# Setup Logging for Dropped Packers
iptables -N dropwall
iptables -A dropwall -m limit --limit 15/minute -j LOG --log-prefix Dropped:
iptables -A dropwall -j DROP

then after all my other iptables stuff I have

#Final Catch all Logging
iptables -A INPUT -j dropwall

With that at the end of your script any packets that you didn't specify to drop or allow but don't have anywhere else to go are dropped then logged.

You can also use this to test other packet drops in your iptables script. Say if you're dropping telnet packets:

iptables -A INPUT -i etho -p tcp --dport 23 -j dropwall
instead of:
iptables -A INPUT -i eth0 -p tcp --dport 23 -j DROP

so whenever a packet is dropped it's logged


You could also do the same thing for accepts if you wanted...
 
  


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
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 80 forwarding to port 22 with iptables zahoo Linux - Networking 3 02-22-2005 07:22 AM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM
How to do ip port forwarding cmardhekar Linux - General 0 08-28-2001 12:49 AM

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

All times are GMT -5. The time now is 04:27 AM.

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