How to access an IP in a subnet of another NC card? - networking

I searched and could not find an answer for this.. not even a discussion about it...
I need to develop an application to talk to a robot in our shop floor... no big deal about the code... The issue is as follows:
This robot is connected to an industrial PC that is connected to our production network. This industrial PC has two NICs, NIC #1 has TCP/IP settings set to connect to our production network (IP something like 10.9.100.100), and the NIC #2 is configured to have its IP on a subnet address (Something like 192.168.127.10).
The robot has an IP address too, which is in the subnet of the NIC #2 of the industrial PC. The robot´s IP is something like 192.168.127.20
There´s an application running on the industrial PC that keeps polling data from the robot, like its status, cycle time, etc. This application then sends the data collected from the robot to a server in our production network.
Simply put, it´s like grab data via NIC #2 and send it to a server in the production network via NIC #1.
In order to test my application from within the IDE and debug it, I´d like to connect to the robot from my desktop (Which is in the production network (10.9.100.200)...), to that IP in the subnet the robot is, that is, the IP subnet set in the NIC #2 from the industrial PC.
I have access to the industrial PC and I could install Visual Studio on it and code via remote desktop. Then for sure I could access that robot. But that would not be cool...
Is there any way, setting or application that allows me to reach that robot from my production network?

What you're looking for is port forwarding. You can set up the industrial PC to listen on a certain port number x on NIC 1 and forward all connections to the robot's IP address on port number y (where y may be equal to x if port x is not used by another application on the industrial PC, otherwise you set it to a different value).
This would be trivial to set up on most Unixes, but since you're running Windows it's a bit more complicated. If your traffic is TCP, Windows supports port forwarding via netsh. If your traffic is UDP, you need to use some third-party application. With some Googling I found this one
(look for "Simple UDP proxy/pipe"). Note that I have no experience with this program and you should be careful when downloading executables from unknown sources; but AFAICT the source code is also provided, so you could compile it yourself if needed.
On the same page you can also find a TCP forwarder if the native Windows one doesn't work for you.

Related

Connecting to a local IP (not in Network) from a computer without connecting to other networked computer sharing same IP

I am sorry, I dont know if this question is already asked (afaik this wasnt asked based on my search results). I have a computer running a software that needs license from a server in my company's domain. For pulling the license, I need to connect to the company network. Also there is a hardware setup in our company which is not integrated to the network. And I need to process some data from the hardware, and the data has to be shared with the software. So, I make two connections, one ethernet connection to the hardware and other wireless for using the software's license. I tried accessing the data from the hardware in the software through hardware's IP address. The problem is, there is another computer in our company from another location sharing the same IP as the Hardware, and the software tries retrieving the data from that computer and fails. I am sorry, if this is priliminary and I am not a networking person.
Simply put, one of the two systems need to change its IP address.
The alternatives are usually too complex and error prone, and their viability depends on the particularity of your environment:
Use arp command to force your PC IP-Mac mapping
Put a router in front of your hardware that does port forwarding
Use VLANs

How find correct Ip for connection Client/Server Qt?

I created two Qt apps: one client and one server.
I use them to send some data for handle a remote device.
If I am in localhost I haven't issues about them, but when i search to connect them by internet i don't know how to find correct Ip server to connect Socket Client.
How i can find this ip node?
Is there a class to find It?
you cannot find it automatically, if this is what you're asking about.
In real life you would deploy your server on some publicly accessible host, give it a domain name (important part as your host can change the IP address at any time) and connect the client via the DNS domain.
However if you're just playing around and you want to show to the world that your app works, specifying the IP address of the server in your client code would be perfectly fine (assuming you're running both the server and the client in the same network).
In that case, if you're running mac/linux run the command ifconfig (or just ip depending on the distribution). On Windows you can run the command ipconfig. Both windows and linux will give you a similar output resembling this:
Pay attention to the network adapters. There can potentially be many of them. You may have some emulated adapters if you have docker or VMWare, you may have the wireless adapters if you have a WiFi card, and then the ethernet adapters if your computer can connect to the the internet with an ethernet cable. Each of these adapters specifies a different IPv4 address. You want to pick the one that is connected to the same network as your client. So for instance if both your server machine and your client running machine are connected to the same wifi, you pick the address from the Wireless LAN adapter

How to connect to raspberry Pi over internet if we know only its MAC Address

I have Raspberry Pi and a mobile app developed in ionic.It has to communicate over SocketIO and normal HTTP request. I can communicate if i know IP address and port no. But what if I'm using it over internet and my raspberry pi's IP address is changing dynamically due to DHCP. How do i connect to my raspberry Pi device. Is their a way to connect if I know MAC address of Rasspberry PI.
Short Answer: no
Slightly Longer:
MAC is only useful at Layer 2. So the minute you have a router between you and the device, you will no longer be able to see the MAC. If you control the Layer 2 network you can statically assign a DHCP address, or you can look at the logs and see what IP it was assigned, but if the device is connecting to networks you don't control and its address is changing, you will need a way for the Raspberry Pi to register where it currently lives. There are a variety of ways to do this, such as dynamic dns registration, or you could have it phone home to some sort of locator service that your app could then query, etc... But without extra software you are probably out of luck.
You should use a dynamic IP service like www.noip.com. They provide a free linux and/or windows client.
That way, when your public IP changes, you will still be able to connect.

Same ip address for multiple devices?

I want to develop an Android app that connects with a Windows desktop application via TCP/IP.
However I have very little knowledge of networking and so please forgive me if this is a very basic doubt.
My Windows based laptop as well as Android phone are connected to the internet via the same WiFi router.
Now I checked the IP address for my laptop as well as phone using a website.
Both are same!
If both have the same IP address, then to achieve networking between these devices I will choose different set of port numbers.
Will this connection work?
Is the connection happening via the internet or just locally on my
router?
EDIT: After reading the answer from #Doon, I have broadened my question.
Let's say the local address of laptop is 192.168.1.10 and that of phone is 192.168.1.20.
If I code my application to use these IP addresses, it should work as it is a local network.
But what if I want my laptop to connect with another phone which is not connected to the WiFi router, rather by 3G network.
Then which IP address should be used for the laptop and the other phone?
Since I am not allowed to use any other server, I am going to use port forwarding i.e. the user will type in the IP address displayed on the other device. The connection could be initiated on either one of the devices.
If you could also show how to do this programmatically, it would be very helpful.
My Windows application is developed in C++ using Qt.
All of your devices are sharing 1 external or WAN IP address using NAPT (network address port translation). Internally on your LAN each device has its own address. So yes it will work but you are going to need to use internal addrss and the devices actual IP address not its perceived address via an external service.
As for the connection locally or via router that all depends on where you are connecting to. If both end points are on your lan or on the same Subnet then the router will not be involved. So in the average home network between your phone and desktop both connected to the same network say via wifi then they are most likely layer 2 adjacent (see the OSI 7 layer model for more info on layer 2 vs layer 3). But once they are not on the same network then routing will be involved and your router will be used. If the phone is connected to 3G or the cell data network and you want it to talk to your desktop on your home network you are going to need to deal with port forwarding on your router and other such fun things.
In regards to updates. Once you leave the local network it gets more complicated especially with IPv4 as address are running out so there is more and more use of nat or IPv6 with 6 to 4 gateways. Do you want the laptop to initiate connect to the phone or phone to the laptop? But normally you will need to iterate your address on your interfaces. Then connect with an external service to get your external IP address and compare and see if they are the same. if both endpoints are dynamically assigned you will need some sort of location mechanism could be dynamic DNS could be locator service etc.

Windows 7 does not accept broadcasts from ip address 0.0.0.1

we have little network devices which are shipped with IP address 0.0.0.1 to ensure that they never collide with any other device in their new environment (thus none of the 10.x.x.x, 172.16.x.x or 192.168.x.x ranges) until configuration. DHCP is no solution since there might be no DHCP server in the field.
The devices would listen to UDP broadcasts and answer with broadcasts until they are given their new IP address this way.
This worked fine with Windows XP - but sucks with Windows 7: the config program does not receive the answer packets from the devices which still have 0.0.0.1. Wireshark sees the packets, then they are dumped by the system.
Question: Is there any reason (RFC?) that actually prohibits using this address in a local environment? Or is it just MS that was overcautious? Where can I read why they treat this address "invalid"? Which ranges are really "invalid" now, too?
Any idea of a workaround on the PC side (Win 7)?
I know that it is not recommended to use 0.xxx addresses for work places, but for this very reason - having a not-used address - it works perfectly.
Edit: there is a device out there called "Netburner" which might have faced the similar issue, according to their forum. See: http://forum.embeddedethernet.com/viewtopic.php?f=5&t=612&p=2198 Does - by coincidence - anybody know some background information?
It sounds as if your configuration application is listening for broadcast packets on all network interfaces and expecting to receive packets from foreign subnets.
That should not work - the OS should only pass-on broadcast packets from the subnets each network interface is on, not from all subnets on the same physical (e.g. Ethernet) segment. I am reasonably certain that doing otherwise is broken behaviour WRT the IP protocol.
The are two ways to deal with this:
Make sure that your network interface has an IP address in the target subnet. You can have more than one IP addresses for each network card, so that should not interfere with normal network operations.
Configure or modify you application to use raw sockets, like Wireshark. Keep in mind, however, that this overrides all normal checks and balances and should be avoided, since it can cause behaviour that is almost impossible to diagnose - which is why it is frowned upon by meny network administrators.
Can you you add new routing table entries to Windows machines easily? Windows has to know which interface to use when routing a broadcast packet to the 0.0.0.x network.
The Unix machines I'm familiar with have a routing table that maps network/netmask entries to either gateways or interfaces (if the network is a local network). The local network (192.168.0.0/16 for my home network) gets sent to interface eth0. Everything else 0.0.0.0/0 gets sent to a specific gateway machine 192.168.0.1.
If my machine sent a UDP broadcast message to network 0.0.0.0/24 (in other words, UDP broadcast sent to 0.0.0.255, then my machine would forward the packet to the gateway machine (which it can look up via arp). The switches in the middle wouldn't propagate the packet to other network devices, because the MAC address is set.
If my machine had another routing entry for 0.0.0.0/24 to the local interface, then my machine would send the packet on the wire using an ethernet broadcast group, and the switches would forward the packet to all connections. (Yay! Just like hubs in the 90s! :)
So I figure you need to add a routing entry for 0.0.0.0/24 to your client machines, so that they can properly address the broadcast packet.

Resources