Connect two ip addresses in different subnet

Posted on 2008-11-06
Last Modified: 2012-05-05
I have two computers with two different ip addresses and subnet masks.
Computer1: ip address 10.57.x.x with subnet mask
Computer2: ip address 10.1.y.y with subnet mask, gateway 10.1.y.z

I need to write a C++ program in Computer1 which connects to Computer2 through an ethernet cross-over cable. What is the best way to do it?

Could it be possible to add another ip address 10.1.y.z in Computer 1 and pretend the gateway to communicate with Computer2? Any suggestions will be appreciated.
Question by:ssl1324
    LVL 28

    Accepted Solution

    A few ideas...

    1) Is this a one-time transfer?  A crossover cable will not allow other communications anyway, so the IP addresses really wouldn't matter.  Just re-address one of the two boxes to the same subnet as the other one.  When you're done, re-address the machine back and plug it back into the 'Net.

    2) Look into products like LapLink that allow transfer via USB, Serial, or Parallel cables instead.  Much easier to implement and you don't have to touch the networking side of things.

    3) Depending on the OS, you may be able to add a second IP address to the existing NIC.  However, with a cross-over cable in use, this is a waste of effort, since the other IP address will be useless anyway.

    4) You could simply add a second NIC, which is easy enough to do on most OS'es, and configure THAT one for your cross-over network link.

    Author Comment

    Thanks for your reply.

    The ip addresses and subnet masks must be fixed. And the communication protocol has to be TCP/IP (i.e. through ethernet crossover cable).

    Another requirement I forget to mention is that, Computer2 only accepts the fixed ip address which connects to it (i.e. only accept ip address 10.57.x.x). So Computer2 will check the TCP header and reject the connection if the ip address is not 10.57.x.x.

    I have thought about adding another NIC but any other software suggestion will be appreciated.
    LVL 28

    Assisted Solution

    by:Bill Bach
    Why such strange requirements?  There is simply no way that this even makes sense in the typical world of computing.  Is this for a class assignment? Sounds like an ideal project for an OS/networking course to explore the innards of device drivers.

    The only viable solution, given the constraints that you have provided, is to write your own version of an IP stack that makes the changes as you need them.  

    If you can add additional devices in-line with the cross-over cable, then there are other options, such as adding a router in between the boxes, or even creating your own version of The Bongo Project ( to implement your own physical layer in place of the Ethernet cross-over cable.  However, this does not follow your original specs.
    LVL 5

    Assisted Solution

    Unless I completely don't understand what your trying to do BillBach is right this is a strange request/requirement. the two pc's simply will not talk to each other through a crossover cable with statically assinged ip's in different subnets. You could add another IP address to computer 2 on the same subnet as computer one and then they could communicate

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Preface There are many applications where some computing systems need have their system clocks running synchronized within a small margin and eventually need to be in sync with the global time. There are different solutions for this, i.e. the W3…
    The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now