Monday, January 23, 2012

Howto: Two different subnets same physical LAN how to get them to talk without a gateway

Have you ever ran into a problem where you had two windows boxes that were on different sub nets on the same physical LAN and you needed to establish temporarily communication?

Say you have these two computers with the following ip addresses.

Computer 1
172.16.1.2 

Computer 2
192.168.100.1



So what we are going to do is tell each computer that in order to get to the other computer they have to go out their local interface.

Open a command prompt and run each of the following commands on the respective computer.

Computer 1
route add 192.168.100.1 MASK 255.255.255.255 172.16.1.2

Computer 2
route add  172.16.1.2  MASK 255.255.255.255 192.168.100.1


This now should allow for communication to occur.

I wrote a batch file to help with adding the route command


@echo off
echo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Echo Created By Tony Unger
Echo **********************************************************************
echo Note:

echo Setup Routing Table
Echo Enter IP address you wish to connect to
REM IP address that was entered
set /p IPAddress=

REM Find Local IP Address - Works for Win7 if you have more then 1 adapter this may not work

REM Windows 7
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG ^| FIND "IPv4"') DO FOR %%B IN (%%A) DO SET LOCIPADDR=%%B


route add %IPAddress% MASK 255.255.255.255 %LOCIPADDR% /p






No comments:

Post a Comment