Sending and receiving packets without being connected

The Scenario:

I have two Laptops L1 and L2
I have two routers R1 and R2(each using OpenWRT 18.06.1) having same MAC and IP( I cloned the MAC and IPs are 192.168.1.1)

L1 is connected with R1 and L2 is connected to R2 separately through wireless.

Now in the ARP table of R1, I add the IP and MAC of L2. (using arp add ... command)
Similarly, in the ARP table of R2, I add the IP and MAC of L1.

So the R1 and R2 have the IP and MAC of both Laptops.

Now I am trying to ping L2 from L1. However, it shows L2 cannot be reached.

Can anyone explain where is the error having?

You can't have two devices with the same MAC and IP talking to each other. I assume you cloned it because you're ISP requires it? If so, that's fine but you need to change the MAC and IP of the 2nd router (i.e. the one which will not be connected to your DSL/Cable modem.)

2 Likes

I concur with @pbel. In addition, you'll need to resolve the IP conflicts you created.

(Moved to Installing and Using OpenWrt - Network and Wireless Configuration.)

I changed their MAC and IP too. But it didnt work.

So my challenge is to find out a way to send a packet from a router to device which is not connected to that router.

I am trying to mimic the system.

Is my logic feasible?

I'm not sure if your logic is feasible...you seem to be describing something not possible...unless you route via IP addresses.

  • Can you be more clear?
  • What system are you trying to mimic, exactly?

I am trying to develop a system that makes the device receive packet from a router without being connected to it.

Is it possible somehow to hardcode a route via address in openwrt?

it most certainly will not work if the dont have any sort of connection.
please refine your meaning.

1 Like

A router requires a path from the source (S) to the destination (D). If you don't have a route (i.e. literally some sort of connection S->...->D), the routers (R1, R2) can't do the job. I think we've all been assuming that what you were trying to do was S->R1->R2->D where each is connected to the next either via Ethernet or Wifi at each step.

If that's what you're trying to do I'd suggest you turn off DHCP on the 'internal' router (i.e. the one that won't be connected to your ISP device), then connect R1 to R2 with an Ethernet cable from a LAN port on R1 to a LAN port on R2 (i.e. don't connect the WAN of one to the LAN of another... that gets a bit more complicated), and make sure your S and D are both using DHCP so they can 'see' each other on the same subnet. While this may not be exactly what you want, it's a starting point because it will show that the basic hardware and configuration you have is working.

I have once set up a system where two routers connected to each other had identical ip addresses (but the mac were different), this was a requirement so that all routers under development could be flashed with an identical image - which made production far easier.

It wasn't a fun solution, but the approach was that the local lan had 192.168.1.0/24 addresses, and viewed the other router as having a 192.168.2.0/24 address, this means that routing could be preformed.

However when any packet was received from the link connecting the two routers, both a SNAT and DNAT were performed, so the packet originally has source 192.168.1.x and destination 192.168.2.x; which was then SNAT and DNAT to have source 192.168.2.x and destination 192.168.1.x.

This did allow communication between the two. I wouldn't suggest doing this unless you absolutely have to - its far easier to set up nets at ether end on different IP ranges.

So the connection is
S--->R1
D--->R2

No when ping D from S, S sends a packet to the R1 having a destination IP of D. Now I have manually added the arp details of D in R1. So R1 will think he is connected to D. So it will broadcast the packet.

Now the broadcasted packet will reach D. Now D sees that packet is coming from a router having the same IP and MAC of the one it is connected, so it will assume it is coming from R2. So it accepts the packet as the destination IP is of R2.

Does it sounds clear?

  • Why don't you just make a route to D in R1 (and a route to S in R2), like normal?

I don't understand why you're making ARP entries.

I need it that way for my research.

ARP entries I made to make it appear to the router as if it is connected to the device virtually

I guess the question is how does R1 know to send a packet to R2, when the packet in question has a destination address of D2, which is under R1 subnode.

look at ip route on each machine, then the address you are sending it to, and look at how it will route ...

1 Like

The question I have is a basic question.
Say D1 is connected to R1(router) There is another router R2 too having the same IP and MAC.(hardcoded IP and MAC)

None of the routers are connected to any backbone.

Now when D1 sends a packet, since its connected to R1 it sends only to R1?
Or when D1 sends a packet it broadcasts to everyone around, the devices that has the same destination address of the packet, receives it and the others who don't drops it.

This doesn't matter, as long as they're connected to each other.

:confused:

If D1 is plugged into R1, obviously it's the only place it can send a packet, that's why R1 is the gateway/router.

Perhaps, you should better explain your experiment, and why you refuse to just make a static route. I don't understand what you're trying to solve. In addition, machines don't move packets to routers via a broadcast MAC address, they use the MAC of the router - perhaps this is confusing you; as it seems you keep trying to forward a broadcast packet based on its source address.

1 Like

My experiment is to receive a packet from a router even though device is not connected to it.
Or to deliver a packet to a router even though it is not connected to it.

  • Then you will need to connect R1 and R2 together
  • On R1, you will need to make a static route to the subnet of D2 via the interface connected to R2
  • On R2, you will need to make a static route to the subnet of D1 via the interface connected to R1
  • Done!

Much of your topology is missing, but I am assuming that R1 is connected to R2 in some way. Even if not, how to think about this may help you.

There are two layers involved, Layer 2, Ethernet, for example, and Layer 3, TCP/IP. Layer 2 is how the packets get from point A to point B. Layer 3 is the TCP/IP addresses and content.

If D1 wants to ping D2 at 1.2.3.4, it first looks at its routing table to see if it can communicate directly or if it needs to use a router. Since it seems from your lead post that both your routers have the same LAN address, I assume they have the same network. That means that 1.2.3.4 is on the same subnet as D1, so D1 considers the IP address to be "link local" (at least in absence of a static route to D2). It looks at its ARP table, which has your manually entered value. The interface creates an Ethernet packet with that MAC address as the destination, fills its payload with the TCP/IP ping header (TCP/IP addresses and then some), and the TCP/IP payload (if any). It puts it out on the wire. Nobody responds. Done. R1 could care less, as the packet is neither a broadcast packet nor does it match its MAC address.

What do you mean by "not connected"? Explain please!

1 Like