Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]/etc/hosts dynamic ip adress
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
chi86
Apprentice
Apprentice


Joined: 30 Jul 2013
Posts: 164
Location: Austria

PostPosted: Thu Jul 23, 2015 4:14 pm    Post subject: [SOLVED]/etc/hosts dynamic ip adress Reply with quote

Hi,
for connecting to a licence server I need to put in the line:

/etc/hosts:
Code:

# Imaginary network.
X.X.X.X     chi
#10.0.0.2               myname
#10.0.0.3               myfriend


the problem is that when I connect via VPN I always get another ip adress, therefore I need to put in as X.X.X.X always my current ip adress. Is there a way to put in a dynamic adress?

Thanks!


Last edited by chi86 on Sat Jul 25, 2015 9:47 am; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1747

PostPosted: Thu Jul 23, 2015 6:01 pm    Post subject: Reply with quote

For YOUR IP address you always use 127.0.0.1. And you call it "localhost".
For dynamic remote IP go either for private DNS with automagic registration or for Avahi and this line:
hosts: files mdns dns
in /etc/nsswitch.conf

Avahi lets your machine introduce itself and nsswitch defines whether or not your machine will trust and use it. And obviously it's easier to setup than your own DNS. It's purpose is to provide "zero configuration networking".

/etc/hosts is static by design. You don't want to change it every time you connect.
Back to top
View user's profile Send private message
chi86
Apprentice
Apprentice


Joined: 30 Jul 2013
Posts: 164
Location: Austria

PostPosted: Thu Jul 23, 2015 6:50 pm    Post subject: Reply with quote

Thanks for the help, but it wont work. I tried it with Avahi but I still cant connetct to the licence server! It just works when I add the line in my /etc/hosts!
Back to top
View user's profile Send private message
chi86
Apprentice
Apprentice


Joined: 30 Jul 2013
Posts: 164
Location: Austria

PostPosted: Thu Jul 23, 2015 6:55 pm    Post subject: Reply with quote

The ip adress I have to add there is the one from tun (VPN)! Maybe thats the problem!
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1747

PostPosted: Thu Jul 23, 2015 9:03 pm    Post subject: Reply with quote

Quote:
I tried it with Avahi but I still cant connetct to the licence server!
and have you updated nsswitch? It doesn't happen automagicaly, you have to do that yourself.
Also, you need sys-auth/nss-mdns for this to work.

Quote:
but it wont work.
Why? Your VPN blocks multicasts, or maybe you just didn't know all the parts you need?
Doing dynamic configuration based on hosts file is ugly and hackish at best, and then you will still need some way to discover the remote host which get's us back to either avahi or automagic registration in your private DNS.
Unless you have psychic plugin there... Or you will provide that IP manually, in which case you can just as well stick to "nano /etc/hosts"

Another solution: it might be possible to force static IP. Assign it manually to VPN's interface. I don't know what setup you have there, but assigning IP of your choice might "just work"
Back to top
View user's profile Send private message
chi86
Apprentice
Apprentice


Joined: 30 Jul 2013
Posts: 164
Location: Austria

PostPosted: Sat Jul 25, 2015 9:41 am    Post subject: Reply with quote

szatox wrote:
Quote:
I tried it with Avahi but I still cant connetct to the licence server!
and have you updated nsswitch? It doesn't happen automagicaly, you have to do that yourself.
Also, you need sys-auth/nss-mdns for this to work.


I did the installation like described in: https://wiki.gentoo.org/wiki/Avahi but the last entry:
Code:
root #ping hostname.local

Wont do anything!

It there not a simple way to get the ip address from my tun interface? Because than I could put it into my /etc/hosts?
Back to top
View user's profile Send private message
chi86
Apprentice
Apprentice


Joined: 30 Jul 2013
Posts: 164
Location: Austria

PostPosted: Sat Jul 25, 2015 9:46 am    Post subject: Reply with quote

Ok after all it was an easy fix :).

I just added my hostname (chi) to the line:
Code:

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


in /et/hosts.

And now it works!!!!!

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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