1

If I am binding a http service to 192.168.1.2, will it make additional requests to my router in order to determine what my local IP is, or it will compare the IP to the local network configuration and if they match going nowhere?

Also why i can't bind the service to 127.0.0.1:8888 ?

Coops
  • 6,055
  • 1
  • 34
  • 54
Somebody
  • 364
  • 1
  • 6
  • 17
  • can you give some more details of what you're trying to bind to port 8888? We need to know the service (apache/tomcat/etc), the configuration your using, and the error you're getting. – Coops Jun 30 '11 at 15:19
  • I'm using node.js webserver. I'm trying to bind http server. When i'm using 192.168.1.2 as binding address requests are directed properly to webserver. But when i'm using 127.0.0.1 it's like they are going some wrong way and browser getting "webpage unavailable" – Somebody Jun 30 '11 at 15:30
  • Guess i'll have to dive a bit deeper into the low level network mechanics. :D – Somebody Jun 30 '11 at 15:50

3 Answers3

2

If you host has already configured 192.168.1.2 as it's IP address, no additional requests need to be made to the router in order to bind and listen on a port with that IP.

However, many HTTP servers will do a reverse DNS lookup of the IP in order to attempt to understand what hostname is associated with this IP. This is probably something you don't need to worry about.

Kyle Smith
  • 9,683
  • 1
  • 31
  • 32
0

I'd say that your first question is operating system dependent, but there's no modern OS that I can think of that would work that way. If you have that IP assigned to a NIC that's local to the machine, your traffic will not leave the NIC.

As for the second question, you need to let us know what HTTP server you're using and what OS you're on.

MDMarra
  • 100,734
  • 32
  • 197
  • 329
  • node.js on Ubuntu. Actually it's listening, but when i'm trying to connect it's not letting me to http server. I have DMZ turned ON on the router for 192.168.1.2 – Somebody Jun 30 '11 at 14:57
0

If the particular IP is configured locally on a network interface, the server will match the IP you give it to the interface the IP lives on. It will then only listen for traffic coming via that device. (It won't need to go 'check' on the network).

This can be a good security measure, for instance if you have a service which is only needed locally (e.g. MySQL), don't bind it to your internet-facing interface.

Normally if you give a service an IP that doesn't exist locally it will return an error along the lines of "failed to bind to X". However there are some situations where you need to a service to bind to an IP that may not currently existing on the service. An example is in a highly-available setup, where IPs can move between servers.

In that case the sysctl setting net.ipv4.ip_nonlocal_bind will let you do so without an error.

Coops
  • 6,055
  • 1
  • 34
  • 54