LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-12-2013, 07:35 AM   #1
syncmaster191t
LQ Newbie
 
Registered: Dec 2013
Posts: 1

Rep: Reputation: Disabled
Forwarding port from eth0 to eth1 (using NAT?)


Hello all,

I have a debian 6 machine with two network interfaces:

eth0 with IP: 192.168.1.1
eth1 with IP: 10.0.0.1

On 10.0.0.1 on port 80 a server program is listening, but NOT on 192.168.1.1.
But I am connected to eth0 and I have an IP like 192.168.1.2.

How can I forward (route) port 80 on eth0 to eth1, possibly using NAT, so that I can connect to the server program listening on 10.0.0.1.

I cannot modify the server program nor anything physically on the server.

Thank you

Andreas
 
Old 12-12-2013, 08:08 AM   #2
MikeDeltaBrown
Member
 
Registered: Apr 2013
Location: Arlington, WA
Distribution: Slackware
Posts: 96

Rep: Reputation: 10
First, your client (192.168.1.2) must know that network 10.0.0.0/?? is accessible through the host, in it's broadcast domain, 192.168.1.1:
If the client is linux:
route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.1
If the client is windows:
ROUTE ADD 10.0.0.0 MASK 255.255.255.0 192.168.1.1
(I'm assuming the 10.0.0.0 network is a /24, adjust the netmask as necessary)

You don't need NAT and you shouldn't need to forward since the server is running on the gateway/router.

You also shouldn't need to define the reverse route since the server's routing table should already have the information it needs (network 192.168.1.0/24 can be reached through interface eth0).
 
Old 12-12-2013, 08:17 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by MikeDeltaBrown View Post
You don't need NAT and you shouldn't need to forward since the server is running on the gateway/router.
If the machine is the gateway/router he does not even need the route to 10.0.0.0/24 as long as the default gateway is 192.168.1.1.

You could also make the webserver listen at all devices on the gateway.

Doing it with NAT you would use DNAT so that everything on port 80 to 192.168.1.1 is forwarded to 10.0.0.1

Code:
iptables -d 192.168.1.1 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1
 
Old 12-12-2013, 08:30 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this seems related:
http://www.linuxquestions.org/questi...6/#post3804866
 
  


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
Packet Forwarding from eth0 to eth1 isn't working rajat Linux - Networking 1 05-07-2007 04:24 AM
forwarding a specific port from eth0 to eth1 zovres Linux - Networking 2 05-02-2006 10:01 PM
port forwarding from eth0 to eth1 ? overproof Linux - Networking 7 05-16-2005 02:48 AM
iptables: forwarding SSH connection: eth0 to eth1 hamish Linux - Networking 12 01-14-2005 03:07 PM
IP forwarding from eth0 to eth1 musicman_ace Linux - Networking 5 08-01-2004 04:39 AM

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

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