LinuxQuestions.org
Visit Jeremy's Blog.
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 01-20-2010, 08:02 PM   #1
onesikgypo
Member
 
Registered: Jun 2008
Posts: 56

Rep: Reputation: 15
Box With 3 Dedicated IP's All Returning The Same Single IP Address


Hi,

I have a linux box, which was given to me by a company with 3 dedicated IP addresses. My goal was to setup ssh tunnels on all three dedicated IP Addresses.

Via Putty, i am successfully able to create a tunnel to the box's on IP1 IP2 and IP3 - that is i can make incoming connections on all three IP's.

However, my problem lies when i attempt to USE the tunnel. AIn all instances, regardless of the IP i actually tunneled into the box with, it returns IP1 as an outgoing connection, i.e if i setup IE to use the tunnel, it will return my IP as IP1, even though i have created the tunenl via IP2/IP3.

What id liek to accomplish is that when i create a tunnel via IP1, then outgoing connections go via IP1, and when i create a tunnel via IP2, then outgoping connectiosn go via Ip2 etc.

After discussing this with a colleague of mine, he infomed me he had the same problem at one point, and that some configuration on the box was required - however he was unable to recall.

Any assistance that could be given would be greatly appreciated.

Thankyou.
 
Old 01-21-2010, 04:42 AM   #2
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Rep: Reputation: 116Reputation: 116
Your problem is routing.

The machine has only got one default gateway. That means the IP address to send packets to if they are destined for the outside world and not the local network. The default gateway is also assigned to a specific ethernet device for the packets to be sent from.

Code:
$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        *               255.255.255.0   U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         10.0.0.1        0.0.0.0         UG    1      0        0 eth0
In the example above, you see that anything destined for an address in 10.0.0.x will be addressed and sent directly to that IP because that is the "localnet". No gateway is required. Anything addressed to a loopback IP will be send using the "lo" interface. If a packet is destined for any other IP address, then it will be sent to the default gateway (in this case 10.0.0.1) so that the gateway can forward it on out of your network and onto the Internet. This default gateway is bound to the "eth0" interface. This means that eth0 will be used to send all packets out to the Internet and therefore will have the source IP as whatever IP is assigned to eth0. Even if you add an adapter and add a new entry to the routing table accordingly, there will still only be one default gateway bound to one adapter.

This means that while you can listen on any IP you want for incoming connections, outgoing ones will always use the default gateway.

If you want to get around this, then you are going to need to use iproute2 and iptables to create custom rules for routing outbound packets. This will require a lot of background reading. A couple of basic starting points:


http://www.linuxjournal.com/article/7291
http://blog.khax.net/2009/11/28/mult...-and-iproute2/
 
Old 01-21-2010, 04:57 AM   #3
onesikgypo
Member
 
Registered: Jun 2008
Posts: 56

Original Poster
Rep: Reputation: 15
i was under the impresion from other research i did online that it could be solved through iptables alone with something like (though i have not had the time to implement it yet) since im just concerned with what IP address is displayed on the outgoing and not concerned with anything incoming as such:

Code:
iptables -t nat -A POSTROUTING -s IP2 -o eth0 -j SNAT --to IP2
 
  


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
Multiple ip's to single Ethernet card abrar_pu Linux - Networking 1 01-02-2008 05:38 AM
Single DHCP server ,to provide the ip address to a MAC address in two different subne alix123 Linux - Software 5 05-08-2007 11:16 PM
Utilization of all IP's on my dedicated Server (CentOS 4) bilalinamdar Linux - Newbie 9 02-15-2007 11:05 AM
gethostbyname() is not returning my IP address hal2000 Programming 5 10-11-2004 05:54 PM
Program returning ip-address? smellofsunshine Linux - Software 4 08-11-2003 05:59 AM

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

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