Host name showing (none) at login - linux

I am a newbie to Linux environment and building a Linux system from scratch using busy box. I created /etc/hosts and /etc/hostname file. But every time I start the system it shows (none)login:
But I can change the hostname using hostname command after logging in. I don't want any FQDN hostname or dynamic hostname configuration from DNS server. The content of the host name files are:-
$cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 tiny
$cat /etc/hostname
tiny
Is there wrong with the procedure or file. Please any help is appreciated.

You're likely going about this the right way and just need to either restart the system sudo reboot (or just reboot as the root user) or reload networking.
On Ubuntu and other Debian-variants, you're correct - you need to update /etc/hostname and /etc/hosts. To reload networking: service networking reload or invoke-rc.d networking force-reload.
On Fedora/CentOS and other Red Hat variants, you can set the hostname using the hostnamectl program. To reload networking: /etc/init.d/network reload
On Android, I believe the command you want is: setprop net.hostname <your name here>.
Also, you can combine your entry in /etc/hostname to:
127.0.0.1 localhost tiny

Perhaps your IP-address is not really 127.0.1.1 (it seems unlikely).
On most Linux systems, you have the ifconfig tool, which can show your IP-address. I would check if the IPv4 address displayed by ifconfig matches the IP-address given for "tiny" in your /etc/hosts file - and modify it to match. Once you have done that, you should be able to ping "tiny" to verify that the hosts file is updated. Verifying that the hostname is going to be used takes a reboot, of course.

Setting /etc/hostname and /etc/hosts doesn't work for my embedded arm Linux box. Instead, I put this line in the start script:
echo tiny > /proc/sys/kernel/hostname

Related

how to see client's ip address instead of hostname in remote syslogs

my client machine has syslog-ng and my remote machine has rsyslog configuration.
my server/remote machine manages many clients and I need to differentiate which machine is sending which logs.
normally I would use syslog-ng on the server side but these machines aren't meant to have them.
Also would like to mention it isn't for apache or web servers just physical machines.
On the client's side
Tried altering and adding different options or changing them to yes/no respectively.
options {
keep_hostname(yes);
create_dirs(no);
use_dns(no);
};
for eg:keep_hostname to no, it worked but only when I changed the hostname to the machine's ip address. which is not what I want.
Using a template
template("$(ISODATE) $(FULLHOST_FROM) $(SOURCEIP) $(HOST) $(HOSTNAME) ${PROGRAM}: ${MESSAGE}\n")
output:
day time localhost abc[ID] .source.s_local SourceIP=127.0.0.1 localhost localhost (root) CMD (xyz.conf)#ID
this isn't the output I want, it is printing in the message section when I want it in the place of the "host" and I don't understand how the source ip is the loopback address.
Using structured logging
rewrite r_sourceip{
set('${SOURCEIP}' value(HOST));
};
log { source(s_local); rewrite(r_sourceip);destination(d_syslog_tcp); };
output:
and the ip is displayed in the logs as the loopback address instead of the machine ip.
day date time 127.0.0.1 syslog-ng.service: Succeeded.
Tried installing rsyslog on my client but it doesn't work
sudo add-apt-repository ppa:adiscon/v8-stable
sudo apt-get update
sudo apt-get install rsyslog
I kept running into many errors, fixing them was impossible due to the difference in OS version or type maybe.
add apt repository command not found
wget command not found
On the server's side
Using a template
which creates a folder with the client's hostname and stores the logs in that particular folder.
not the solution I want.
$template DynaFile,"/var/log/%FROMHOST-IP%/%syslogfacility-text%.log"
*.* -?DynaFile
I want the logs to appear as such
day date time `client's ip address` syslog-ng.service: Succeeded.
Can someone suggest me a solution and why I keep getting the loopback address as my client's ip?

How can I get the IP of the docker host on a Linux system from a docker container?

This question appears to have been asked many times, but the answers appear to be outdated, or just not work.
I'm on a Linux system without a RTC (a raspberry pi). My host runs an ntp daemon (ntpd), which checks the time online as soon as the host boots up, assuming it has internet, and sets the system clock.
The code inside my container needs to know if the host's system clock is accurate (has been updated since last boot).
On the host itself, this is very easy to do - use something like ntpdate -q 127.0.0.1. ntpdate connects to 127.0.0.1:123 over udp, and checks with the ntpd daemon if the clock is accurate (if it's been updated since last boot). This appears to be more difficult to do from within a container.
If I start up a container, and use docker container inspect NAME to see the container's IP, it shows me this:
"Gateway": "172.19.0.1",
"IPAddress": "172.19.0.6",
If I run ntpdate -q 172.19.0.1 within the container, this works. Unfortunately, 172.19.0.1 isn't a permanent IP for the host. It that subnet is already taken when the container is starting up, the subnet will change, so hardcoding this IP is a bad idea. What I need is an environment variable that always reflects the proper IP for the host.
Windows and MacOS versions of docker appear to set the host.docker.internal hostname within containers, but Linux doesn't. Some people recommend setting this in the /etc/hosts file of the host, but then you're just hardcoding the IP, which again, can change.
I run my docker container with a docker-compose.yml file, and apparently, on new versions of docker, you can do this:
extra_hosts:
- "host.docker.internal:host-gateway"
I tried this, and this works. Sort of. Inside my container, host.docker.internal resolves to 172.17.0.1, which is IP of the docker0 interface on the host. While I can ping host.docker.internal from within the container, using ntpdate -q host.docker.internal or ntpdate -q 172.17.0.1 doesn't work.
Is there a way to make host.docker.internal resolve to the proper gateway IP of the host from within the container? In my example, 172.19.0.1.
Note: Yes, I can use code within the container to check what the container's gateway is with netstat or similar, but then I need to complicate my code, making it figure out the IP of the NTP server (the docker host). I can probably also pass the docker socket into the container, and try to get the docker host's IP through that, but that seems super hackey, and an unnecessary security issue.
The best solution I've found is to use the ip command from the iproute2 package, look for the default route and use the gateway address for it.
ip route | awk '/default/ {print $3}'
if you want it in an environment variable, you can set it in an entrypoint script with
export HOST_IP_ADDRESS=$(ip route | awk '/default/ {print $3}')

Change hostname of Linux machine

I have a host "india.niksula.hut.fi". I want to change it to "test.india.niksula.hut.fi". I ran the command:
sudo hostname test.india.niksula.hut.fi
I also modified the /etc/hostname file to have "test.india" instead of "india", which was previously the case. When I ran the command:
hostname --fqdn
I get "test.india.niksula.hut.fi". Now, when I am trying to ping that name from another machine, it gives:
ping: unknown host test.india.niksula.hut.fi
SSH also gives the same result. I need to be able to access the name "test.india.niksula.hut.fi". Can anyone help please?
Thanks in advance!
How should the other machine know about the host name at all? Have you a DNS-service running where you store your host mames with the corresponding IP addresses?
So you either run a DNS service or store the host-names with the proper IP addresses in your /ets/hosts on all your machines.

cannot SSH beaglebone after changing

In order to get internet through USB from my ubuntu host, I changed routing on beaglebone
route add default gw 192.168.7.1
and change /etc/resolv.conf into
nameserver 192.168.1.1
It gets internet but I cannot ssh beaglebone like before anymore from any host.
Normally I did ssh root#192.168.7.2
but it doesn't return any message or prompt to enter password.Just blank waits there.
I there any way to fix it?
Are you sure that you shouldn't configure /etc/resolv.conf with
nameserver 192.168.7.1
It my happen that the ssh daemon is trying to resolve the reverse of the ip address you're connecting from, and it takes long to timeout, giving you the impression that it does not work.

linux centos 6.3 hostname (dhcppc4) assigned automatically

Linux terminal showing hostname dhcppc4 that i never configured. As per configuration files hostname must be localhost :
[root#dhcppc4 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
[root#dhcppc4 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Note : I attached a new monitor to my laptop.
Don't know how but sometimes terminal shows localhost as hostname.
what is dhcppc4? How to resolve the issue?
This question is not suitable for stackoverflow (this should be on serverfault i guess)
Anyway, DHCP server could even assign an hostname to your machine
Look here: RFC 1553 - DHCP
Maybe this is your case?
You are most assuredly allowed to edit the HOSTNAME line of that config' file you refer to in your question just fine.
It will not show up until you logout & back in again. You will also want to run /etc/init.d/rsyslogd restart (or whatever syslog daemon you are using) to make that name take effect in the log files.
You may or may not need to run a vi /etc/hosts to adjust the lines in there as you need for your specific applications. Most will be fine, but some are very very picky, like the otherwise very awesome software, Zimbra, for one example, wont work if those lines are not perfect. Asterisk could be another one that might require that file to be perfect match with your configuration.
You can or can not work with your DHCP server to set this, but most people dont, most edit the HOSTNAME and move on.
It is actually important, though, and do in fact resolve this, dont just leave it, as we sysadmins do not want to be typing mission critical commands at the BASH prompt on the wrong machine when all 6 of your servers all say "localhost".

Resources