Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
localhost / local IP confusion
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Abraxa
Apprentice
Apprentice


Joined: 14 Jun 2005
Posts: 172
Location: Germany

PostPosted: Wed Apr 02, 2014 8:16 am    Post subject: localhost / local IP confusion Reply with quote

Hello fellow gentoo-ers,

I've recently run into a networking issue that was a little tough to track down. The situation is that an Eclipse plugin launches an external Qt application and tries to talk to it via UDP:

Quote:
Eclipse plugin sends from 192.168.178.34:X to 127.0.0.1:20000
Qt program sends from 192.168.178.34:20000 to 192.168.178.34:X
ICMP msg appears, says 192.168.178.34:X is unreachable

The result is that the reply packets never arrive. 192.168.178.34 is my eth0 IP.

On a VM with Ubuntu, it looks like this:

Quote:
Eclipse plugin sends from 127.0.0.1:X to 127.0.0.1:20000
Qt program sends from 127.0.0.1:20000 to 127.0.0.1:X

Here, everything works as intended and the programs can have a nice chat.

Now if I add the line "192.168.178.34 localhost" to /etc/hosts, the Eclipse plugin and the Qt program can talk on my system, too:
Quote:
Eclipse plugin sends from 192.168.178.34:X to 192.168.178.34:20000
Qt program sends from 192.168.178.34:20000 to 192.168.178.34:X


While I do reckon that such a line does not belong, it makes sense if I assume the Eclipse plugin is looking up "localhost" in order to determine the IP to send to. But why would it send from my local IP instead of localhost to begin with? For the record, "127.0.0.1 localhost" has always been present in that file.

Does anyone have an idea what could be going on here? The fact that it works as intended on Ubuntu tells me that there must be a configuration issue or bug on my gentoo system.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31365
Location: 56N 3W

PostPosted: Wed Apr 02, 2014 9:42 pm    Post subject: Reply with quote

Abraxa,

Please post your /etc/hosts
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Abraxa
Apprentice
Apprentice


Joined: 14 Jun 2005
Posts: 172
Location: Germany

PostPosted: Thu Apr 03, 2014 5:34 am    Post subject: Reply with quote

Hello NeddySeagoon,

this is my /etc/hosts:

Code:
# /etc/hosts: Local Host Database
#
# This file describes a number of aliases-to-address mappings for the for
# local hosts that share this file.
#
# In the presence of the domain name service or NIS, this file may not be
# consulted at all; see /etc/host.conf for the resolution order.
#

# IPv4 and IPv6 localhost aliases
127.0.0.1      localhost
::1             localhost


After replacing 127.0.0.1 by 192.168.178.34, things start working.

Thanks for the assistance!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31365
Location: 56N 3W

PostPosted: Thu Apr 03, 2014 12:13 pm    Post subject: Reply with quote

Abraxa,

What's there is correct. You need another entry
Code:
192.168.178.34   <hostname>


<hostname> is your PC hostname.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
szatox
Tux's lil' helper
Tux's lil' helper


Joined: 27 Aug 2013
Posts: 128

PostPosted: Thu Apr 03, 2014 7:38 pm    Post subject: Reply with quote

don't replace 127.0.0.1, it is supposed to be bound to localhost. Adding another line with your eth0 address and hostname seems to be a better idea.

What does `route -n` show?
What happens when you ping localhost?
Does eclipse or that plugin have any settings that allow it to force source IP rather than let system take care of that?
Back to top
View user's profile Send private message
kingjames
n00b
n00b


Joined: 21 Mar 2014
Posts: 3

PostPosted: Sat Apr 05, 2014 8:28 pm    Post subject: Reply with quote

Even the line is empty ( without 127.0.0.1 localhost )

I can still access localhost on browser. I tested.
Back to top
View user's profile Send private message
666threesixes666
Veteran
Veteran


Joined: 31 May 2011
Posts: 1223
Location: 42.68n 85.41w

PostPosted: Sat Apr 05, 2014 9:58 pm    Post subject: Reply with quote

Code:

# IPv4 and IPv6 localhost aliases
127.0.0.1      localhost
::1             localhost


aliases as in your host name. im pretty sure you could drop your ip address as an alias also.

ie

Code:

# IPv4 and IPv6 localhost aliases
127.0.0.1      localhost  <hostname>
::1             localhost  <hostname>


from mr neddy's post.
_________________
cat /etc/*-release
Funtoo Linux - baselayout 2.2.0
consider this warning no. 1
http://ecx.images-amazon.com/images/I/81Ku-vxIb3L._SL1500_.jpg
http://wiki.gentoo.org/wiki/Special:Contributions/666threesixes666
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum