LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-12-2016, 06:06 PM   #1
majest
LQ Newbie
 
Registered: Oct 2015
Posts: 7

Rep: Reputation: Disabled
Connecting 2 devices with the same static IP address to my computer


I would like to connect 2 devices to my computer using ethernet cable (direct connection). Unfortunately the devices both have the same static IP address, 192.168.1.1, and I can't change this. The devices don't need to communicate with eachother so really I am wondering how to isolate their LANs so they can both have the same IP address.

I have 2 interfaces on my computer, eth1 and eth2, and I gave them addresses 192.168.1.2 and 192.168.1.3. When I connect the cables, this results in only one of the devices being visible on the LAN - obviously one device claims 192.168.1.1 and the other gets excluded.

Is there a way to make this work? I thought about using IP tables to change the source IP address (SNAT) of the packets based on the interface but I haven't figured out how to do it - my initial attempts haven't worked.

Or could I put eth1 and eth2 on 192.168.2 and 192.168.3 and give them secondary IP addresses on 192.168.1? Something like:

auto eth1 eth1:0
iface eth1 inet static
address 192.168.2.1
netmask 255.255.255.0

iface eth1:0 inet static
address 192.168.1.2
netmask 255.255.255.0

Appreciate any suggestions or comments - thanks
 
Old 04-12-2016, 11:39 PM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

I'm curious about what devices these are, and why their addresses can't be changed ;-)

I don't believe there is a way to achieve what you want with direct connections. One way to get past the problem would be to put another device between your computer and one of these other devices to do some NATing for you - possibly a small router like a MikroTik RouterBoard or a Raspberry Pi or similar single board computer with 2 ethernet interfaces?

Good luck - let us know if you find a solution please!
 
Old 04-13-2016, 01:09 PM   #3
majest
LQ Newbie
 
Registered: Oct 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
They're Windows XP machines that have software on that runs a special piece of hardware . We can't modify the XP machine at all.

I've read that Linux can be used as a router (software rather than hardware). Is it possible to dedicate an eth1 and eth2 to be routers with NAT rules passing packets on to eth0? It seems bizarre to have to forward packets arriving at eth1/eth2 onto eth0 which is less than 1 inch away on the mo'board...

Last edited by majest; 04-13-2016 at 01:21 PM.
 
Old 04-13-2016, 06:50 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,963

Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
Make a static arp entry for each one should work.
 
Old 04-14-2016, 05:35 AM   #5
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

The challenge is in the routing: how do you get the outgoing traffic to go to the correct interface?

One approach worth trying might be to create fake IPs by which you can address these:

- for device 1, use fake IP 192.168.2.1, and assign 192.168.2.2 to your eth1
- for device 2, use fake IP 192.168.3.1, and assign 192.168.3.2 to your eth2

Connecting to 192.168.2.1, the routing table should try and send the traffic via eth1 as intended. You can then use SNAT to map the source address to your previously-mentioned 192.168.1.2 address. A similar scenario would apply for the second device.

The commands to set this up would look something like this:

Code:
sudo ifconfig eth1 alias 192.168.2.2
sudo ifconfig eth2 alias 192.168.3.2
sudo iptables -t nat -A POSTROUTING -d 192.168.2.1 -j SNAT --to-source 192.168.1.2
sudo iptables -t nat -A POSTROUTING -d 192.168.3.1 -j SNAT --to-source 192.168.1.3
I probably missed something here, but might be worth a shot ;-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to block my computer from connecting TO a specific IP address? taylorkh Linux - Security 8 02-16-2010 07:55 AM
[SOLVED] Static IP Address not connecting to the internet Ubuntu 9.04 madkayaker Linux - Networking 20 09-18-2009 01:12 AM
usb drive connects as different devices when connecting to my computer okos Slackware 16 09-15-2008 12:26 AM
How do I give my computer a static IP address when bridging? Mysticle31 Linux - Networking 0 12-20-2007 01:37 AM
computer switches from static to dhcp address (automagically?) cyberpuerka Linux - Networking 1 09-03-2004 11:29 AM

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

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