LinuxQuestions.org
Help answer threads with 0 replies.
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-27-2004, 04:04 PM   #1
zovres
Member
 
Registered: Sep 2002
Posts: 184

Rep: Reputation: 30
port forwarding


I would like to forward port 81 from 192.168.0.1 which is connected to the net to 192.168.0.4 using iptables.

I've looked aroud, found a few command lines but they don't work :\

can anyone give me THE command line that will work for sure
or recommand me a good iptables guide?


thanx
 
Old 02-27-2004, 04:46 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Port forwarding would look something like this...
iptables -t nat -A PREROUTING -i $EXT -p tcp --dport 80 -j DNAT --to 192.168.0.4

But I'm kind of wondering in if you just want to share the internet connection. If so, you don't use port forwarding, but this instead....

# Use this for NAT or IP Masquerading.
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $EXT -j MASQUERADE

# This rule will accept connections from local machines.
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -s 192.168.0.0/24 -d 0/0 -p all -j ACCEPT
 
Old 02-27-2004, 05:09 PM   #3
zovres
Member
 
Registered: Sep 2002
Posts: 184

Original Poster
Rep: Reputation: 30
the connection is already shared and now I just want to forward port 81 to 192.168.0.4

I'm gonna try your command thx =)
 
Old 02-27-2004, 05:12 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Just keep in mind that $EXT is for my setup and you might use just the external interface ( eth0 ) or ( eth1 ).
 
Old 02-27-2004, 06:05 PM   #5
zovres
Member
 
Registered: Sep 2002
Posts: 184

Original Poster
Rep: Reputation: 30
it doesn't work :\

do I need to restart iptables? to reboot?
 
Old 02-27-2004, 06:24 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
do I need to restart iptables? to reboot?
Reboot is a windows thing.
Just curious, what port is 81 for? my ISP blocks all of the well know ports so I would have to use a high number.

This site has a lot of tables information.....

http://www.linuxguruz.com/iptables/
 
Old 02-27-2004, 06:29 PM   #7
zovres
Member
 
Registered: Sep 2002
Posts: 184

Original Poster
Rep: Reputation: 30
81 is the port of my alternativ webserver (the main one is on 80) I tried with port number 8192 and I still have the problem
 
  


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 01:50 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