IPV4 - routes, and such - confused
duaneellissd opened this issue · 8 comments
I'm not getting any IPV4 packets out of the TUN driver in P2P mode.
I don't understand why and I am a bit confused.
It seems that no matter what I do, I do not get IPv4 Traffic - I see IPv6 but no IPv4
What I don't know how to do is determine the route windows wants to use.
Interface configuration:
Unknown adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9
Physical Address. . . . . . . . . : 00-FF-0D-20-6E-9E
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::456:c9a:9c24:6df3%17(Preferred)
IPv4 Address. . . . . . . . . . . : 10.168.42.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.252
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 285277965
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-2F-CD-E0-98-E7-43-7A-1E-F9
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
I read in the OpenVPN source code that, in P2P mode, the network mask must be exactly 255.255.255.252 - so that's what I have.
I also see in the same code, the IP address for the WINDOWS side (last bits) must be 1 or 2, and the REMOTE side must be the other 2 or 1.
Thus, I configured the windows interface as 10.168.42.1, my remote side is 10.168.42.2
The ROUTING TABLES are as follows:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.168.99.1 10.168.99.195 25
10.168.42.0 255.255.255.252 On-link 10.168.42.1 281
10.168.96.0 255.255.252.0 On-link 10.168.99.195 281
10.168.99.195 255.255.255.255 On-link 10.168.99.195 281
10.168.99.255 255.255.255.255 On-link 10.168.99.195 281
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
169.254.0.0 255.255.0.0 On-link 169.254.13.25 281
169.254.13.25 255.255.255.255 On-link 169.254.13.25 281
169.254.255.255 255.255.255.255 On-link 169.254.13.25 281
192.168.56.0 255.255.255.0 On-link 192.168.56.1 281
192.168.56.1 255.255.255.255 On-link 192.168.56.1 281
192.168.56.255 255.255.255.255 On-link 192.168.56.1 281
192.168.125.0 255.255.255.0 On-link 192.168.125.1 291
192.168.125.1 255.255.255.255 On-link 192.168.125.1 291
192.168.125.255 255.255.255.255 On-link 192.168.125.1 291
192.168.162.0 255.255.255.0 On-link 192.168.162.1 291
192.168.162.1 255.255.255.255 On-link 192.168.162.1 291
192.168.162.255 255.255.255.255 On-link 192.168.162.1 291
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 192.168.56.1 281
224.0.0.0 240.0.0.0 On-link 192.168.125.1 291
224.0.0.0 240.0.0.0 On-link 192.168.162.1 291
224.0.0.0 240.0.0.0 On-link 10.168.99.195 281
224.0.0.0 240.0.0.0 On-link 169.254.13.25 281
224.0.0.0 240.0.0.0 On-link 10.168.42.1 281
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 192.168.56.1 281
255.255.255.255 255.255.255.255 On-link 192.168.125.1 291
255.255.255.255 255.255.255.255 On-link 192.168.162.1 291
255.255.255.255 255.255.255.255 On-link 10.168.99.195 281
255.255.255.255 255.255.255.255 On-link 169.254.13.25 281
255.255.255.255 255.255.255.255 On-link 10.168.42.1 281
===========================================================================
Persistent Routes:
None
I have 3 tests I've tried:
Method 1: ping 10.168.42.2
- I would expect some activity
Method 2: ping -6 -S localipv6address someipv6addressonnetwork
Method 3: curl -o foo http://10.168.42.2
For case 2, The IPv6 seems to work using linked local addresse (fe80), and specifying the target address as the same as the ipv6 addres but +1, thus it is on the same IPv6 segment. This works, I see packets out of the tun driver but no IPv4 packets.
Agree it's an ARP problem, I think it is a design limitation -
I am using P2P Mode, not TUN mode. I am not using DHCP, perhaps I should
I would have expected P2P mode to "just work" - I think the problem is described below
I see this in Wireshark:
I believe the AUTOIP address (169.254) is the default address given at startup.
When I start the adapter (ie: ioctl(set media state) I see the two gratuitous ARPs
Then later, I try to PING the remote side, I then see the three "Who has" ARP requests, but nothing comes out of the driver into my user space app.
Looking at the code in "device.c" - I find the function ProcessARP() which seems to send the ARP reply, it lives in the txpath.c - it is called under 2 conditions: (A) Line 597 - if DHCP is enabled, I'm not enabling it
//=====================================================
// Are we running in DHCP server masquerade mode?
//
// If so, catch both DHCP requests and ARP queries
// to resolve the address of our virtual DHCP server.
//=====================================================
if (Adapter->m_dhcp_enabled)
{
const ETH_HEADER *eth = (ETH_HEADER *) tapPacket->m_Data;
const IPHDR *ip = (IPHDR *) (tapPacket->m_Data + sizeof (ETH_HEADER));
const UDPHDR *udp = (UDPHDR *) (tapPacket->m_Data + sizeof (ETH_HEADER) + sizeof (IPHDR));
// ARP packet?
if (packetLength == sizeof (ARP_PACKET)
&& eth->proto == htons (NDIS_ETH_TYPE_ARP)
&& Adapter->m_dhcp_server_arp
)
{
if (ProcessARP(
Adapter,
, or case (B) line 662 - This part is confusing the COMMENT states one thing, but the code reads the reverse. - confused.
//===============================================
// In Point-To-Point mode, check to see whether
// packet is ARP (handled) or IPv4 (sent to app).
// IPv6 packets are inspected for neighbour discovery
// (to be handled locally), and the rest is forwarded
// all other protocols are dropped
//=============================================== if (Adapter->m_tun)
{
ETH_HEADER *e;
e = (ETH_HEADER *) tapPacket->m_Data;
switch (ntohs (e->proto))
{
case NDIS_ETH_TYPE_ARP:
// Make sure that packet is the right size for ARP.
if (packetLength != sizeof (ARP_PACKET))
{
goto no_queue;
}
ProcessARP (
Adapter,
.... snip snip ...
@gert - Thanks that helps me understand the problem
I also see that that in the P2P case, the adapter->m_tun = TRUE
occurs my bad there.
Question 1: what sends the Gratuitous ARP at startup - The driver or windows?
Question 2: Would the fact the driver seems to have 2 IP address (the auto-ip + configured) be the problem, I donot for example see a loop that tests: "For all configured ip address on this driver" thus it would never capture the second address (The first I assume is the AUTO-IP, the SECOND I assume is the configured address)
Question 3: Can you explain the DHCP side? I can turn that on if it helps - I got the impression and I could be wrong - that it needs to work with the remote side DHCP server... or something like that.
In my case my remote does not have a DHCP server, it's a really dumb micro controller running LWIP/SLIP - do I really need to run a dhcp server on that board to make this work?
In any case - If I enable the DHCP - I want to pass the correct parameters - Looking at the driver code, it looks like there are 4 parameters to the DHCP server call. Value 0 - the DHCP address, Value 1 = The DHCP Netmask, value 3 = The DHCP Server IP, Value 4 = the lease time in seconds.
@cron2 (Gert) - Follow up question
Sure, because you need to tell(!) the driver which address to reply to.
Where exactly do I do this, when I configure for P2P - there are 2 parameters
-
Parameter 0 - is the local IP - I presume that is the IP address of the local interface, which in my case is 10.168.42.1 (I pass this, the .1 address) - the remote device is 10.168.42.2 (not setting this)
-
Parameter 1 is the netmask, which is 255.255.255.252 (0xfffffffc)
Edit - Its not _at_gert, it is _at_cron2...
Still no joy.
Enabling the DHCP server seems to work, the adapter is configured now :-) via dhcp
In wire shark I do see the DHCP requests... and the ack.
And in wireshark I see the ARP requests for .2 but I don't see replies.
Unknown adapter TAP_TUN:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9
Physical Address. . . . . . . . . : 00-FF-0D-20-6E-9E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::456:c9a:9c24:6df3%4(Preferred)
IPv4 Address. . . . . . . . . . . : 10.168.42.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.252
Lease Obtained. . . . . . . . . . : Tuesday, March 31, 2020 11:52:07 AM
Lease Expires . . . . . . . . . . : Wednesday, April 1, 2020 11:52:07 AM
Default Gateway . . . . . . . . . :
DHCP Server . . . . . . . . . . . : 10.168.41.255
DHCPv6 IAID . . . . . . . . . . . : 285277965
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-25-2F-CD-E0-98-E7-43-7A-1E-F9
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
The ARP output, ie: arp -a -v
gives this, I don't know why the .2 address says: Invalid.
C:\Windows\system32>arp -a -v
Interface: 127.0.0.1 --- 0x1
Internet Address Physical Address Type
224.0.0.22 static
239.255.255.250 static
Interface: 10.168.42.1 --- 0x4
Internet Address Physical Address Type
10.168.42.2 00-00-00-00-00-00 invalid
10.168.42.3 ff-ff-ff-ff-ff-ff static
224.0.0.22 01-00-5e-00-00-16 static
224.0.0.251 01-00-5e-00-00-fb static
224.0.0.252 01-00-5e-00-00-fc static
239.255.255.250 01-00-5e-7f-ff-fa static
255.255.255.255 ff-ff-ff-ff-ff-ff static