Networking Forums

Networking Forums > Computer Networking > Linux Networking > NAT with 2 Internet interfaces

Reply
Thread Tools Display Modes

NAT with 2 Internet interfaces

 
 
Tomek
Guest
Posts: n/a

 
      04-14-2005, 07:36 AM
Hello Everybody,
I have a Linux on PC as gateway (lets call it GW). GW has 3 interfaces. 2 of
them (ETH0, ETH1) have 2 different public IP adresses (IP_0, IP_1) and are
conneted via my ISP to the Internet. Third interface (ETH2) is a local
interface with not public IP (IP_2). In the local network there is a
computer (SERVER) with local IP(IP_S). Lets call this configuration Company.
I would like to connect to Company SERVER from home computer (IP_H), so I
redirected all traffic from my home computer to the SERVER:
/sbin/iptables -A INPUT -s IPH -d IP_0 -i eth0 -j ACCEPT
/sbin/iptables -t nat -A PREROUTING -t nat -s IPH -d IP_0 -j DNAT --to IP_S
/sbin/iptables -A INPUT -s IPH -d IP_1 -i eth1 -j ACCEPT
/sbin/iptables -t nat -A PREROUTING -t nat -s IPH -d IP_1 -j DNAT --to IP_S

I also have two routing tables with two default gateways on GW. If I ping
IP_0 from the Internet (not home computer) i have response from IP_0 and if
I ping IP_1 I have response from IP_1.

I understand that if I want my connection from HOME to SERVER works I have
to configure NAT for SERVER.

How do I have to configure this NAT???
I tried:
/sbin/iptables -t nat -A POSTROUTING -s IP_S -d 0.0.0.0/0 -o eth0 -j
MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -s IP_S -d 0.0.0.0/0 -o eth1 -j
MASQUERADE

but it wont work.

If I leave MASQUARADE only on eth0 interface, then I can connect from home
to SERVER but only via IP_0. If i try to connect via IP_1, my packets going
to SERVER via IP_1 but returning via IP_0.

Please help me. I would like to choose if I connect from my home computer to
SERVER via IP_0 or IP_1.

Regards
Tomek



 
Reply With Quote
 
 
 
 
Jarek Poplawski
Guest
Posts: n/a

 
      04-14-2005, 12:00 PM
On 2005-04-14, Tomek <(E-Mail Removed)> wrote:
> Hello Everybody,
> I have a Linux on PC as gateway (lets call it GW). GW has 3 interfaces. 2 of
> them (ETH0, ETH1) have 2 different public IP adresses (IP_0, IP_1) and are
> conneted via my ISP to the Internet. Third interface (ETH2) is a local
> interface with not public IP (IP_2). In the local network there is a
> computer (SERVER) with local IP(IP_S). Lets call this configuration Company.
> I would like to connect to Company SERVER from home computer (IP_H), so I
> redirected all traffic from my home computer to the SERVER:
> /sbin/iptables -A INPUT -s IPH -d IP_0 -i eth0 -j ACCEPT

This is not needed here.

> /sbin/iptables -t nat -A PREROUTING -t nat -s IPH -d IP_0 -j DNAT --to IP_S

One "-t nat" will suffice.

> /sbin/iptables -A INPUT -s IPH -d IP_1 -i eth1 -j ACCEPT

This is not needed here.

> /sbin/iptables -t nat -A PREROUTING -t nat -s IPH -d IP_1 -j DNAT --to IP_S

One "-t nat" will suffice.

> I also have two routing tables with two default gateways on GW. If I ping
> IP_0 from the Internet (not home computer) i have response from IP_0 and if
> I ping IP_1 I have response from IP_1.
>
> I understand that if I want my connection from HOME to SERVER works I have
> to configure NAT for SERVER.

You have done it already (DNAT).

> How do I have to configure this NAT???
> I tried:
> /sbin/iptables -t nat -A POSTROUTING -s IP_S -d 0.0.0.0/0 -o eth0 -j
> MASQUERADE
> /sbin/iptables -t nat -A POSTROUTING -s IP_S -d 0.0.0.0/0 -o eth1 -j
> MASQUERADE

This is not needed here.
It would be necessary only for connections from SERVER to HOME. Then
you should use SNAT not MASQUERADE.

Jarek P.
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 interfaces, 2 gateways, no internet Simon GUEROUT Linux Networking 10 02-12-2009 01:26 PM
Two interfaces Jozza Linux Networking 4 10-27-2008 02:19 PM
two interfaces kleeper Linux Networking 2 01-26-2005 01:39 PM
Windows 2003 VPN Sever: Two VPN Internet Interfaces? Franz Schenk Windows Networking 0 06-30-2004 02:13 PM
multiple interfaces to Internet issue David Magda Linux Networking 1 06-11-2004 07:15 AM



1 2 3 4 5 6 7 8 9 10 11