How to use files hosts / Comment utiliser fichier hosts

Hello, (French below / Français dessous).

I have a question about using the host file, to avoid hairpainning I modified the hosts file as follows:
192.168.1.XX domain

But is it possible to write it this way:
192.168.1.XX domain External.IP domain

So that the hosts know how to type on both addresses if the computer is being used on the same network as the server or if it is being used on an outside network?

Thanks for your feedback
Guillaume


Bonjour,
J’ai une question sur l’utilisation du fichier host, pour éviter les hairpainning j’avais modifié le fichier hosts de la manière suivante :

IP interne domaine

Mais est-ce possible de rédiger les choses de cette manière :

IP interne domaine
IP externe domaine

De manière à ce que le hosts sachent taper sur les deux adresses si l’ordinateur est utiliser sur le même réseau que le serveur ou s’il est utiliser sur un réseau extérieur ?

Merci pour vos retours
Guillaume

That’s not a valid syntax for hosts file.

If you want to switch of network with your laptop without changing your hosts file (i guess you have hairping issue that force you to write in your hosts file), i recommend you to use your yunohost server has a DNS resolver.

Like that you can configure your network connexion at home with the ip of your server has a DNS resolver, and when you connect on an other network you will use the DHCP resolver instead…

To do that:

sed -i "s/listen-address=127.0.0.1/listen-address=127.0.0.1,SERVER_LOCAL_IP/g /etc/dnsmasq.conf
systemctl restart dnsmasq
yunohost firewall allow UDP 53

If you are not using vpnclient_ynh, you should check your box is not configured in DMZ mode, and check you are not forwarding the 53 port. If your 53 port is reachable from outside, your server could be used in DNS attack.

1 Like

Sound create, i will try it with my raspberry before :slight_smile:
Thanks a lot it will be more easy than always switch hosts files