0

I have the following setup:

Android Galaxy S5 Mini. Android version 5.1.1.

I have 2 network interfaces:

  1. Interface1 with ip: 192.168.5.1
  2. Interface2 with ip: 192.168.5.10

I create a DatagramSocket using Android SDK and bind it to address: 192.168.5.10(Interface 2), port 2525. I put this socket in receive and wait for packets. I use another device to send the packets.

Packets from ip address: 192.168.5.4 is received.

Packets from ip address(different device): 192.168.5.1 (same as the device's Interface1 ip) is never received.

It seams that the network stack rejects packets which have source ip address which exists in the device, regardless of the interface it was received in.

If I modify the ip address for Interface1 to something other than 192.168.5.1 it works fine.

Devices on which it didn't happen:

  1. Samsung tablet T113 Android 4.4.4 (Stock rom)
  2. LG G4 Android 6.0 (Stock rom)
  3. LG Nexus 5X Android 7.1.2 (Stock rom)

Devices on which it did happen:

  1. Galaxy S5 Mini Android 5.1.1 (Stock rom)
  2. Galaxy Note 3 Android 6.0.1 (CyanogenMod)
  3. One+1 Android 6.0.1 (CyanogenMod)

What is the mechanism which rejects the packet with source IP 192.168.5.1(same as the device's Interface1 ip)?

enter image description here

3
  • I suspect IP address conflict, also you can't have gateway ip address match client ip address. Commented Jun 13, 2017 at 11:08
  • @xavier_fakerat I managed to use Android's VPNService and inject a packet to the system. If it has the source ip of any interface - the problem occurs. It doesn't seem to be related to GW/Client issue.
    – noti
    Commented Jun 13, 2017 at 11:26
  • 1
    +1 Yes you are right, I actually stumbled across this here: unix.stackexchange.com/questions/106291/…. I reckon this needs root Commented Jun 13, 2017 at 12:17

1 Answer 1

1

I found why this happens, but not sure if I can do anything about it without root. There is a system configuration per network interface called accept_local. For example: net.ipv4.conf.wlan0.accept_local. When it is set to 0, it can't receive packets from another local interface. Probably when it works on other devices, this configuration is set to 1. On Galaxy Note 3 it was set to 0. Once I did this, everything started working, but root was needed.

Update

Found a site which list the system variables values: https://census.tsyrklevich.net/

Specifically:

  1. https://census.tsyrklevich.net/sysctls/net.ipv4.conf.wlan0.accept_local
  2. https://census.tsyrklevich.net/sysctls/net.ipv4.conf.wlan0.rp_filter
2
  • 1
    fixed formatting Commented Jun 13, 2017 at 12:20
  • @xavier_fakerat I checked the value of accept_local on the devices that worked with no modification. accept_local = 0, which means that it shouldn't have worked on them. So how come it did?
    – noti
    Commented Jun 14, 2017 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .