title: How to send a UDP packet from a specific interface under Linux?
body: <p>I have several Ethernet interfaces with IPv4 Link-Local addresses, which means I have multiple routes to <code>169.254.0.0/16</code> on different interfaces. (Those interfaces are not necessarily on the same layer 2 network, so the same IP in this range can be used by different systems on different interfaces.)</p>
  
  <p>When sending a UDP packet to an address in <code>169.254.0.0/16</code> I can't pick which interface will be used to send the packet using Rust's standard library <code>UdpSocket</code>, but without specifying the interface it is very likely to use the wrong one.</p>
  
  <p>How can I send a UDP packet from a specific interface?</p>
  
  <p>(IPv6 Link-Local <code>fe80::/64</code> has a similar problem, but <code>SocketAddrV6</code> has a <code>scope_id</code> which can be used to set the index of the interface to use).</p>