Click to See Complete Forum and Search --> : port forwarding/ mapping
elfking
03-14-2003, 03:37 PM
I have been searching around on how to do this.... Ive tried it a couple of times but it has not worked yet.. right now ive got a windows machine running doing this:
incoming port of : 1110 gets sent to mail.attbi.com:110 and
incoming port of : 2555 gets sent to mail.attbi.com:25
Using my computer as a gateway... (proper terms I hope.) Id like to set up my linux box to do that....
Then... if I get it working, is there a way to limit this access by IP? so only certain people I know about can use that mapping?
I am running Redhat 8.0 and ive been playing with iptables to try and do this... but I don't think I am understanding becuase I couldn't get it to work at all...
So if anyone could better explain how I would go about doing this, that would be awesome. Thanks.
-Brian.
bwkaz
03-14-2003, 07:45 PM
/usr/sbin/iptables -t nat -A PREROUTING --proto tcp --dport 1110 -j DNAT --to-destination mail.attbi.com:110 should work. Change the ports for the other case. You may also have to use mail.attbi.com's IP address rather than their hostname, I don't know.
If you want to restrict to a certain IP, then put --src xxx.xxx.xxx.xxx before the -j somewhere. If you want a range of IPs, then use CIDR notation -- something like --src 192.168.0.0/24 for addresses that match 192.168.0.[0-255]. If you want to match a disjoint range, then you're going to have to write separate rules for each IP, I think.
elfking
03-17-2003, 02:22 PM
I used those commands and syntax, changed around the ports to match it, and made sure the router had the ports forwarded to my box and it still didnt work. I noticed that after typing all the stuff in, it never showed up on the table when listed... so I don't know if that gives any insite, I also restarted iptables to see if that maybe needed to happen to take affect...
when installing linux i installed no firewall. so I don't think the firewall could be the issue either. Its a strange little problem.
chrism01
03-18-2003, 02:05 PM
best to run iptables -L and put the output here so we can see.
elfking
03-18-2003, 02:56 PM
I guess the command doesnt work?
I typed this (copy and paste): iptables -t nat -A PREROUTING --proto tcp --dport 2161
-j DNAT --to-destination 63.240.76.7:110
when I iptables -L its empty.....
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I had no error messages or anything after typing it in, it went as if it took the command and was happy with it.
chrism01
03-18-2003, 04:19 PM
Certainly looks odd. I'm going to have to suggest a couple of things here.
Have a quick scan through
man iptables
in case anything looks promising.
More usefully, goto http://www.netfilter.org/documentation/
and read up on iptables.
Good luck.
:)
elfking
03-18-2003, 06:43 PM
I think it may need a second network card... let me see if I can explain... currently its working on my windows box... Packets go like this:
Internet Anyone on port 1133--> My router --> My Windows Box (maps it and sends it out as mail.attbi.com:110 --> router -->Internet(ATTBI)
The same thing goes for my linux box... execpt all this ipchains stuff that ive been reading for the past couple days... says that it wants to go from one interface to another... and no, I didnt make the stupid mistake of not forwarding the ports to the linux box from the router. I don't think I understand how to do it. I guess its not a common thing.
I had come from the netfilter documentation on ip tables to here, after trying everything I could with no luck... Thanks for all the help... If anyone can think of anything else, im still interested. :D