Fix inaddr_any for sending packets... - TCP-IP

This is a discussion on Fix inaddr_any for sending packets... - TCP-IP ; Hello, Currently: Bind inaddr_any. Send packet. Packet.SourceIp contains default interface ip. Which is interface 1 usually. ^^^ This is bad. Better would be: Routing software already knows the correct interface based on Packet.DestIP. Thus routing software should set Packet.SourceIp to ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Fix inaddr_any for sending packets...

  1. Fix inaddr_any for sending packets...

    Hello,

    Currently:

    Bind inaddr_any.

    Send packet.

    Packet.SourceIp contains default interface ip. Which is interface 1 usually.

    ^^^ This is bad.

    Better would be:

    Routing software already knows the correct interface based on Packet.DestIP.

    Thus routing software should set Packet.SourceIp to SelectedInterface.IP.

    Bye,
    Skybuck.



  2. Re: Fix inaddr_any for sending packets...

    HI Skybuck,

    Which operating system you are talking about?
    In the case of Linux, as u said, it takes the IP address of interface
    on which the destination IP address is reachable (of course using
    routing database).

    Alternately you can use bind the socket to specific IP address.

    Neo
    Techpulp Technlogies
    http://techpulp.com/


    On Aug 4, 9:37 pm, "Skybuck Flying" wrote:
    > Hello,
    >
    > Currently:
    >
    > Bind inaddr_any.
    >
    > Send packet.
    >
    > Packet.SourceIp contains default interface ip. Which is interface 1 usually.
    >
    > ^^^ This is bad.
    >
    > Better would be:
    >
    > Routing software already knows the correct interface based on Packet.DestIP.
    >
    > Thus routing software should set Packet.SourceIp to SelectedInterface.IP.
    >
    > Bye,
    > Skybuck.



  3. Re: Fix inaddr_any for sending packets...

    I don't think so, not when specifieing inaddr_any or something like that
    during the bind.

    I have seen others mention the same problems... not sure if it was linux or
    unix.

    Also it only happens in certain situations see other sub thread about that


    Bye,
    Skybuck.



  4. Re: Fix inaddr_any for sending packets...

    Situation where problem becomes apperent with addr_any:

    Interface 1, LAN-IP
    Interface 2, INTERNET-IP

    Bye,
    Skybuck.



  5. Re: Fix inaddr_any for sending packets...

    On Aug 4, 12:29*pm, "Skybuck Flying" wrote:

    > Situation where problem becomes apperent with addr_any:
    >
    > Interface 1, LAN-IP
    > Interface 2, INTERNET-IP


    This cannot occur if the machine is a gateway. Gateways NAT packets
    with LAN source addresses and Internet destination addresses.

    This cannot occur if the machine is not a gateway. Machines that are
    not gateways send packets with LAN source addresses and Internet
    destination addresses to their gateway, which NATs them.

    So this can never be a problem unless the machine is horribly
    misconfigured.

    DS

  6. Re: Fix inaddr_any for sending packets...

    See

    IPHLPAPI:

    GetBestInterface function.

    So far seems to work... but not yet tested with weird situations

    Bye,
    Skybuck.



  7. Gateway (Re: Fix inaddr_any for sending packets...)

    David Schwartz writes
    in alt.winsock.programming, comp.protocols.tcp-ip:

    > On Aug 4, 12:29*pm, "Skybuck Flying" wrote:
    >
    > > Situation where problem becomes apperent with addr_any:
    > >
    > > Interface 1, LAN-IP
    > > Interface 2, INTERNET-IP

    >
    > This cannot occur if the machine is a gateway. Gateways NAT packets
    > with LAN source addresses and Internet destination addresses.
    >
    > This cannot occur if the machine is not a gateway. Machines that are
    > not gateways send packets with LAN source addresses and Internet
    > destination addresses to their gateway, which NATs them.
    >
    > So this can never be a problem unless the machine is horribly
    > misconfigured.
    >
    > DS



    Execept, that real gateways (routers) do not rewrite source IP address.


    Static routing tables, routing protocols and so on assigments takes
    care that Internet knows what network is behind of router.

    Network on question is then of course assigned (and routable).



    NAT (rewriting source IP address) is commonly used when network
    on question is not assigned (certain IP ranges are reserved
    for private use and are not routable).



    ( That is not relevant for Skybuck Flying )


    ( This is comp.protocols.tcp-ip after all ... )


    / Kari Hurtta

  8. Re: Gateway (Re: Fix inaddr_any for sending packets...)

    On Aug 5, 9:18*pm, Kari Hurtta +comp.protocols.tcp...@siilo.fmi.fi> wrote:

    > Execept, that real gateways (routers) *do not rewrite source IP address..


    Gateways between LANs that use private addresses and the Internet most
    certainly to rewrite source IP addresses. They have to.

    > NAT (rewriting source IP address) is commonly used when network
    > on question is not assigned (certain IP ranges are reserved
    > for private use and are not routable).


    In his example, the machine has one interface in a LAN that uses
    private addresses and one interface on the Internet. It must either do
    NAT itself or have a gateway on the LAN. Otherwise its configuration
    is inconsistent.

    DS



+ Reply to Thread