From owner-freebsd-questions@freebsd.org Fri May 4 07:13:01 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AAD63FCA400 for ; Fri, 4 May 2018 07:13:01 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from bede.qeng-ho.org (bede.qeng-ho.org [217.155.128.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C9916887C for ; Fri, 4 May 2018 07:13:00 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from arthur.home.qeng-ho.org (arthur.home.qeng-ho.org [172.23.1.2]) by bede.qeng-ho.org (Postfix) with ESMTP id 8804C10645; Fri, 4 May 2018 08:03:55 +0100 (BST) Subject: Re: UDP packet transmission To: Doug Hardie , freebsd-questions@freebsd.org References: <91591EE5-91EA-4C79-BE7B-A5F9F53CFADA@mail.sermon-archive.info> From: Arthur Chance Message-ID: <3e93f140-af24-fba0-65f2-70c772a338f8@qeng-ho.org> Date: Fri, 4 May 2018 08:03:55 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <91591EE5-91EA-4C79-BE7B-A5F9F53CFADA@mail.sermon-archive.info> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2018 07:13:01 -0000 On 04/05/2018 05:05, Doug Hardie wrote: > I have a somewhat unusual situation and have not found a solution for it. I have a remote machine running 12 current. It has two independent internet connections. They are from two different sources and have different IP addresses. One is a fixed IP address and the other dynamic. The purpose is to be able to access the device if one of those interfaces is down. It is only accessed when problems occur. Typically that is when the fixed address is not accessible. The problem is there is no way to know the dynamic address. > > To address this, I tried sending a UDP packet through the dynamic IP link to another machine at a fixed IP address. It records the IP address that originated the packet and logs it. Hence, I can easily find the last dynamic IP that was used and access the device through that. However, to make that happen, I need to be able to send a UDP packet that goes through a specific interface and does not use the routing table. > > The most frequent approach I have found is to bind the socket to only the dynamic IP address's interface. However, that does change the originating IP address in the packet to that interface, but continues to transmit via the interface found in the routing table. > > Another suggestion was to use raw sockets. However, all the reading on that (Stevens et al) indicate that the packet will still be transmitted on the interface selected in the routing table. > > Yet another suggestion was to change the routing table temporarily, send the packet, and then change it back. Besides a lot of potential for weird stuff, it would break a number of other connections going through the fixed IP address. > > I am hoping there is another solution that would be better. Thanks, Why not use setfib to give the UDP packet sending process its own routing table? -- An amusing coincidence: log2(58) = 5.858 (to 0.0003% accuracy).