# hostname - not correctly setup

## Joseph_sys

when I type "hostname" I get syscon5

in /etc/hosts

127.0.0.1	localhost.localdomain localhost syscon5

When I try to connect to via browser to 127.0.0.1 or localhost apache tries to connect to local server, I get:

It Works

Which is OK

But when I type "syscon5" apache takes me to Internet.  WHY?

Where is this setting coming from?

I remove hostname from /etc/conf.d/hostname

hostname=""

restart net.eth0 but when I type hostname I still get "syscon5"Last edited by Joseph_sys on Fri Dec 16, 2011 8:18 pm; edited 2 times in total

----------

## Joseph_sys

I change in /etc/conf.d/hostname

hostname="localhost"

restart hostname and I hostname give me "localhost" when I log OUT and try to log IN Dbus gives me some error message

When I reboot, hostname gives me "syscon5" instead of localhost.

Why is it doing it?

----------

## krinn

because /etc/hosts file format is

IP FQN SN

IP, well the ip

FQN: the full name of the host

SN: short name of the host

a short sample:

127.0.0.1 localhost.localdomain localhost

and to gave a name to your host

192.168.0.95 mister.localdomain mister

now you can ping mister

----------

## Joseph_sys

 *krinn wrote:*   

> because /etc/hosts file format is
> 
> IP FQN SN
> 
> IP, well the ip
> ...

 

Thank you, yes that works.  Except my hostname is assign via firewall DHCP server, so doesn't matter what I use locally.

This is solved but my problem still remains.  I can not create dataset via sql-ledger I get some strange message and even the main developer of the SQL-Ledger doesn't know what to do.

Web-browser is giving me an error

```
ERROR - could not connect to server: Permission denied

Is the server running locally and accepting connection to Unix domain

socket "/var/run/postgresql/.s.PGSQL.5432"?
```

In apache.error log

```
[error] [client 127.0.0.1] DBI

connect('dbname=template1','sql-ledger',...) failed: could not connect

to server: Permission denied, referer: http://localhost/sql-ledger/admin.pl

[error] [client 127.0.0.1] \tconnections on Unix domain socket

"/var/run/postgresql/.s.PGSQL.5432"? at SL/User.pm line 253, referer:

http://localhost/sql-ledger/admin.pl
```

I tested with the SQL-Ledger developer all possible combination and we can not figure it out.

I though, that it might me my network setup "hostname" problem but it does not appear to be the case either.

I don't know what else to try.  My setting appear to be working on all three other computers but not the new one I'm setting up.

I've been using Gentoo for almost 10-years and if I can not resolve this problem I'll have to jump to another distro  :Sad: 

as I've run out of ideas what to try or how to test it.

Question: Is it possible that this error is caused by some strange permission setting of these programs:

1 - Perl, 5+

 2 - http server (Apache, NCSA, httpi, thttpd, ...)

 3 - SQL Server (PostgreSQL 7.1+)

 4 - DBD (DBD-Pg)

 5 - DBI

as I've set some of them up via ssh connection.

----------

## Joseph_sys

Which Gentoo package install hostname scrip and configuration?

Hostname on my machine is being forced by DHCPD from my firewall, setting in /etc/conf.d/hostname DO NOT take effect.

----------

## Joseph_sys

I've re-emerged: openrc, net-tools and gettext

but it did not help, I have in my /etc/conf.d/hostname

hostname="localhost"

but I'm getting "syscon5" from my firewall.  Why?

----------

## krinn

You should have an option in your dhcp to disallow that, and no i cannot help you i have 0 dhcp server as i have no use for one.

to take a popular one, http://www.phystech.com/download/dhcpcd_man.html

 *Quote:*   

> -D
> 
>     Forces dhcpcd to set domainname of the host to the domainname option supplied by DHCP server. By default dhcpcd will NOT set domainname of the host to the domainname option received from DHCP server. 
> 
> -h <hostname>
> ...

 

So you use dhcpcd and have -D option set, or that manpage is outdate and the default has change, but still an option should exist then to disallow this.

----------

## kimmie

I don't think the host name is your problem.

 *Quote:*   

> 
> 
> ```
> ERROR - could not connect to server: Permission denied 
> 
> ...

 

Looks like your perl program is trying to connect to postgres via a UNIX domain socket, which is not the same thing as a TCP socket, and has nothing to do with DNS or IP addresses. For this to work, the calling process must have unix permissions on that socket, as well as whatever permissions are setup in pg_hba.conf. See the postgres doco for details. To force it to work, you could try chmod 777 "/var/run/postgresql/.s.PGSQL.5423", but don't leave it that way, it's not secure. Or maybe postgres isn't listening on the socket; anyway the problem lies between perl DBD and postgres configs.

Also: 

 *krinn wrote:*   

> because /etc/hosts file format is
> 
> IP FQN SN
> 
> 

 

This isn't correct; the format is "IP canonical_name aliases". Aliases can be whatever you wish, they don't have to relate to the canonical name in any way.

----------

## krinn

yep alias, but we say "petit nom" in french  :Razz: 

----------

## kimmie

J'ai le melon mauvais!   :Very Happy: :

----------

## krinn

as good as my english  :Smile: 

----------

## Joseph_sys

 *krinn wrote:*   

> You should have an option in your dhcp to disallow that, and no i cannot help you i have 0 dhcp server as i have no use for one.
> 
> to take a popular one, http://www.phystech.com/download/dhcpcd_man.html
> 
>  *Quote:*   -D
> ...

 

There is still something wrong with the system. I connected the box to another firewall that does not push the hostname on the clients.  When box booted it had correct name "user@localhost" my connection problem still persist :-/

I'll install Ubunto on to see if it suffers from the same problem.

----------

