2

I run into a big problem on my project yesterday. I have a local server which I connect to through websockets. Everything works fine.

The next step of the project was to use it when the network wasn't connected to internet. I thought it would go smoothly. Wrong! The websockets wouldn't connect.

After many hours, I found out that the local server would basically send a frame to try to resolve the local IP of the connecting client, and would lock the connection until it gets a reply, which my router couldn't answer as internet was unplugged.

The bad workaround I found was to add my client IP in the /etc/hosts/ But I cannot add all local addresses to the 'hosts' file.

Any idea how to prevent ubuntu to resolve local IPs? it configured as DHCP:

$>more /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet dhcp

Thanks a lot in advance

4
  • So, you have a client and server, that are connected locally? While you're connected to the internet everything works, however when the internet is disconnected, you can't connect to the server? Your client is getting a public IP address for the server and not the local, so when the public is down it can't route? I'm not sure I completely follow.
    – user508889
    May 12, 2016 at 13:11
  • So, both client and server are on the same local network. client has IP 192.168.1.121 and server has IP 192.168.1.124 What is troubling is that when I connect to the server (by SSH for example), the server is trying to resolve the 'hostname' 192.168.1.121.... It doesn't make much sense to me.... So when I unplugged the internet cab;e from the router, it takes 8 or 10 seconds to NOT resolve it, thus 'blocking' the connection process for as many seconds. For SSH it is fine, but the websockets I am using time out on connection May 12, 2016 at 13:46
  • Is your 'hostname' including the domain name, with a tld? Like hostname.domain.com ?
    – user508889
    May 12, 2016 at 18:45
  • No. Each 'hostname' is one word. And all the communication is made with IP addresses and no hostname or domain name May 13, 2016 at 6:53

2 Answers 2

0

you can add static hostname aliases for IP addresses to your /etc/hosts file to have them resolve without using DNS.

Gotchas:

Be carefull to ensure the 127.0.0.1 locahost line remains intact as it can cause lots of other problems if thats missing.

The hosts file is still used when you are connected so its up to you to ensure that it makes sense in that situation as you can alias any hostname to any ip with it.

3
  • I know, but I can't rewrite the host with all the IP addresses of the local network. I would just like the local IPs not to be 'resolved' as if they were domain names.... May 12, 2016 at 13:47
  • i don't see why you can't add all the hosts to the /etc/hosts file , if you can refer to them in code they are static enough to go in that file. Maybe some more detail might help.
    – Amias
    May 13, 2016 at 11:01
  • because: - I don't think it is a nice way of doing it - I also work on big networks with 'subnetworks' where the Local Server subnetwork can be different from the 'client' subnetwork... Thus prevent to make that solution happen... May 13, 2016 at 12:27
0

Me and all my colleagues had same problem, I fix this issue by install samba and restart services after that.

sudo apt install samba

then

sudo service smbd restart

after this you can connect to other network place by Entering something like this:

smb://domain.something/somepath$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .