5/21/2023 0 Comments How to get gateway ip on macIf not, we just use the IP address to calculate network id. So, first we take the IP address of the route table's first entry and check if the IP address can be found in ARP table. I think we can just use the first entry of route table without iterating all routes. It seems that on MacOS the first entry is always the default gateway or the route that has the longest matching prefix (In VPN case, the destination is 0/1). Unfortunately, NetLink is not available on MacOS. MAC address for TAP devices, IP of GW or network address if GW is not specified for TUN devices. We should use the best information available, i.e. MAC addresses are available only in case of TAP devices which use ethernet frames. Michal, could you remind me again why do we want to use gateway's MAC address? I was wondering maybe we should use the gateway's IP instead of MAC address to calculate network id. The gateway 10.8.2.1 has no MAC address, so our current implementation does not work. You shouldn't try to interpret all routes, instead get a route for some predefined host like we do in NetlinkService: This is just one possibility how to override default GW. This forces all trafic to be routed to VPN instead of the default gateway. Internet:ĭestination Gateway Flags Refs Use Netif Expire ![]() It seems that NordVPN adds two routes in my route table. (In reply to Kershaw Chang from comment #1)
0 Comments
Leave a Reply. |