date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,351,783,683,000 |
I have two CentOS 7 VM's running in virtualbox. On each of the machines I want to set the hostname and a static IP address. VM1 works just fine. VM2 does not. I did the same thing on both servers so I'm not sure why VM2 is having issues. It shows as localhost.localdomain and I can't get it to read the new correct hostname. Here is what I've done:
Modified the /etc/sysconfic/network file as follows:
NETWORKING=yes
HOSTNAME=newhost.newdomain
Modified the /etc/resolv.conf file as follows:
nameserver 8.8.8.8
Modified the /etc/sysconfig/network-scripts/ifcfg-enp0s3 file as follows:
HWADDR=#
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=enp0s3
UUID=#
ONBOOT=yes
IPADDR=192.168.10.1
NETMASK=255.255.255.0
NM_CONTROLLER=no
GATEWAY=192.168.10.100
The interface works and the IP is assigned as specified. The only thing that does not work is the hostname. I can change it temporarily by using the 'hostname {newname}' command but that is only a temp fix as it reverts back on reboot. All of this is the same as on VM1 (except for the IP address assigned) and VM1 works fine. I'm not concerned with the hosts file at the moment since I'm not worried about name resolution; I'm just worried with the hostname.
Any thoughts or suggestions?
|
Try setting the host name in /etc/hostname
From the hostname man page on my CentOS 7 machine:
The host name is usually set once at system startup (normally by read‐ing the >contents of a file which contains the host name, e.g. /etc/hostname).
| CentOS 7 hostname will not change |
1,351,783,683,000 |
Why is it that when I run the command host examplewebsite.com it gives me website's ip, but for some websites, when I type that IP address into the address bar and hit enter, it shows me a 404 page?
Shouldn't it take me to the website I got ip from?
|
The difference is in how DNS and the HTTP "Host" header work.
The site you're going to may have multiple sites hosted using the same server. In DNS, all the names for the sites hosted on that IP list the single server IP address. When you enter the name in the browser, the browser sends the hostname to the server using the "Host" header. If you enter only the IP, since it can't know what site you want to go to. Mapping the IP to a name ("reverse DNS") is separate from mapping the name to an IP.
| Getting a website's ip with 'host'? |
1,351,783,683,000 |
I am debugging something related to LDAP loggins, Ldap SSH Login not working - Same configs worked on 20+ other servers - Ubuntu and I noticed that in some servers, the logs use localhost and in others they have the hostname. Having the hostname seems to make the most sense, especially if we were to centralize the log files.
How is this configured? Why isn't it default to use hostname? Just kinda made me curious...
Examples :
Oct 29 11:23:56 daily sshd[20625]: pam_unix(sshd:session): session opened for user LDAPUSERNAME by (uid=0)
Or
Oct 29 10:56:36 localhost sshd[2560]: pam_unix(sshd:auth): check pass; user unknown
Update:
user@qa-ops:~$ hostname
qa-ops
user@daily:~$ hostname
daily.domain.com
Perhaps it has to do with Daily having a full domain name in hostname? I always thought /etc/hostname was just supposed to be the short part of the hostname, not the full hostname.domain.com etc.
| ERROR: type should be string, got "\nhttps://wiki.archlinux.org/index.php/rsyslog#Configure_Hostname\n\nRsyslog uses the glibc routine gethostname() or gethostbyname() to determine the hostname of the local machine. The gethostname() or gethostbyname() routine check the contents of /etc/hosts for the fully qualified domain name (FQDN) if you are not using BIND or NIS.\n\nMore specifically, if the localhost entry for your IP comes first in /etc/hosts, then it will take precedence.\n(Assuming that files is the first value in the hosts: line in /etc/nsswitch.conf. Or alternatively, that your hostname cannot be resolved using DNS).\n\nThe Arch Wiki page goes on to explain:\n\nYou can check what the local machine's currently configured FQDN is by running hostname --fqdn. The output of hostname --short will be used by rsyslog when writing log messages. If you want to have full hostnames in logs, you need to add $PreserveFQDN on to the beginning of the file (before using any directive that write to files). This is because, rsyslog reads config file and applies it on-the-go and then reads the later lines.\nThe /etc/hosts file contains a number of lines that map FQDNs to IP addresses and that map aliases to FQDNs. See the example /etc/hosts file below:\n/etc/hosts\n#<ip-address> <hostname.domain.org> <hostname>\n#<ip-address> <actual FQDN> <aliases>\n127.0.0.1 localhost.localdomain somehost.localdomain localhost somehost\n::1 localhost.localdomain somehost.localdomain localhost somehost\n\nlocalhost.localdomain is the first item following the IP address, so\n gethostbyname() function will return localhost.localdomain as the\n local machine's FQDN. Then /var/log/messages file will use localhost\n as hostname.\nTo use somehost as the hostname. Move somehost.localdomain to the first item:\n/etc/hosts\n#<ip-address> <hostname.domain.org> <hostname>\n#<ip-address> <actual FQDN> <aliases>\n127.0.0.1 somehost.localdomain localhost.localdomain localhost somehost\n::1 somehost.localdomain localhost.localdomain localhost somehost\n\n\nIt might be hard to tell exactly how the relevant information is selected from /etc/hosts (or the DNS) in various circumstances. Reading the source code again, I think rsyslog tries to resolve the system hostname (output of hostname command) into an FQDN.\nI think this means where it says \"gethostname or gethostbyname\" above, it should really say \"gethostname and gethostbyname\". So those instructions could probably be improved, but they at least point you at the right place.\nThere is also a very similar question asked on the rsyslog-users mailing list.\n" | Why do some of my logs use Localhost and others Hostname - Different Servers |
1,351,783,683,000 |
I'm trying to DENY access to port 1000 when it is being accessed through any host or IP that is NOT a specific host.
I.e.
If I try to access the service on sub.domain.com:1000 I should get in.
If I try to access the service on sub.domain2.com:1000 I should not get in, even though both of these domains are A-records pointing to the same server.
I'm trying to accomplish this using iptables with the following rules, but it's not working. It's allowing connections to any destination host/ip, not just the one I have set an ACCEPT rule to.
iptables -A INPUT -p tcp --destination sub.domain.com --dport 1000 -j ACCEPT
iptables -A INPUT -p tcp --dport 1000 -j DROP
The sub.domain2.com in this example, hosts different services, which is why I can't simply remove that DNS pointer.
|
IPTables is working on IP and TCP level, so it doesn't actually know DNS.
When a client creates a TCP connection to a DNS name it first looks up the IP address corresponding to the DNS name and then connects to the IP, not to the DNS name.
This means IPTables can't possibly know which DNS name a client is connecting to, it only knows which IP the client connects to.
If you specify --destination sub.domain.com as a parameter, IPTables will simply do a name look up to the IP that corresponds to this name, and then use the IP in it's rules.
If your port 1000 serves HTTP it would be possible to configure an HTTP server on that port to not handle requests to domains other than sub.domain.com, but IPTables doesn't have the necessary information to this.
If you could put sub.domain.com and sub.domain2.com onto two different IPs on the same server, then IPTables would be able to deny access to one but not to the other, because it could decide based on the IP.
This illustrates nicely that the Domain Name System is on top of Transport (TCP) and Internet (IP), for more details you can read the wikipedia article about it:
| How to deny access to specific port when destination is NOT a specific host? |
1,351,783,683,000 |
I'm following this guide and I'm running into issues.
https://www.tecmint.com/initial-ubuntu-server-setup-guide/
I am trying to create a linux machine in Ubuntu in wsl2 and then rename it using hostnamectl but have the error
Failed to create bus connection: No such file or directory
I have tried to follow these solutions.
This solution suggested installing a package which I did.
How do I fix my problem with hostnamectl command. It cannot connect to dbus
xuhu55@LAPTOP-DUPSMABG:/usr/share$ sudo dpkg -l | grep dbus
[sudo] password for xuhu55:
ii at-spi2-core 2.28.0-1 amd64 Assistive Technology Service Provider Interface (dbus core)
ii dbus 1.12.2-1ubuntu1.2 amd64 simple interprocess messaging system (daemon and utilities)
ii libdbus-1-3:amd64 1.12.2-1ubuntu1.2 amd64 simple interprocess messaging system (library)
ii python-dbus 1.2.6-1 amd64 simple interprocess messaging system (Python interface)
ii python3-dbus 1.2.6-1 amd64 simple interprocess messaging system (Python 3 interface)
xuhu55@LAPTOP-DUPSMABG:/usr/share$ sudo apt-get install dbus
Reading package lists... Done
Building dependency tree
Reading state information... Done
dbus is already the newest version (1.12.2-1ubuntu1.2).
0 upgraded, 0 newly installed, 0 to remove and 381 not upgraded
This other solution involved using strace which unfortunately showed that my problem was not a symlink problem that the other solution could have solved.
hostnamectl shows error: "Failed to create bus connection: No such file or directory"
xuhu55@LAPTOP-DUPSMABG:/usr/share$ strace hostnamectl
execve("/usr/bin/hostnamectl", ["hostnamectl"], 0x7ffff119f3f0 /* 20 vars */) = 0
brk(NULL) = 0x562bdd747000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/systemd/tls/x86_64/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/systemd/tls/x86_64/x86_64", 0x7fffde186d70) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/systemd/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...
stat("/lib/systemd", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=39569, ...}) = 0
mmap(NULL, 39569, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb215297000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb215295000
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb214c89000
mprotect(0x7fb214e70000, 2097152, PROT_NONE) = 0
mmap(0x7fb215070000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7fb215070000
mmap(0x7fb215076000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb215076000
close(3) = 0
openat(AT_FDCWD, "/lib/systemd/libsystemd-shared-237.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@|\3\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=2355440, ...}) = 0
mmap(NULL, 4457440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb214848000
mprotect(0x7fb2149fd000, 2093056, PROT_NONE) = 0
mmap(0x7fb214bfc000, 569344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b4000) = 0x7fb214bfc000
mmap(0x7fb214c87000, 5088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb214c87000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb214640000
mprotect(0x7fb214647000, 2093056, PROT_NONE) = 0
mmap(0x7fb214846000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb214846000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\30\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=22768, ...}) = 0
mmap(NULL, 2117976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb21443a000
mprotect(0x7fb21443e000, 2097152, PROT_NONE) = 0
mmap(0x7fb21463e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7fb21463e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\33\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=31232, ...}) = 0
mmap(NULL, 2126336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb214232000
mprotect(0x7fb214239000, 2093056, PROT_NONE) = 0
mmap(0x7fb214438000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb214438000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libcryptsetup.so.12", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0``\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=310040, ...}) = 0
mmap(NULL, 2405352, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb213fe6000
mprotect(0x7fb21402f000, 2097152, PROT_NONE) = 0
mmap(0x7fb21422f000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x49000) = 0x7fb21422f000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\274\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1155768, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb215293000
mmap(NULL, 3252232, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb213ccb000
mprotect(0x7fb213ddf000, 2093056, PROT_NONE) = 0
mmap(0x7fb213fde000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x113000) = 0x7fb213fde000
mmap(0x7fb213fe5000, 8, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb213fe5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libip4tc.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=27088, ...}) = 0
mmap(NULL, 2122304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb213ac4000
mprotect(0x7fb213aca000, 2093056, PROT_NONE) = 0
mmap(0x7fb213cc9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0x7fb213cc9000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libseccomp.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200L\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=309456, ...}) = 0
mmap(NULL, 2404592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb213878000
mprotect(0x7fb2138ab000, 2093056, PROT_NONE) = 0
mmap(0x7fb213aaa000, 106496, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x32000) = 0x7fb213aaa000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=154832, ...}) = 0
mmap(NULL, 2259152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb213650000
mprotect(0x7fb213675000, 2093056, PROT_NONE) = 0
mmap(0x7fb213874000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x24000) = 0x7fb213874000
mmap(0x7fb213876000, 6352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb213876000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libidn.so.11", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0+\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=206872, ...}) = 0
mmap(NULL, 2302000, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb21341d000
mprotect(0x7fb21344f000, 2093056, PROT_NONE) = 0
mmap(0x7fb21364e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x31000) = 0x7fb21364e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340(\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=153984, ...}) = 0
mmap(NULL, 2248968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb2131f7000
mprotect(0x7fb21321b000, 2097152, PROT_NONE) = 0
mmap(0x7fb21341b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x24000) = 0x7fb21341b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/liblz4.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\35\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=112672, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb215291000
mmap(NULL, 2207840, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb212fdb000
mprotect(0x7fb212ff6000, 2093056, PROT_NONE) = 0
mmap(0x7fb2131f5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a000) = 0x7fb2131f5000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libblkid.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\230\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=311720, ...}) = 0
mmap(NULL, 2411776, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb212d8e000
mprotect(0x7fb212dd5000, 2097152, PROT_NONE) = 0
mmap(0x7fb212fd5000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x47000) = 0x7fb212fd5000
mmap(0x7fb212fda000, 3328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb212fda000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb212b6f000
mprotect(0x7fb212b89000, 2093056, PROT_NONE) = 0
mmap(0x7fb212d88000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7fb212d88000
mmap(0x7fb212d8a000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb212d8a000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\20\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=18680, ...}) = 0
mmap(NULL, 2113752, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb21296a000
mprotect(0x7fb21296e000, 2093056, PROT_NONE) = 0
mmap(0x7fb212b6d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fb212b6d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libuuid.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\26\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=27112, ...}) = 0
mmap(NULL, 2122112, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb212763000
mprotect(0x7fb212769000, 2093056, PROT_NONE) = 0
mmap(0x7fb212968000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0x7fb212968000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdevmapper.so.1.02.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\266\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=432640, ...}) = 0
mmap(NULL, 2532048, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb2124f8000
mprotect(0x7fb21255e000, 2093056, PROT_NONE) = 0
mmap(0x7fb21275d000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x65000) = 0x7fb21275d000
mmap(0x7fb212762000, 720, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb212762000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libargon2.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=34872, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb21528f000
mmap(NULL, 2130080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb2122ef000
mprotect(0x7fb2122f7000, 2093056, PROT_NONE) = 0
mmap(0x7fb2124f6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7fb2124f6000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libjson-c.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P'\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=43304, ...}) = 0
mmap(NULL, 2138456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb2120e4000
mprotect(0x7fb2120ee000, 2093056, PROT_NONE) = 0
mmap(0x7fb2122ed000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x7fb2122ed000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340+\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=84032, ...}) = 0
mmap(NULL, 2179304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb211ecf000
mprotect(0x7fb211ee3000, 2093056, PROT_NONE) = 0
mmap(0x7fb2120e2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13000) = 0x7fb2120e2000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=464824, ...}) = 0
mmap(NULL, 2560264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb211c5d000
mprotect(0x7fb211ccd000, 2097152, PROT_NONE) = 0
mmap(0x7fb211ecd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x70000) = 0x7fb211ecd000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb211a59000
mprotect(0x7fb211a5c000, 2093056, PROT_NONE) = 0
mmap(0x7fb211c5b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fb211c5b000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libudev.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\3008\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=121016, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb21528d000
mmap(NULL, 2218280, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb21183b000
mprotect(0x7fb211858000, 2093056, PROT_NONE) = 0
mmap(0x7fb211a57000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7fb211a57000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\272\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb21149d000
mprotect(0x7fb21163a000, 2093056, PROT_NONE) = 0
mmap(0x7fb211839000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7fb211839000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb21528b000
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb215288000
arch_prctl(ARCH_SET_FS, 0x7fb215288940) = 0
mprotect(0x7fb215070000, 16384, PROT_READ) = 0
mprotect(0x7fb211839000, 4096, PROT_READ) = 0
mprotect(0x7fb212d88000, 4096, PROT_READ) = 0
mprotect(0x7fb214846000, 4096, PROT_READ) = 0
mprotect(0x7fb211a57000, 4096, PROT_READ) = 0
mprotect(0x7fb211c5b000, 4096, PROT_READ) = 0
mprotect(0x7fb211ecd000, 4096, PROT_READ) = 0
mprotect(0x7fb2120e2000, 4096, PROT_READ) = 0
mprotect(0x7fb2122ed000, 4096, PROT_READ) = 0
mprotect(0x7fb2124f6000, 4096, PROT_READ) = 0
mprotect(0x7fb213874000, 4096, PROT_READ) = 0
mprotect(0x7fb21275d000, 4096, PROT_READ) = 0
mprotect(0x7fb212968000, 4096, PROT_READ) = 0
mprotect(0x7fb212b6d000, 4096, PROT_READ) = 0
mprotect(0x7fb212fd5000, 16384, PROT_READ) = 0
mprotect(0x7fb2131f5000, 4096, PROT_READ) = 0
mprotect(0x7fb21341b000, 4096, PROT_READ) = 0
mprotect(0x7fb21364e000, 4096, PROT_READ) = 0
mprotect(0x7fb213aaa000, 102400, PROT_READ) = 0
mprotect(0x7fb213cc9000, 4096, PROT_READ) = 0
mprotect(0x7fb213fde000, 8192, PROT_READ) = 0
mprotect(0x7fb21422f000, 4096, PROT_READ) = 0
mprotect(0x7fb214438000, 4096, PROT_READ) = 0
mprotect(0x7fb21463e000, 4096, PROT_READ) = 0
mprotect(0x7fb214bfc000, 565248, PROT_READ) = 0
mprotect(0x562bdd4dd000, 4096, PROT_READ) = 0
mprotect(0x7fb2152a1000, 4096, PROT_READ) = 0
munmap(0x7fb215297000, 39569) = 0
set_tid_address(0x7fb215288c10) = 1612
set_robust_list(0x7fb215288c20, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7fb212b74cb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7fb212b81890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7fb212b74d50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7fb212b81890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL) = 0x562bdd747000
brk(0x562bdd768000) = 0x562bdd768000
statfs("/sys/fs/selinux", 0x7fffde187670) = -1 ENOENT (No such file or directory)
statfs("/selinux", 0x7fffde187670) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tt"..., 1024) = 474
read(3, "", 1024) = 0
close(3) = 0
access("/etc/selinux/config", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1683056, ...}) = 0
mmap(NULL, 1683056, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150ed000
close(3) = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2995
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=252, ...}) = 0
mmap(NULL, 252, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2152a0000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26376, ...}) = 0
mmap(NULL, 26376, PROT_READ, MAP_SHARED, 3, 0) = 0x7fb215299000
close(3) = 0
futex(0x7fb215075a08, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MEASUREMENT", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=23, ...}) = 0
mmap(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb215298000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TELEPHONE", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=47, ...}) = 0
mmap(NULL, 47, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb215297000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_ADDRESS", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=131, ...}) = 0
mmap(NULL, 131, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150ec000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NAME", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=62, ...}) = 0
mmap(NULL, 62, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150eb000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_PAPER", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=34, ...}) = 0
mmap(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150ea000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0
mmap(NULL, 48, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150e9000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MONETARY", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=270, ...}) = 0
mmap(NULL, 270, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150e8000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1516558, ...}) = 0
mmap(NULL, 1516558, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb21132a000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TIME", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3360, ...}) = 0
mmap(NULL, 3360, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150e7000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=50, ...}) = 0
mmap(NULL, 50, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150e6000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=199772, ...}) = 0
mmap(NULL, 199772, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb2150b5000
close(3) = 0
openat(AT_FDCWD, "/proc/self/stat", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "1612 (hostnamectl) R 1610 1610 1"..., 1024) = 312
close(3) = 0
getpid() = 1612
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0
setsockopt(3, SOL_SOCKET, SO_RCVBUFFORCE, [8388608], 4) = -1 EPERM (Operation not permitted)
setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8388608], 4) = 0
getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0
setsockopt(3, SOL_SOCKET, SO_SNDBUFFORCE, [8388608], 4) = -1 EPERM (Operation not permitted)
setsockopt(3, SOL_SOCKET, SO_SNDBUF, [8388608], 4) = 0
connect(3, {sa_family=AF_UNIX, sun_path="/run/dbus/system_bus_socket"}, 29) = -1 ENOENT (No such file or directory)
close(3) = 0
openat(AT_FDCWD, "/usr/share/locale/C.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/C.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/C/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/C.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/C.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/C/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
writev(2, [{iov_base="Failed to create bus connection:"..., iov_len=58}, {iov_base="\n", iov_len=1}], 2Failed to create bus connection: No such file or directory
) = 59
exit_group(1) = ?
+++ exited with 1 +++
|
At the core, the problem is that hostnamectl is a systemd utility, which acts on the systemd-hostnamed.service. WSL doesn't currently provide support for systemd.
Also, WSL sets the hostname to the name of the Windows computer hosting the instance. While you can change it by changing the Windows hostname (Control Panel -> System -> See the name of this computer -> Change Settings), you can't change the WSL hostname itself.
What's your ultimate goal with changing the hostname, other than just following the tutorial you linked? Perhaps there is a better solution (e.g. changing the prompt).
| hostnamectl command causes Failed to create bus connection: No such file or directory |
1,351,783,683,000 |
I was trying to change the hostname on my machine according to this article: https://www.blackmoreops.com/2013/12/12/change-hostname-kali-linux/
When I got to the part
service hostname.sh stop
sleep 1
service hostname.sh start
The hostname will stop correctly it seems, but I can't get it to start. Now, whenever I scan my IP from a secondary machine, my hostname appears as n/a.
When I try to start the hostname, it will say
Failed to start hostname.service: Unit hostname.service is masked.
I've done some research on the topic and I tried the command
systemctl unmask hostname.service
as well as
systemctl unmask hostname
These execute without error.
When I try any of these commands however, I get the same error again about it being masked.
systemctl enable hostname.service
systemctl enable hostname
systemctl start hostname.service
systemctl start hostname
start hostname.service
start hostname
Lastly, I even tried to mask it and then unmask it again, with the same result.
These symptoms persist through multiple reboots as well. I would greatly appreciate any help as I am quite stumped.
Also, for what it is worth, I am using Kali Linux a Debian distribution.
UPDATE
/etc/hosts
127.0.0.1 localhost
127.0.1.1 kali.net VVTOETSC
#The following lines are desirble for IPV6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
/etc/hostname
VVTOETSC
|
The article referenced in your question dates back to 2013 and is outdated. To change hostname simply do the following:
Disconnect from the network
Run the command hostname new_hostname as root.
Connect back to the network
| My machine has no hostname "Failed to start hostname.service: Unit hostname.service is masked." |
1,351,783,683,000 |
So due to problems with my hostname I just changed it. The problem with that is that in the tripwire configuration I left the hostname variable within the name of the dbfile and the local keyfile as it was. (like {$hostname}-abc.key)
First I tried simply renaming the files to match my new hostname. That didn't work.
I then used a backup and updated the tripwire configuration file as described here without that hostname-variable to match my old hostname.
This also didn't work as I get:
Error: Policy file does not match policy used to create database.
Exiting...
How can this be fixed without having to reinitialize the tripwire database? I still have an untouched (but moved and hence potentially differing ownership?) backup of my tripwire files. Maybe chown and alike could be used to solve this? I'm running Debian 9.1 with KDE.
And on a related note: where can I find a hash of the siggen file? It was missing after compilation so I had to copy it from another compilation that worked. Not sure if that warrants a separate question.
|
Ok I solved this now. Here are the steps I took for that:
Change your hostname back to what it was before by changing it via sudo texteditor /etc/hosts & sudo texteditor /etc/hostname
Reboot computer and check that the name is set correctly by running uname -n
Run a check: tripwire --check
Check/save/backup the report
Repeat steps 1 & 2 but change the hostname to the new hostname
Get a backup of all the relevant tripwire files in place
Rebuild configuration: sudo twadmin --create-cfgfile -S site.key twcfg.txt
Regenerate local key: sudo twadmin --generate-keys --local-keyfile {hostname}.key
Recreate policy: sudo twadmin -m P -S site.key twpol.txt
Initialize the database: sudo tripwire --init
Create a new offline backup
| Changed hostname, now I can't run a tripwire check: "policy file does not match policy used to create database" |
1,351,783,683,000 |
How is 127.0.0.1 related to 127.0.0.2?
Using ssh to login to tleilax (OpenSuSE):
tleilax:~ #
tleilax:~ # hostname
tleilax
tleilax:~ #
tleilax:~ # hostname -f
tleilax.bounceme.net
tleilax:~ #
tleilax:~ # cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
127.0.0.2 tleilax.bounceme.net tleilax
tleilax:~ #
tleilax:~ # exit
logout
Connection to 192.168.1.4 closed.
logged into doge (Ubuntu):
thufir@doge:~$
thufir@doge:~$ hostname
doge
thufir@doge:~$
thufir@doge:~$ hostname -f
doge.bounceme.net
thufir@doge:~$
thufir@doge:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 doge.bounceme.net doge
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
thufir@doge:~$
My understanding is that 127.0.0.1 and 127.0.1.1. are, at least in Ubuntu, used for the hostname:
Somme years ago Thomas Hood started a discussion[0] about how the system
hostname should be resolved.
The eventual result[1] was that Debian nowadays ships /etc/hosts like
these per default:
127.0.0.1 localhost
127.0.1.1 <host_name>.<domain_name> <host_name>
As also described in the Debian reference[2].
I had a short mail conversation with Thomas and he proposed bringing up
the following at d-d.
https://lists.debian.org/debian-devel/2013/07/msg00809.html
On tleilax I used yast -- why does it give an IP address of 127.0.0.2? Is that any different from 127.0.0.1? Is it just an artifact of using yast?
Finally, will it muck up yast in any way were I to change 127.0.0.2 to 127.0.0.1? I'm guessing it doesn't really matter -- I'm more curious about it.
To what extent is this just convention within each distro, versus a wider requirement for how IPv4 addresses work?
|
your loopback devicelo is bound to the network 127/8 (aka 127.0.0.1/255.0.0.0), thus any address in the range 127.0.0.1 to 127.255.255.254 is your local loopback.
therefore, it doesn't matter whether you use 127.0.0.1 or 127.0.0.2.
the reason why they (Debian) chose the scheme they chose are explained in the Debian-reference (and it's really a workaround for a bug)
| why are there different formats for the hosts file between OpenSuSE and Ubuntu? |
1,351,783,683,000 |
As you might know, by default, the hostname of an AWS instance is something like ip-12-34-56-78.us-west-2.compute.internal, so when I ssh to this host, the tab name is changed to root@ip-12-34-56-78 (a bit of difficult for me to identify which is which).
Since I have the following in the ~/.ssh/config:
Host mail.domain.com
Hostname 1.2.3.4
User root
Host web.domain.com
Hostname 5.6.7.8
User root
I'm wondering that is there any way to change the tab name to the "alias" hostname of the remote host I'm connected to (instead of the "real" hostname):
My current PS1 settings:
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
I have tried to add a ssh wrapper into ~/.bashrc:
ssh() {
echo -ne "\033]0;${@: -1}\007"
exec ssh $@
}
then . ~/.bashrc and test by running ssh web.domain.com:
while connecting: the tab name is changed to web.domain.com, as expected
when connected: it is overwritten with root@ip-5-6-7-8
Why? Is there something related to PS1 here?
UPDATE Fri Jun 6 21:58:04 ICT 2014
There is something quite strange going on: looks like this only happened with AWS instance. With other hosts, the tab name remain after logging in.
PS1 on the AWS instance:
# echo $PS1
[\u@\h \W]\$
PS1 on the other hosts:
~ echo $PS1
\[\]\[\][\[\]\t\[\]] \u\[\]@\[\]\h\[\]\[\]:\[\]\w\[\] \[\]
I also have tried to set the PS1 variable on the AWS to the value of working host but it didn't help.
|
That should be because upon logging into the remote shell session, that server's PS1 is sending you back the same \033]0;title\007 command sequence which makes your terminal program intercept and display accordingly. You really don't have any effect of editing your PS1 on local workstation.
I had a similar requirement and what I did is on the remote shell's bashrc, I put something like the following
PS1="\033]0;(tools)\007\015[\u@\h \W]# "
The tools is the designated name by which I wanted to identify the title. Effectively, the title shows it correctly in the terminal, and the command prompt is what I have normally.
| How to set the tab name to an alias hostname of the remote host I'm connected to? |
1,351,783,683,000 |
I'm running Ubuntu 14.04 and I've recently altered some hostname resolving configs. So I'm now trying to optimise them and for that I need to find out which nameservers resolve particular hostnames in my requests.
I can try to ping a hostname my.hostname.example.net to find out if it gets resolved at all or not, but how can I find out which nameserver resolved that particular hostname?
|
There are several commands that are useful to debug DNS resolution, and to show the path travelled to resolve DNS lookpups:
dnstracer
Install it with:
sudo apt-get install dnstracer
example of usage:
$ dnstracer www.cnn.com
Tracing to www.cnn.com[a] via 193.136.188.1, maximum of 3 retries
193.136.188.1 (193.136.188.1) Got answer [received type is cname]
|\___ ns1.fastly.net [fastly.net] (23.235.32.32)
|\___ ns4.fastly.net [fastly.net] (104.156.84.32)
|\___ ns3.fastly.net [fastly.net] (23.235.36.32)
\___ ns2.fastly.net [fastly.net] (104.156.80.32)
NAME
dnstracer - trace a chain of DNS servers to the source
DESCRIPTION
dnstracer determines where a given Domain Name Server (DNS) gets its
information from, and follows the chain of DNS servers back to the
servers which know the data.
debug mode of nslookup
Example:
$ nslookup
> set debug
> www.cnn.com
Server: 193.136.188.1
Address: 193.136.188.1#53
------------
QUESTIONS:
www.cnn.com, type = A, class = IN
ANSWERS:
-> www.cnn.com
canonical name = turner.map.fastly.net.
ttl = 191
-> turner.map.fastly.net
internet address = 151.101.36.73
ttl = 30
AUTHORITY RECORDS:
-> fastly.net
nameserver = ns2.fastly.net.
ttl = 13130
-> fastly.net
nameserver = ns3.fastly.net.
ttl = 13130
-> fastly.net
nameserver = ns4.fastly.net.
ttl = 13130
-> fastly.net
nameserver = ns1.fastly.net.
ttl = 13130
ADDITIONAL RECORDS:
-> ns1.fastly.net
internet address = 23.235.32.32
ttl = 13130
-> ns2.fastly.net
internet address = 104.156.80.32
ttl = 13130
-> ns3.fastly.net
internet address = 23.235.36.32
ttl = 13130
-> ns4.fastly.net
internet address = 104.156.84.32
ttl = 13130
------------
Non-authoritative answer:
www.cnn.com canonical name = turner.map.fastly.net.
Name: turner.map.fastly.net
Address: 151.101.36.73
dig - trace
Example:
$ dig +trace +recurse +all www.cnn.com. a
; <<>> DiG 9.8.3-P1 <<>> +trace +recurse +all www.cnn.com. a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37660
;; flags: qr ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 456885 IN NS j.root-servers.net.
. 456885 IN NS k.root-servers.net.
. 456885 IN NS l.root-servers.net.
. 456885 IN NS m.root-servers.net.
. 456885 IN NS a.root-servers.net.
. 456885 IN NS b.root-servers.net.
. 456885 IN NS c.root-servers.net.
. 456885 IN NS d.root-servers.net.
. 456885 IN NS e.root-servers.net.
. 456885 IN NS f.root-servers.net.
. 456885 IN NS g.root-servers.net.
. 456885 IN NS h.root-servers.net.
. 456885 IN NS i.root-servers.net.
;; ADDITIONAL SECTION:
a.root-servers.net. 543296 IN A 198.41.0.4
a.root-servers.net. 111296 IN AAAA 2001:503:ba3e::2:30
b.root-servers.net. 604618 IN A 192.228.79.201
b.root-servers.net. 111296 IN AAAA 2001:500:84::b
c.root-servers.net. 604618 IN A 192.33.4.12
c.root-servers.net. 111296 IN AAAA 2001:500:2::c
d.root-servers.net. 604618 IN A 199.7.91.13
d.root-servers.net. 111296 IN AAAA 2001:500:2d::d
e.root-servers.net. 604618 IN A 192.203.230.10
f.root-servers.net. 604618 IN A 192.5.5.241
f.root-servers.net. 111296 IN AAAA 2001:500:2f::f
g.root-servers.net. 604618 IN A 192.112.36.4
h.root-servers.net. 604618 IN A 198.97.190.53
;; Query time: 22 msec
;; SERVER: 10.19.90.11#53(10.19.90.11)
;; WHEN: Mon Dec 5 18:06:06 2016
;; MSG SIZE rcvd: 496
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16113
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 14
;; QUESTION SECTION:
;www.cnn.com. IN A
;; AUTHORITY SECTION:
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
;; ADDITIONAL SECTION:
a.gtld-servers.net. 172800 IN A 192.5.6.30
b.gtld-servers.net. 172800 IN A 192.33.14.30
c.gtld-servers.net. 172800 IN A 192.26.92.30
d.gtld-servers.net. 172800 IN A 192.31.80.30
e.gtld-servers.net. 172800 IN A 192.12.94.30
f.gtld-servers.net. 172800 IN A 192.35.51.30
g.gtld-servers.net. 172800 IN A 192.42.93.30
h.gtld-servers.net. 172800 IN A 192.54.112.30
i.gtld-servers.net. 172800 IN A 192.43.172.30
j.gtld-servers.net. 172800 IN A 192.48.79.30
k.gtld-servers.net. 172800 IN A 192.52.178.30
l.gtld-servers.net. 172800 IN A 192.41.162.30
m.gtld-servers.net. 172800 IN A 192.55.83.30
a.gtld-servers.net. 172800 IN AAAA 2001:503:a83e::2:30
;; Query time: 196 msec
;; SERVER: 192.112.36.4#53(192.112.36.4)
;; WHEN: Mon Dec 5 18:06:07 2016
;; MSG SIZE rcvd: 489
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44429
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 10, ADDITIONAL: 6
;; QUESTION SECTION:
;www.cnn.com. IN A
;; AUTHORITY SECTION:
cnn.com. 172800 IN NS pdns3.ultradns.org.
cnn.com. 172800 IN NS pdns4.ultradns.org.
cnn.com. 172800 IN NS pdns1.ultradns.net.
cnn.com. 172800 IN NS pdns2.ultradns.net.
cnn.com. 172800 IN NS pdns5.ultradns.info.
cnn.com. 172800 IN NS pdns6.ultradns.co.uk.
cnn.com. 172800 IN NS ns-47.awsdns-05.com.
cnn.com. 172800 IN NS ns-576.awsdns-08.net.
cnn.com. 172800 IN NS ns-1630.awsdns-11.co.uk.
cnn.com. 172800 IN NS ns-1086.awsdns-07.org.
;; ADDITIONAL SECTION:
pdns1.ultradns.net. 172800 IN AAAA 2001:502:f3ff::1
pdns1.ultradns.net. 172800 IN A 204.74.108.1
pdns2.ultradns.net. 172800 IN A 204.74.109.1
pdns2.ultradns.net. 172800 IN AAAA 2610:a1:1014::1
ns-47.awsdns-05.com. 172800 IN A 205.251.192.47
ns-576.awsdns-08.net. 172800 IN A 205.251.194.64
;; Query time: 58 msec
;; SERVER: 192.31.80.30#53(192.31.80.30)
;; WHEN: Mon Dec 5 18:06:07 2016
;; MSG SIZE rcvd: 445
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47226
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.cnn.com. IN A
;; ANSWER SECTION:
www.cnn.com. 300 IN CNAME turner.map.fastly.net.
;; Query time: 64 msec
;; SERVER: 204.74.114.1#53(204.74.114.1)
;; WHEN: Mon Dec 5 18:06:07 2016
;; MSG SIZE rcvd: 64
| How to find out nameserver which resolves a particular host name |
1,351,783,683,000 |
Currently I uses a big /etc/hosts to block unwanted hostnames. But the file is getting bigger and bigger closing in on 700000 entries. The are many similar entries so I would like to use wildcards like *.co.kr because I don't speak any Korean. Also hostnames that start with a digit or are longer than 64 characters are likely candiates I want to block.
AFAIK /etc/hosts does not provide that functionality. I think some kind of DNS deamon is required. Any ideas?
Edit: I chose the Korean tld just as a example. My /etc/hosts is getting bigger and bigger and harder to maintain. Most of the hostnames in there could be reduced to a small set of rules instead.
|
Name resolution is a pretty poor way of blocking undesired web traffic. The list of things to block and not to block keeps changing, and sometimes you need to block per URL and not just per host. Browser extensions such as AdBlock* and uBlock* tend to do a much better job. If you want to write your own list, you can write a PAC file.
If you really want to block requests based on domain names, do it with a DNS proxy, not with /etc/hosts. /etc/hosts can only do individual hosts. Dnsmasq is a popular, lightweight DNS proxy. Some distributions set up dnsmasq by default; most distributions have it as a package. To make a whole domain appear as localhost with dnsmasq, you can use the following line in /etc/dnsmasq.conf:
address=/co.kr/127.0.0.2
| How to block hostnames with wildcards or Regex? |
1,351,783,683,000 |
In linux, when my machine requests an IP address it also sends the hostname back to the DHCP server. How can I stop my machine from sending back this hostname?
I use dhclient, possibly via NetworkManager.
|
You can find host-name in dhcp client configuration to remove or add hostname.
For example:
Debian / Ubuntu Linux - /etc/dhcp3/dhclient.conf
$ sudo vi /etc/dhcp3/dhclient.conf
Set hostname as you need on the following line:
send host-name "yourhostname";
RHEL / Fedora / CentOS Linux - /etc/sysconfig/network-scripts/ifcfg-eth0 (for 1st DHCP network interface)
Open configuration file, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append hostname as you need on the following line :
DHCP_HOSTNAME=yourhostname
It is also possible for NetworkManager to send the hostname; see /etc/NetworkManager/NetworkManager.conf looking for:
[keyfile]
hostname=your_hostname
| Spoofing or removing DHCP client hostname in response to DHCP server |
1,337,608,929,000 |
I set a new hostname on my machine using:
sudo hostname NEWHOSTNAME
Then I restarted, and tried accessing the internet and nothing happened. I checked the hostname and it was set to localhost.localdomain.
How can I reset my configurations so that I am again connected to the web?
I'm running Red Hat Enterprise 6.0 (Santiago)
|
Your hostname should have nothing to do with being able to connect to the internet. That is unless the DHCP server on your network assigns IP addresses based on hostname (which if it does, it's a big mistake).
If the internet loss you mention is on a home network, consider restarting your local router. If it's a public or work network, unplug the cable/disable wireless, wait a few seconds and try plugging/enabling again.
If you still have problems, ask your local administrator.
If you are your local administrator, follow the steps here or ask for support.
| I changed my hostname, rebooted and lost internet connection |
1,337,608,929,000 |
I am setting up a RHEL-based server that is associated with dynamic DNS from DynDNS, with a domain of, say, "abc.dyndns.org" that is dynamically updated with the server's IP address.
I have read that in order to ensure access to your server's services, you need to have at least the following in your /etc/hosts:
127.0.0.1 localhost.localdomain localhost
xxx.xxx.xxx.xxx redhatbox.yourcompany.com redhatbox
Where "xxx.xxx.xxx.xxx" is whatever IP address your server has, and "redhatbox" would be the name of the computer. So here are my questions:
(1) Because my server has an IP that is dynamically assigned by my ISP's DHCP, there is no one IP I can put in place of xxx.xxx.xxx.xxx, what should I do in this case?
(2) Should I simply replace "redhatbox.yourcompany.com" with my DynDNS domain "abc.dyndns.org"? And replace the "redhatbox" alias with "abc"?
If anyone can explain all this for a novice like me that would be great. Thank you very much for your detailed answers and patience.
|
Some context:
When a program asks your machine to resolve a hostname into a IP address it looks into your /etc/hosts and, if not found, it then makes a DNS query.
You don't need to keep a non-loopback IP address on it. You can just usually keep the localhost entries and an alias.
See, that's my /etc/hosts contents:
[braga@coleman ~]$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 coleman.jazz coleman
::1 localhost6.localdomain6 localhost
coleman.jazz or coleman (named for the musician, Ornette Coleman) is just an alias for my machine.
Direct answers:
Just leave it out.
You can replace it wherever you want to. it's just an alias. You can even replace it with www.google.com (and www.google.com on your machine will point up to your own machine).
| Hosts file on server with dynamic DNS? |
1,337,608,929,000 |
I changed the host name and went to make it stick, but my previous solution didn't work. I am using Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/L. Is there a new way to do this (other than reboot)?
pi@raspberrypi:~ $ /etc/init.d/hostname.sh
-bash: /etc/init.d/hostname.sh: No such file or directory
pi@raspberrypi:~ $
|
hostname.sh has never been the right thing to use. Not only is it one of the van Smoorenburg rc scripts that systemd specifically masks on Debian, but running it was not the way to make a hostname persistent across reboots even with van Smoorenburg rc. It's the script that reads the persistent hostname.
The static hostname, from which the dynamic hostname is initialized during bootstrap, is stored in /etc/hostname on Debian Linux. You can edit that file directly, or use tools such as hostnamectl which use Desktop Bus, a client-server API, and a started-on-demand server program to … write that file for you. ☺
Further reading
Franklin Piat, Christopher Soellinger, Matthias Weiler et al. (2017). How To Change Hostname. Debian wiki.
| Is /etc/init.d/hostname.sh still an option for debian stretch? |
1,337,608,929,000 |
Is it possible to make ssh pick a random IP address (using a wildcard) to connect? We have 30 computers with IP addresses from "asd1.asd.asd.asd.com" to "asd30.asd.asd.asd.com", and i want to connect to one of them (randomly selected) using the alias xxxx. Is there a simple way to do this using the ~/.ssh/config file?
I've tried to use this wildcard:
Host xxxx
Hostname asd[0-30].asd.asd.asd.com
User my_username
But it doesn't work. Any ideas? Is it even possible?
|
If you really had to, you could do something like this:
Host xxxx
User my_username
ProxyCommand nc asd$((1+$((RANDOM %% 30)))).asd.asd.asd.com 22
This assumes you're using the bash shell -- otherwise you can put the proxy command as the argument for a bash invocation, e.g.
ProxyCommand /bin/bash -c "exec nc asd$((1+$((RANDOM %% 30)))).asd.asd.asd.com 22"
| How to randomly pick one of multiple hostnames under one alias (~/.ssh/config) |
1,337,608,929,000 |
From a user that is part of the sudoers group, I can normally run any command by doing sudo <command>
But the following command fails stating "Permission denied"
sudo echo "myhostname" > /etc/hostname
It doesn't even ask me for the password. How do I change the hostname ?
|
The correct command in your case will be echo "newhostname" | sudo tee /etc/hostname, because as nssnd explained, sudo applies only to single command, and redirection has less priority than sudo. Another option is to use bash command:
sudo bash -c "echo newhostname > /etc/hostname"
| Why can't I change the hostname of my server using sudo? [duplicate] |
1,337,608,929,000 |
Content of hostname file in my server is:
# cat /etc/hostname
sub.mysite.com
But when I ping my CentOS 7 server it says:
# ping sub.mysite.com
64 bytes from sub ...
Even:
# ping ns1.mysite.com
64 bytes from sub ...
How can I tell my server to have the following output when pinging?
64 bytes from sub.mysite.com ...
UPDATE
For example on my client:
user@host:~$ ping ns1.mysite.com
PING ns1.mysite.com (x.x.x.x) 56(84) bytes of data.
64 bytes from sub (x.x.x.x): icmp_seq=1 ttl=56 time=7.88 ms
64 bytes from sub (x.x.x.x): icmp_seq=2 ttl=56 time=5.86 ms
64 bytes from sub (x.x.x.x): icmp_seq=3 ttl=56 time=4.99 ms
64 bytes from sub (x.x.x.x): icmp_seq=4 ttl=56 time=4.88 ms
I want to have full hostname (sub.mysite.com) rather than sub.
|
ping doesn't use /etc/hostname to resolve IP to name mappings, it uses the Name Service (netns) to do these translations. Incidentally, /etc/hostname is part of systemd:
$ rpm -qf /etc/hostname
systemd-219-42.el7_4.10.x86_64
That short name you're seeing, sub, is coming from your /etc/hosts file via the Name Service. If you use strace you can see how ping is finding sub:
$ strace -s 2000 ping -c1 www.google.com |& grep /etc/host
open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 4
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 4
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 4
So the easy way to solve your problem is to put the name of your server as you want ping to display it in your /etc/hosts file.
Example
$ ping -c1 www.google.com
PING www.google.com (74.125.141.99) 56(84) bytes of data.
64 bytes from vl-in-f99.1e100.net (74.125.141.99): icmp_seq=1 ttl=63 time=109 ms
--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 109.903/109.903/109.903/0.000 ms
Now if we were to add that IP, 74.125.141.103, to your `/etc/hosts` file we could manipulate `ping` into showing whatever we want for it:
Add this to /etc/hosts:
74.125.141.99 blah.blah.com
Now repeat our test:
$ ping -c1 www.google.com
PING www.google.com (74.125.141.99) 56(84) bytes of data.
64 bytes from blah.blah.com (74.125.141.99): icmp_seq=1 ttl=63 time=109 ms
--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 109.886/109.886/109.886/0.000 ms
Order of /etc/hosts
Keep in mind that the order the hosts are added to /etc/hosts can cause the names to show up as you were seeing.
For example if we had this in our /etc/hosts:
74.125.141.99 blah blah.blah.com
The ping would show up as you were seeing, with a short name:
$ ping -c1 www.google.com
PING www.google.com (74.125.141.99) 56(84) bytes of data.
64 bytes from blah (74.125.141.99): icmp_seq=1 ttl=63 time=108 ms
--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 108.065/108.065/108.065/0.000 ms
References
/etc/resolv.conf order not respected by ping
| How to change `ping from` value when pinging Linux server? |
1,337,608,929,000 |
I get entries like these in /var/log/cron, in a host named SERV2 (RHEL 6.2):
Apr 21 14:50:01 SERV1 CROND[14799]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Apr 21 15:20:01 serv2 CROND[24438]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Apr 21 15:00:01 SERV1 CROND[14838]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Entries with SERV1 seem to be coming from other host, but AFAIK cron doesn't work in a distributed way, just as a local service. How can those entries end up here?
More info:
# hostname
SERV2
# cat /etc/hosts
10.22.1.70 serv2
10.22.1.27 serv1
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
The syslog format typically contains a timestamp, hostname, app name, and process ID along with whatever custom message was sent. All of these values are (substantially) under the control of the process that sends the syslog message. The cronie source (if configured to use syslog) uses the openlog and syslog functions to write to syslog.
Seeing that the reported messages looked like syslog format, and that the hostnames were different between the messages, and that all of the (mentioned) logs were from the CROND "app name", it seemed plausible that SERV2's syslog was configured to write all "cron" facility logs that it receives to the /var/log/cron file. This would include "remote" logs from other systems that were configured to send their syslogs to SERV2 (and assuming that SERV2 is listening for those remote logs).
This theory was confirmed in the comments when the OP found that serv1 had a wildcard syslog entry that pointed every syslog at (presumably the IP of) SERV2.
| Separate server's hostname appearing in this server's cron logs |
1,337,608,929,000 |
I recently created a droplet server at Digital Ocean named:
ubuntu-2gb-nyc3-01-2016-03-13
and then did a rename on the server at the Digital Ocean control panel, to exchange.mydomain.com.
Furthermore, I did the following command:
sudo echo "exchange.mydomain.com" > /etc/hostname
And verified it changed by doing nano /etc/hostname
However, when I type in hostname at the command prompt, the value is not reflecting the update. What is the problem and how do I fix this?
|
Distros which use systemd use hostnamectl to set their hostname:
$ sudo hostnamectl set-hostname exchange.mydomain.com
You'll have to log off and back in again to see the change in your shell prompt, but the hostname command will show the change as soon as you've ran the command.
Usage
$ sudo hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
-h --help Show this help
--version Show package version
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--transient Only set transient hostname
--static Only set static hostname
--pretty Only set pretty hostname
Commands:
status Show current hostname settings
set-hostname NAME Set system hostname
set-icon-name NAME Set icon name for host
set-chassis NAME Set chassis type for host
set-deployment NAME Set deployment environment for host
set-location NAME Set location for host
| Unable to update hostname output for Ubuntu Server (on Digital Ocean) |
1,337,608,929,000 |
We have a server with a CentOS distribution of Linux. It lost its hostname in the month somehow, since our last reboot. We ran an ETL (extract, transform, load) job last week, and part of that process stops JBoss before moving data to our database, and then restarts JBoss after that automatically. The restart failed.
I solved (with a hack) using this method:
https://stackoverflow.com/questions/6484275/what-causes-the-error-java-net-unknownhostexception/34094741#34094741
We didn't make any changes to the server in the last month (to any files), so I know /etc/hosts wouldn't have changed. I added that extra line (in the answer above), in the /etc/hosts file so JBoss could start.
Two questions:
How does the "hostname -f" command retrieve the hostname from the DNS, per this question? What is it checking on our DNS? Is there a term I should be using to communicate with our server team?
Where does `hostname` store the hostname that I've set?
How do most server administrators handle this, or avoid what happened to me? Do they always set something in the /etc/hosts file to avoid changes to the DNS?
Basically I'm trying to figure out what changed on our network (or DNS) which caused our hostname to go missing. See, the command prompt shows the hostname on the server when I log in. It's strange that I see it there, but not when I call "hostname -f". See "lvs-xyz" below.
[root@lvs-xyz ~]# hostname -f
hostname: Unknown host
If you can't answer all of my questions, I'm mainly looking for what the "norm" is to avoid losing a hostname for the administration of Linux. If I put it into /etc/hosts, then it seems like a hack because the command prompt could change if the kernal value changes, and then it would be different from /etc/hosts if that were to happen.
EDIT:
[root@lvs-xyz sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NETWORK=144.92.154.0
IPADDR=144.92.154.48
NETMASK=255.255.255.192
|
You can specify it (loaded on reboot anyway) in /etc/sysconfig/network with a HOSTNAME= line (see the documentation here)
You should specify it as a fully qualified name there generally.
If the host doesn't have a name already, and you're using DHCP it will often pick its name up that way.
| What is the best way to keep a Linux server's hostname consistent? |
1,337,608,929,000 |
Our accounts in our lab are all mounted over NFS and are accessible over all the systems in a subnet. So, effectively we can ssh into any of the machines in the subnet and continue our work. The problem is that the machines come up or go down randomly because of people accidently turning it off etc. To find running machines I scan the subnet using nmap and choose a machine.
Because of the above problem, I can't put a fixed entry for Hostname in my ssh config entry. So, how can I have an ssh config entry that will have all other parameters except Hostname such that the ssh config entry and the Hostname can somehow be given together while running ssh?
|
The Host directive can take multiple hosts, for example:
Host *.domain.tld specific-host.tld 10.*.*.*
User foo
Port 2222
This would set user and port for all hosts matching the star pattern,
the explicit host specific-host.tld, or, assuming you type IP
numbers, any host whose first IPv4 byte is 10. Then you can add Host
/ HostName pairs to give nicknames to specific hosts, for example.
| Use a dynamically obtained hostname with an ssh config entry |
1,337,608,929,000 |
Give the example here which has an attempt at setting the hostname to foo.bar.baz for the duration of the build,
#!/bin/bash
ctr=$(buildah from alpine:3)
buildah run --hostname 'foo.bar.baz' $ctr /bin/sh <<-'EOF'
echo "/usr/bin/hostname returns [$(hostname)]";
EOF
I get the following output,
/usr/bin/hostname returns [myHostname]
I was expecting hostname to return foo.bar.baz.
I'm using Debian Testing's buildah package 1.15.2-1.
❯ buildah version
Version: 1.15.2
Go Version: go1.14.7
Image Spec: 1.0.1
Runtime Spec: 1.0.2-dev
CNI Spec: 0.4.0
libcni Version:
image Version: 5.5.2
Git Commit:
Built: Wed Dec 31 18:00:00 1969
OS/Arch: linux/amd64
But I've also tested it on 1.17,
❯ buildah version
Version: 1.17.0
Go Version: go1.15.2
Image Spec: 1.0.1-dev
Runtime Spec: 1.0.2-dev
CNI Spec: 0.4.0
libcni Version:
image Version: 5.7.0
Git Commit:
Built: Wed Dec 31 18:00:00 1969
OS/Arch: linux/amd64
|
I filed this as a bug on GitHub (#2775).
It seems it's hardwired but not documented, from irc.freenode.net/#podman
nalind> buildah run is hardwired to disable UTS namespace in rootless mode, don't remember why
...
nalind> EvanCarroll: unless it's a limitation we put in place for the sake of runc or crun, not being able to use a private UTS namespace in buildah run a fixable bug
| How does --hostname work with `buildah run`? |
1,337,608,929,000 |
Is there a way I can massage my ~/.zshrc to make the ssh auto-completion autocomplete for the Host, not the Hostname?
I have an entry in my ~/.ssh/config that looks like this:
Host staging-rfc staging
User crmpicco
Hostname staging.rfc.crmpicco.co.uk
If I type ssh sta[TAB] then it pre-fills the full hostname of staging.rfc.crmpicco.co.uk, which gives me a permission denied error - presumably because it's trying to login with my terminal user and not "crmpicco".
[email protected]: Permission denied (publickey).
My ~/.zshrc:
# Highlight the current autocomplete option
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Better SSH/Rsync/SCP Autocomplete
zstyle ':completion:*:(scp|rsync):*' tag-order ' hosts:-ipaddr:ip\ address hosts:-host:host files'
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*'
# Allow for autocomplete to be case insensitive
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' \
'+l:|?=** r:|?=**'
# Initialize the autocompletion
autoload -Uz compinit && compinit -i
|
Changing my zstyle to the following worked perfectly:
zstyle ':completion:*:(ssh|scp|ftp|sftp):*' hosts $hosts
zstyle ':completion:*:(ssh|scp|ftp|sftp):*' users $users
| zsh ssh autocomplete Host instead of Hostname from ~/.ssh/hosts |
1,337,608,929,000 |
Say I'm on machine local and log into machine remote with ssh, using X11 forwarding. Is there any way for programs running within the ssh session on remote can know they are being displayed on local? Ideally, I'd like to know the hostname of the computer that the X server is running on. My goal is to cause different behavior in a program (emacs) based on which machine it's displayed on.
|
I don't think the X server reports its host name to clients. The clients are supposed to know the host name that they're connecting to, but over an SSH connection, that's localhost, with ssh doing the forwarding.
The OpenSSH server sets the SSH_CLIENT environment variable; you can read the client's IP address from there. That's the address as seen by the server, so you can't distinguish machines behind the same NAT. This is the address of the X server, provided that nothing else is going on (SSH forwarding, remote X server on the client, …). Note that you'll only get the environment variable in Emacs if it was started from within that SSH connection, not if you created a frame in a running Emacs with emacsclient.
You can get at some properties of the display (dimensions, color depth, X vendor, …) in Emacs with the functions x-server-XXX, x-display-XXX and display-XXX.
| How to find the hostname of an X server |
1,337,608,929,000 |
I have an Ubuntu 11.04 server virtual machine. I would like to request a specific hostname from the DHCP server at the office. Since I don't run it often, the IP changes nearly every time that I boot it. Obviously, referencing it by a hostname is the preferred option.
I know that my DHCP server respects DHCP client hostname requests. On my windows 7 machine, I can rename the computer, reboot, query the DHCP server, and see the new name in the ANSWER SECTION. The query command that I use is:
dig @192.168.225.5 -x 192.168.235.XXX
and each time it will respond with the new computer hostname. I can also now ping and ssh from other machines using that new hostname.
I have no such luck on the Ubuntu VM. I modified /etc/dhcp/dhclient.conf to include a line:
send host-name "MYRQUESTEDHOSTNAME";
and then run
sudo /etc/init.d/networking restart
but querying with dig using the VM's IP address yields no ANSWER SECTION.
What am I missing?
|
I found a solution that works for my network, but your mileage may vary. I'm not sure why it does not happen automatically. Anyway, here's the simple shell script that should update the right nameserver on the right network interface with the right IP (will work for VPN connections, too) and should work on OSX/BSD & Linux.
#!/bin/bash
# the host information to send
DOMAIN=$(awk '/^search/ {print $2}' /etc/resolv.conf | head -1)
HOST=$(hostname -s)
# nameserver to update
NAMESERVER=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -1)
# linux version to find interace that routes to nameserver
if [[ -e /sbin/ip ]]; then
INTERFACE=$(ip -o route get ${NAMESERVER} | awk '{print $5}')
else # osx / bsd version
INTERFACE=$(route get ${NAMESERVER} | awk '/interface/ {print $2}')
fi
# ip of the interface
IP=$(ifconfig ${INTERFACE} | perl -ne 'print "$1" if /inet.*?(\d+\.\d+\.\d+\.\d+)/')
nsupdate -d <(
echo server ${NAMESERVER} 53
echo update add ${HOST}.${DOMAIN} 86400 A ${IP}
echo show
echo send
)
| How to request a hostname from a DHCP server on Ubuntu? |
1,337,608,929,000 |
I have two computers in the same network with below hostnames and IP address(Dynamic IPs):
host1.local - 10.0.0.11
host2.local - 10.0.0.12
host1 is running Docker with default configuration.
Containers in host1 are able to connect to host2 using the IP address 10.0.0.12 but are unable to connect to the host2 using the hostname host2.local. Can anyone please let me know how can the containers directly connect to the hosts2 using hostnames. Please note that both the servers host1, host2 are in DHCP server and don't have fixed ip address so configuring the file /etc/hosts doesn't work in my case.
|
Docker containers usually are in the default bridge network:
When you start Docker, a default bridge network (also called bridge) is created automatically, and newly-started containers connect to it unless otherwise specified.
You can also have user-defined bridges with their own DNS service:
User-defined bridges provide automatic DNS resolution between containers.
On a user-defined bridge network, containers can resolve each other by name or alias.
There are additional options to configure DNS resolution in a container (see here):
By default, a container inherits the DNS settings of the host, as defined in the /etc/resolv.conf configuration file. Containers that use the default bridge network get a copy of this file, whereas containers that use a custom network use Docker’s embedded DNS server, which forwards external DNS lookups to the DNS servers configured on the host.
Custom hosts defined in /etc/hosts are not inherited. To pass additional hosts into your container, refer to "add entries to container hosts file" in the docker run reference documentation. You can override these settings on a per-container basis.
And add entries to container hosts file says:
You can add other hosts into a container’s /etc/hosts file by using one or more --add-host flags. This example adds a static address for a host named docker:
$ docker run --add-host=docker:93.184.216.34 --rm -it alpine
You can of course also configure the upstream DNS server to properly resolve *.local. If you use mDNS for that, the upstream DNS server must be able to use it.
| How can docker communicate to other hosts in local network using hostnames? |
1,337,608,929,000 |
How do I rename the RedHat7 hostname without a reboot? I am also trying to automate this task.
|
[root@stephan ~]# echo stephan2 > /etc/hostname # this is the file that your system reads on boot, to determine the hostname
[root@stephan ~]# sed -i s/stephan/stephan2/g /etc/hosts # many networking headaches will ensue if this isn't updated
[root@stephan ~]# hostname -F /etc/hostname # reread the hostname file to update the systems hostname.
Your prompt will continue to display the old hostname until you log out of it and back in, or execute a new shell session.
[root@stephan ~]# logout
[stephan@stephan ~]$ sudo su -
Last login: Wed Sep 28 18:06:35 EDT 2016 on pts/0
[root@stephan2 ~]#
| Rename RedHat7 hostname without reboot |
1,337,608,929,000 |
I tried to change my hostname according to this guide for Debian based system:
I edited /etc/hostname
I ran /etc/init.d/hostname start
Though there are errors. Always when I write a sudo command it tells me it can't recognize the hostname. After I restarted the system, the graphical environment wasn't working, the startx command wasn't successful. So, I changed the hostname back to the old name.
Can I change the hostname without errors?
|
The problem is that your new hostname can't be resolved to an ip address. There are basically two solutions for your problem.
First one but little bit more complex solution is to adjust the hostname in /etc/hosts as well. You will have to adjust /etc/hosts every time you change your hostname.
The second and simpler solution is to install nss-myhostname. The debian package name is libnss-myhostname so just install it with apt-get install libnss-myhostname. This will allow you to always resolve your current hostname.
| Changing hostname without errors |
1,337,608,929,000 |
The zshmisc man page on my new Debian Squeeze install states, under SIMPLE PROMPT ESCAPES:
%m
The hostname up to the first `.'. An integer may follow the '%' to specify how
many components of the hostname are desired. With a negative integer, trailing
components of the hostname are shown.
When I include %2m in my prompt, I see differing behaviour between OSX and Linux.
On OSX (10.7.3), running zsh 4.3.11, the prompt behaves as expected, showing the two leading components of the system hostname.
On Debian, running zsh 4.3.10, the prompt still only shows the bare hostname. hostname -f on this system confirms that the full hostname is set correctly. Note also that the manpage for this zsh release says that %2m should be supported.
Does anyone have any suggestions as to where to start debugging this?
|
A quick look at zsh's prompt handling source code suggests that %m is based on what your system returns for the gethostname system call. That's like running hostname without the -f option.
I'm assuming running hostname without -f returns your bare hostname on your Debian system?
You could try changing your hostname to include the domain name. The Debian HowTo/ChangeHostname docs should help with that. But maybe some Debian tools assume your hostname does not include the domain name, so that might be a bad idea.
It might make more sense to just use command substitution.
First set the PROMPT_SUBST option
setopt PROMPT_SUBST
then you can run any command and put its output in the prompt like this:
PS1='$(hostname -f)$ '
to get only the first however many parts of the hostname, you could use cut, e.g.
PS1='$(hostname -f | cut -f 1-2 -d .)$ '
Because your hostname shouldn't change, you could also be a little more efficient by running the command just once and storing it in a variable, then using the variable, e.g.
HOSTANDSUBDOMAIN="$(hostname -f | cut -f 1-2 -d .)"
PS1="$HOSTANDSUBDOMAIN$ "
| ZSH %m prompt escape not working as documented under Debian Linux |
1,337,608,929,000 |
Is it possible to configure where the system will look for the machine if I enter just a short domain name hostname?
I work in a grid environment where the machines are many and spread across multiple domains, but they have unique naming, therefore let say skirit23 will only be found as skirit23.ics.muni.cz
I could configure the full mappings, but that would be a big file (and constantly changing one). Therefore I was thinking if I could configure the system to look into the ics.muni.cz then try ncbr.muni.cz then try fav.zcu.cz etc...
|
This is usually done by specifying search in /etc/resolv.conf (see man 5 resolv.conf).
Example (no more than six domains possible):
search ics.muni.cz ncbr.muni.cz fav.zcu.cz
| Hostname to fully qualified doman name expansion |
1,337,608,929,000 |
poking docker to see how it works:
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker run --net=host -d -t jmar71n/freepbx
2792243260a8de33d1a775d115188e601fc556e500b5ad085e09b4133d0f3d06
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
root@46f45b8973c3:/#
root@46f45b8973c3:/# exit
exit
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker run -it jmar71n/freepbx bash
root@813557bf8922:/#
root@813557bf8922:/# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
root@813557bf8922:/#
Now, is each run a new instance? Is that why the prompt changes? The hostname is a unique ID for each run?
How would I login to the first instance, with --net=host?
When I try the exec flag, it fails:
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker exec -it jmar71n/freepbx bash
Error: No such container: jmar71n/freepbx
ubuntu@ip-172-31-14-19:~$
Why? What's the correct way to login to that instance?
ubuntu@ip-172-31-14-19:~$
ubuntu@ip-172-31-14-19:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 20c44cd7596f 2 days ago 123MB
hello-world latest 725dcfab7d63 2 weeks ago 1.84kB
jmar71n/freepbx latest 8dda2a58fde1 19 months ago 1.54GB
ubuntu@ip-172-31-14-19:~$
|
Docker run, creates a new instance (para virtualised) environment from a given image.
To log in to a given instance, you need to run docker exec but you need to execute docker exec with the id of the container you are looking to log into. This can be attained from the command:
docker ps -a
Then with the id attained, log into the container with:
docker exec -it <containerid> bash
| How can I log into a running docker instance? |
1,337,608,929,000 |
For example.
[root@ip-10-0-7-225 ~]#
I edited /etc/hosts but it didn't work.
|
As noted, the problem is the hostname. CentOS (unlike Debian) may get that information from
/etc/sysconfig/network
e.g., a line like
HOSTNAME=myhostname.mydomainname
Further reading: 28.1.21. /etc/sysconfig/network
| How to change the part after root@ |
1,337,608,929,000 |
I currently have a few cloud instances and each of them has it's own URL (such as example.com) that is pointed at it through my registrar.
However, I am curious what, if any changes I should make to their hostname (using the hostname) command to configure them properly.
Just for fun, I have given them totally random names, through either the hostname command or by editing /etc/hostname.
The thing is, I just don't know what this is used for?
Can anyone clarify how the hostname set on the server relates to the URL / domain name I am pointing at it (if it does at all)
and for what, exactly, the hostname of a server is used?
|
[...] own URL (such as example.com) that is pointed at it through my registrar.
That's not what a (domain) registrar does. A domain registrar just acts as your proxy for registering your domain, its contact information, and its delegated DNS servers in the domain registry. After that, it's up to the DNS servers what the names under that domain point to.
You may be using a service provider that supplies both registrar services and DNS services, but it's important to distinguish the functions.
The thing is, I just don't know what this is used for?
This is used so you can tell them apart. That's why we give names to things in general.
Can anyone clarify how the hostname set on the server relates to the URL / domain name I am pointing at it (if it does at all)
Depending on your web server, the system hostname may be used as the default value of the ServerName (or equivalent), that is, the server's own idea of its host name. That information may be revealed in such things as HTTP redirects automatically generated by the web server.
for what, exactly, the hostname of a server is used
Many things, really: it may go in default shell prompts (so you can see what machine you're connected to), in log files, DNS PTR records, and so on.
| Why do I even need to set my hostname or my domain name? |
1,337,608,929,000 |
I'm testing a VPS provider, and recently created a virtual machine with a hostname testserver using an ubuntu template. This VPS provider reserves and bills resources by the month, so if you create a VM for a small job, it's sensible to keep it around in case you need another VM for some other job later.
I came back to VM after a couple of weeks for another job, and wanted to rename the hostname to webserver. I edited /etc/hostname and rebooted, and the OS recognises that the hostname is now webserver. According to the VPS vendor, it's apparently impossible to change the hostname of the VM in the hypervisor resource group (read they haven't created a controller view and form template to do so), so I'm stuck with it being called testserver there. sudo works, but when I sudo I get a warning:
sudo: unable to resolve host webserver
Anyone know why? This is obviously just a minor inconvenience, but I thought I would ask in case anyone knows of a solution.
|
sudo uses the system resolver, configured by /etc/nsswitch.conf; in your case, host lookups were configured to use /etc/hosts, which had the previous hostname identified with the server's IP. To fix it, simply update /etc/hosts with the new hostname.
| sudo: unable to resolve host "hostname" |
1,337,608,929,000 |
Why is bash shell sometimes saying I'm at @localhost while other times it says I'm at @computer-5?
|
Some DHCP servers (and clients) are configured to assign a hostname just like an IP address. In these cases the computer's hostname does in fact change to e. g. computer-5 (until it gets a lease assigning a different name, or the lease is relinquished). localhost will still work for the loopback interface, but the DHCP-assigned hostname will (or should) resolve to the DHCP-assigned address specifically.
| Am I @localhost or @computer-5? |
1,337,608,929,000 |
I am developing a web page using Apache Web Server in my pc. When I want to open it in the browser I use the ip, for example:
http://192.168.1.6/proyect
My host is part of a local network (a laptop and mobile device). In both of them, I can open up the website using the url mentioned above. I would like to know if it is possible to use a "domain" instead an IP in the URL? For example, http://dev-pc/proyect.
My first attempt was to know whether a name exists:
$ hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-desktop
Chassis: desktop
Machine ID: d388b100e4b34a17a685369e53045669
Boot ID: ee82c1e45d35433785b57040944928f3
Operating System: Fedora 20 (Heisenbug)
CPE OS Name: cpe:/o:fedoraproject:fedora:20
Kernel: Linux 3.19.8-100.fc20.x86_64
Architecture: x86_64
Then, I test it accesing this URL:
http://localhost.localdomain/proyect
And it works, but in other devices the page is not found. Looks like localhost.localdomain is just recognized by my pc. Thank you in advance.
|
To define a domain for more than just your own computer in one place, you must have some authoritative domain controller. On a home network, the thing providing the local and first-line of DNS (domain names) info is your router.
Any device on your home network is a member of the domain being defined by the router (because they are on the network, so they are a member of that network's domain). This means that your mobile devices must be using your wifi, not a cell connection.
You should be able to access your computer by its hostname.
If your dev computer does not have a hostname, define one for it with hostname or hostnamectl (depending on your flavour of unix):
$ sudo hostname devbox
or..
$ sudo hostnamectl set-hostname --static "devbox"
And now any device on the same network (inheriting that network's domain) should be able to ping your dev site by hostname:
$ ping devbox
64 bytes from laptop (10.1.1.13): ttl=64 time=32.9 ms
| Setting a domain name in LAN |
1,337,608,929,000 |
The problem is that I fail to SSH to a remote machine via its hostname, while using its IP works.
The hostname returned by command hostname is: california_desert
while the name returned by command nslookup $IP_address is: pcpp3238782. They did not match each other.
I think that's why I cannot connect to remote machine using its hostname.
I have checked /etc/hosts, /etc/hostname, /etc/sysconfig/network: all set the hostname to california_desert.
Checked with /etc/resolve.conf, the name server is set to the right one.
Also tried strace but no new clue.
Anybody can please help?
|
The problem here is that the hostname and hosts files are only used for the computer they're on. In order for other computers to be able to use the hostname, it needs to be in the DNS zone for the domain.
Think of it like this - you get a phone, and it has a phone number 555-5555. You now know that to call California_desert, you need to dial 555-5555. But nobody else knows this. In order for others to know how to reach you, you need to register your phone number in the directory. DNS is that directory service.
Of course, you can also tell a friend that your number is 555-5555 and then they can call you directly without looking it up in the directory. For a unix system, this would be like adding the hostname and ip for California_desert to the hosts file on every server that wants to connect to it.
| Fail to ssh to remote machine via hostname |
1,337,608,929,000 |
1. Starting a shell process under a separate child UTS namespace
sudo unshare -f --mount-proc -u /bin/bash
2. Change the hostname in this process
hostnamectl set-hostname newhostname
3. Monitor the change from a different shell
$ hostname
newhostname
Expected Result
The process in the parent namespace to preserve its old hostname.
Result Got
Changing the hostname in the new UTS namespace also changed the hostname in the parent namespace.
Why is this happening? I'm using Ubuntu 20.04, kernel version 5.10.23-xanmod1 (uname -r).
|
hostnamectl comes along the systemd environment and it doesn't execute the sethostname(2) system call. It asks systemd to do it, through the /run/dbus/system_bus_socket socket. As systemd didn't change namespace, it performs this in the initial namespace, changing the name of the old UTS namespace (the initial where it's running) to the new name provided and leaving the new UTS namespace with an unchanged name (contrary to OP's claim): the old hostname. There will be other side effects, like the file /etc/hostname being changed.
This can be checked using strace. There's no sethostname(2) inside, but there are visible systemd-related elements:
newfstatat(AT_FDCWD, "/run/systemd/system/", {st_mode=S_IFDIR|0755, st_size=40, ...}, AT_SYMLINK_NOFOLLOW) = 0
If one prevents the call above to succeed (by using unshare -f -u -m /bin/bash and then covering inside it all of /run with a mount -t tmpfs tmpfs /run), one gets:
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
The dialog is later done through the socket opened like this:
connect(3, {sa_family=AF_UNIX, sun_path="/run/dbus/system_bus_socket"}, 30) = 0
In such environment one should use the low level "legacy" command hostname which is used for reading or changing the hostname. It does invoke directly the sethostname(2) system call: it will change the new UTS namespace's name and leave the old (initial) UTS namespace unchanged:
hostname newhostname
For hostnamectl to affect the new UTS namespace (like with a full container started with LXC), this requires more than an unshare command: a whole new instance of a systemd eco-system must be present in the new environment, probably requiring several other namespaces to be entered/unshared and a lot of additional boilerplate.
| Why is the UTS namespace isolation not working? |
1,609,942,831,000 |
Background
I am creating several VirtualBox instances to use as Web development environments (Arch host/Debian guests), and I want them to share most files but have an additional drive for each machine, mounted at /mnt. This is more memory-efficient than simply cloning the entire disk, and allows me to install tools across systems without the need to reinstall on other projects that use the same programs, files, etc. I am aware of the limitation that two machines won't be able to work at the same time, but I don't switch contexts very often so it's a non-issue for me.
On each machine, for example, the /etc/hostname and /etc/hosts files are replaced with symlinks pointing to respective files on the individual drive, mounted at /mnt with some other useful directories that are specific to each project. This allows me to swap out drives for different projects while using the same, basic filesystem.
localhost ~ > ls -la /mnt/etc/host*
-rw-r--r-- 1 root root 16 Dec 10 08:04 /mnt/etc/hostname
-rw-r--r-- 1 root root 128 Jan 6 07:20 /mnt/etc/hosts
localhost ~ > ls -la /etc/host*
-rw-r--r-- 1 root root 9 Aug 7 2006 /etc/host.conf
lrwxrwxrwx 1 root root 17 Jan 5 22:36 /etc/hostname -> /mnt/etc/hostname
lrwxrwxrwx 1 root root 14 Jan 5 22:34 /etc/hosts -> /mnt/etc/hosts
-rw-r--r-- 1 root root 411 Dec 9 21:25 /etc/hosts.allow
-rw-r--r-- 1 root root 711 Dec 9 21:25 /etc/hosts.deny
Issue and Code
However, I see that my shell prompt doesn't respect the values in hostname or hosts, instead defaulting to localhost. These files need to contain different hostname values for each VM, or I'll easily lose track of which machine I'm working in. Here are the files:
/mnt/etc/hosts
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.1.1 mc-development.localdomain mc-development
127.0.0.1 localhost
/mnt/etc/hostname
mc-development
Edit 1
Here's the output of hostnamectl:
localhost ~ > hostnamectl
Static hostname: mc-development
Transient hostname: localhost
Icon name: computer-vm
Chassis: vm
Machine ID: …
Boot ID: …
Virtualization: oracle
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-13-amd64
Architecture: x86-64
I thought that maybe the way I was symlinking to a different drive was the cause of the hostname definition issue, but according to this output, it is reading the files just fine. So it would appear that Fish is honoring the transient hostname when I want it to display the static hostname.
Any ideas of how to do this? What are the key differences between the two hostname types?
By the way, this shows up in Bash, too.
localhost ~ > bash
matt@localhost:~$
What I've Tried
I thought that maybe the order in which the drives were being mounted might make a difference because if the OS reads a link to a file that hasn't been loaded yet, it could cause an issue like this. However, changing the order of fstab entries did not help.
Edit 2
As mentioned in a comment on Ljm Dullaart's answer, copying the /usr directory didn't seem to work. My Debian box complains at boot that it is missing programs from /bin and /sbin, including /bin/init.
Here are the steps I took:
1. Boot to a live image and mount the drives, shared inside guest.
# mount /dev/sda1 /mnt
# mount /dev/sdb1 /mnt/mnt
2. Move the entire usr directory to the shared drive.
# mv /mnt/usr /mnt/mnt
3. Create the symlink.
# ln -s /mnt/mnt/usr /mnt/usr
4. Boot, and…
|
No, it is not recommended.
In general, you would have a number of filesystems that can be shared (some even read-only), but the root filesystem is not one of them. The system boot process uses this filesystem.
In your case, I would share /usr an possibly /opt. You would keep separate per machine on the rootfs (sizes are on my machine; just to give you an impression of the memory use):
15M bin
94M boot
34M etc
778M lib
28M lib64
You will probably keep separate per machine
4.9G var
That is because logs are kept here. You should not want to mix the logging of your instances that way.
You will still be sharing
22G usr
4.7G opt
426G home
As per EDIT 2_
This linking that you do will not work. You let /usr on /dev/sda1 point to /mnt/mnt/usr. Not to /usr on sdb1, but to /mnt/mnt/usr.
However, you did something more; /sbin must still be on the rootfs. The fact that it isn't there is just wrong.
What you will need to do is to re-install both machines (sorry), with exactly the same installation media and the same options.
Machine 1:
When the partition-editor appears, select a partition as follows:
/dev/sda1 : root filesystem (/)
/dev/sdb1 : /usr
/dev/sdb2 : /home
/dev/sdb3 : /opt
Then, install the lot.
When machine 1 is up and running, shut it down.
Next, for machine 2: exactly the same. Make sure that sda is it's own disk and that sdb is the shared disk.
Note that upgrade and updates will be a PITA, but as this is a virtual environment, you may choose to re-install from time to time.
____ Yet another edit _____
Because debian uses systemd, the described method is no longer possible. See https://fedoraproject.org/wiki/Features/UsrMove for an explanation why. (Fedora, but applies to all systemd-distro's)
| How can I use unique hostnames across VMs with a shared root filesystem? Is this method even recommended? |
1,609,942,831,000 |
According to Debian's RPi3 image wiki, I should be able to ssh into a Raspberry-Pi, with just the hostname. I shared internet from my Debian laptop, WiFi to the a Raspberry-Pi over Ethernet, but the hostname never resolved.
What kind of settings/configuration do either the client and server or the network need for LAN hostname resolution to work?
What do I need to install on the Pi so that MS-Windows can resolve the Pi's IP address when I want to access a web server hosted on it, for example? I think it's smbclient but I'm not sure.
|
Enable Link-Local Multicast Name Resolution (LLMNR) on the RPi. Edit /etc/systemd/resolved.conf and set LLMNR=true. Enable and start the systemd service system-resolved: systemctl --now enable systemd-resolved. No DNS server is needed, but name resolution only works on the local net. Make sure there are no duplicate hostnames on the LAN.
| Linux/Windows client resolve Linux hostname on LAN |
1,609,942,831,000 |
A set of servers that I SSH into use a switch statement in the default .bashrc to make system-specific configurations:
case "$HOSTNAME" in:
systemA*|systemB|)
# some local definitions here
;;
systemC*|systemD|)
# some local definitions here
;;
*)
echo "No bashrc definitions for $HOSTNAME"
esac
But I also use bash on my Mac locally, so I decided to be a smartarse and extend this statement to include a case for when I'm not SSHing into another statement.
However, the Mac often changes my preferred hostname based on my network environment (usually when I'm wired in at work, rather than on Wi-Fi at home, but I assume this is down to the DHCP configuration). I'm aware that I can override it, but is the best idea? Is there a better solution for having bashrc settings that are only in effect when I'm not in a remote shell?
|
You could do this:
case "$HOSTNAME" in:
systemA*|systemB)
# some local definitions here
;;
systemC*|systemD)
# some local definitions here
;;
*)
if [ "$(uname)" = "Darwin" ]; then
echo "I'm on a Mac!"
else
echo "No bashrc definitions for $HOSTNAME"
fi
esac
uname will give you a whole bunch of basic info about the system you're on. uname --help for options.
Update:
Alternatively (and this is what I do, which you can see here at the end of my .bashrc) what you can do is create .bashrc_local_Darwin for Mac specific configuration and a .bashrc_local_Linux for Linux specific stuff. These can go into version control as they are still general to all macs and all linux boxes you connect to. So what you do then is create a .bashrc_local on each box you want custom configuration only for that box which you don't put into version control. You then source these files if they exist, et volià, you have a pretty neat system with out the cludgy and hard-to-maintain case...esac statement.
| Alternative to hostname for system-specific bashrc |
1,609,942,831,000 |
I have installed CentOS7 in VMWare Workstation 12 player and I'm trying to use key-based SSH authentication. I have completed the process of passwordless SSH and it works fine but I have to start the SSHD service every time I open VMWare as it refuses to connect to port 22, which is the default and I haven't changed it.
The hostname is osboxes and the FQDN is osboxes.local.com. For some reason I also need to set hostname as osboxes.local.com all the time manually even if there is entry in /etc/hosts file.
Please suggest how to keep SSHD service running all the time and set permanent FQDN hostname in CentOS7?
|
In CentOS 7, to start a daemon on boot, one must run the command:
sudo systemctl enable daemon.service
In your case, you must run:
sudo systemctl enable sshd.service
For Fully Qualified Domain Name, you should add the following line to /etc/hosts in your host (not virtual machine) according to the ip address of the virtual machine:
192.168.*.* osboxes osboxes.local.com
After that, you can login just with:
ssh user@osboxes
Also, if one ever wishes to stop a daemon starting on the boot:
sudo systemctl disable daemon.service
is the command to run. And,
sudo systemctl start daemon.service
sudo systemctl stop daemon.service
sudo systemctl status daemon.service
are the commands to start, stop and view status of a service.
Last but not least,
sudo systemctl list-unit-files
shows what services are set to enabled/disabled on boot.
| How to keep sshd service running all the time and set permanent FQDN hostname in CentOS7? |
1,609,942,831,000 |
I am attempting to use bash-completion for URLs of the form "proto://host". Without the ":", I see expected behavior, with the ":" present, the URL comes out "faulty".
Bash completion has a function for hostnames, _known_hosts_real.
It has a parameter -p PREFIX that I want to use.
How to reproduce "wrong" behavior:
You need at least one "known" host on your system:
E.g. echo "gdns.google 8.8.8.8" >> /etc/hosts
Run these commands for functioning example:
$ unset COMPREPLY
$ _known_hosts_real -p 'http//' -- "gdn"
$ echo $COMPREPLY
http//gdns.google
Non-working example:
$ unset COMPREPLY
$ _known_hosts_real -p 'http://' -- "gdn"
$ echo $COMPREPLY
//gdns.google
Note the only difference is the added colon in "http://". The problem here is the prefix has lost the protocol specifier and the colon. Is this expected behavior?
|
@Michael_Veers pointed out, that this is expected behavior (+1), so I should write my own function.
But instead I wrote a patch for the standard _known_hosts_real into my bashrc, that enables additional options:
-t Do not trim to left colon
-S <suffix> Add custom suffix
In .bashrc:
. <(type _known_hosts_real | sed -e '
1d;s/acF:p:/actS:F:p:/;
s/^.*c)/\nS)\nsuffix=$OPTARG\n;;\nt)\nnotrim=1\n;;\nc)/;
s/\(__lt\)/[ $notrim ]||\1/')
Now this works as expected:
$ unset COMPREPLY
$ _known_hosts_real -p "scp://" -S '/' -t -a gdn
$ echo $COMPREPLY
scp://gdns.google/
| How to specify protocol prefix containing ":" to bash-completion function _known_hosts_real |
1,609,942,831,000 |
When i start apache service in my debian 7.8 with the command :
root@debian:/home/debian# service apache2 start
[....] Starting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
. ok
In my /etc/hosts
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
In my /etc/hostname
localhost
How to solve the problem?
|
Edit /etc/apache2/conf.d/httpd.conf, add the line:
ServerName localhost
| Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName |
1,609,942,831,000 |
All mails suddenly stopped sending, here is the maillog:
Jan 26 17:02:20 vm2745 sendmail[3544]: My unqualified host name (Centos) unknown; sleeping for retry
Jan 26 17:03:20 vm2745 sendmail[3544]: unable to qualify my own domain name (Centos) -- using short name
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPA003544: Authentication-Warning: Centos: apache set sender to [email protected] using -f
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPA003544: [email protected], size=470, class=0, nrcpts=1, msgid=, relay=apache@localhost
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPA003544: [email protected], [email protected] (48/48), delay=00:01:00, xdelay=00:00:00, mailer=relay, pri=30470, relay=[127.0.0.1] [127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPA003544: t0QG2KPB003544: DSN: Service unavailable
Jan 26 17:03:20 vm2745 sendmail[3545]: t0QG3K4Q003545: Centos [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPB003544: [email protected], delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31494, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPB003544: t0QG2KPC003544: return to sender: Service unavailable
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPC003544: to=postmaster, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32518, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPB003544: Losing ./qft0QG2KPB003544: savemail panic
Jan 26 17:03:20 vm2745 sendmail[3544]: t0QG2KPB003544: SYSERR(apache): savemail: cannot save rejected email anywhere
hosts:
127.0.0.1 Centos localhost
::1 localhost6.localdomain6 localhost6
hosts.allow:
ALL : 127.0.0.1, 212.226.x.x, 10.10.10.
sendmail : ALL
sendmail : localhost
popa3d : ALL
hosts.deny:
ALL:ALL
/etc/mail/access:
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
What's wrong?
|
Removed Centos from hosts and added this line:
mydomain.com.ip.address mydomain.com
Now it works.
| Sendmail stopped sending mails (unable to qualify my own domain name (Centos) -- using short name) |
1,609,942,831,000 |
What if one host is defined in /etc/hosts like:
192.168.0.100 server
and one is defined in ~/.ssh/config like:
Host server
HostName 192.168.0.101
and you ssh into server: ssh server.
How would such a conflict be resolved? I guess one has higher priority than the other.
|
If you do ssh server the server part could be a real host name or some ssh internal "nickname". ssh first looks for some nickname in .ssh/config, if it finds a configuration there it will use this. If it does not find a configuration it assumes a real hostname and tries to resolve it via /etc/host and dns.
| What will be prioritized in a conflict between ~/.ssh/config hostname and /etc/hosts? |
1,609,942,831,000 |
I am using a macBook Pro
I enter: new-host-2:~ Justin$ hostname
And it returns: new-host-2.home
Why is this when it says in setting/sharing my computers name is "Justin's macbook pro" and computers on my local network can access my computer at "Justins-MacBook-Pro.local"
The tutorial I am reading says that the command should return one of the "many" names of your computer, I am assuming this is one, but if it is where else on my computer can I find this name or a list of names for my computer? And why did it not return "Justins-MacBook-Pro.local", this format was what the tutorials computer returned?
|
MAC OS X maintains at least three different names for different usages (ComputerName, HostName and LocalHostName).
You can set the command line hostname to a different value with this command:
scutil --set HostName "justins"
| Why when I enter the command "hostname" it returns something other than my computers name? |
1,609,942,831,000 |
I'm trying to connect to several computers via their hostnames since they get their IP via DHCP. I can successfully ping the machines via ping host-01.local.
ping, wget, avahi-resolve and even Firefox all send out the required mDNS packages, which I checked throug Wireshark (UDP on port 5353).
However ssh doesn't seem to try to resolve the adresses at all. There are no mDNS queries issued and the output for ssh host-01.local just says:
ssh: Could not resolve hostname host-01.local: Device or resource busy
For ssh -vvv host-01.local it is:
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "host-01.local" port 22
ssh: Could not resolve hostname host-01.local: Device or resource busy
The client is running Linux Mint. The network I'm in doesn't seem to matter. Everything else related to avahi seems to work just fine.
|
For some reason I had the 32-bit version of ssh on my system. Installing the 64-bit version seems to have solved all of my problems.
After looking through the strace of the command I noticed ssh had failed trying to load a bunch of libraries. This baffled me at first because most of these libraries are installed on my system, until I noticed some of the paths wich included i386-linux-gnu. That's when I realized I must have the wrong package installed.
| SSH is unable to resolve local domain names |
1,609,942,831,000 |
I am looking to build a script that will log in to multiple servers using a host file and run uptime, hostname -I and hostname
Script so far
echo"" ;
echo "hostname:" $(ssh $HOST hostname) ;
echo "IP:" $(ssh $HOST hostname -I) ;
echo "uptime" $(ssh $HOST uptime) ;
echo"" ;
What would be the best way to accomplish my goal?
|
Assuming you just want all output in the terminal:
#!/bin/bash
hosts_file=/path/to/file
username=youruser
while read -r host; do
hostname=$(ssh "${username}@${host}" hostname)
ip_addr=$(ssh "${username}@${host}" hostname -I)
uptime=$(ssh "${username}@${host}" uptime)
echo
{
echo "Hostname:?$hostname"
echo "IP:?$ip_addr"
echo "uptime:?$uptime"
} | column -s\? -t
echo
done <"$hosts_file"
This will loop through each line of your hosts_file, assigning the whole line to host. Then it will set the hostname, ip_addr, and uptime to the corresponding results on the remote machine. It will then echo those results in a columnized format.
| uptime Script help [closed] |
1,609,942,831,000 |
I just set up my raspberry pi. It is working great and I can easily access it from my local Windows machine using SSH. I gave it a custom hostname. I can acces the pi with this hostname only when the samba server is running on the pi. When I stop it I can no longer use the custom hostname and have to use the IP.
I was wondering if there was another way Windows systems would recognize the hostname of a linux system that does not involve setting up a samba server.
This is also relevant for me since I plan on creating a dual boot system with my local machine and accessing it from another Windows system within the LAN.
|
You can either setup a DNS server and add an entry for your Pi's hostname + IP to it. All the systems that need resolve this hostname will need to make use of this DNS server.
Your other option is to add an entry in your system's hosts file with an entry that specifies the Pi's hostname + IP address.
1.2.3.4 pi-host
NOTE: Yes Windows systems do have a host file, just like Linux/Unix systems do too.
You can see details about how to do this here: http://www.rackspace.com/knowledge_center/article/how-do-i-modify-my-hosts-file.
NOTE: This file is generally located here on Vista/Windows 7 systems: 5. In the filename field type C:\Windows\System32\Drivers\etc\hosts.
| Create FQDN in LAN for Windows systems without samba |
1,609,942,831,000 |
When changing the hostname to a random set of alphanumeric characters on a machine running Linux Mint(17.1 Rebecca, Cinnamon 64-bit) I encounter some problems.
The following script changes the hostname to a random set of alphanumeric characters:
#!/bin/bash
### BEGIN INIT INFO
# Provides: randomhostname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Changing hostname to random value
# Description: Changing hostname to random value
### END INIT INFO
old=$(cat /etc/hostname)
new=$(tr -dc 'A-Z0-9' < /dev/urandom | head -c12)
sed -i "s/$old/$new/g" /etc/hosts
sed -i "s/$old/$new/g" /etc/hostname
exit 0
Ideally the change of hostname would be achieved without restarting the system, but since /etc/init.d/hostname.sh start has to be executed afterwards and that file isn't present in this version of Linux Mint(not sure about other version), I have to reboot the system for the changes to take effect. So doing this at boot time seems like the next best option for me at the moment.
I moved the file to the /etc/init.d/ directory and made it executable with sudo chmod +x randomhostname. After that I added it to the boot sequence with sudo update-rc.d randomhostname defaults.
When I restart and the system and login to Linux Mint I can see the change of the hostname in /etc/hostname and /etc/hosts, which in this case is YKNG7Z4PJD7H. However, I don't see this when using the terminal(i.e. username@BFZJ7LB0BKAD) and I get the following message when using sudo:
username@BFZJ7LB0BKAD ~ $ sudo true
sudo: unable to resolve host BFZJ7LB0BKAD
I presume this problem is caused by the fact that the script is executed on the wrong time(maybe after certain services have already been started) and the system has yet to be rebooted again for the previous changes to take effect.
What is considered the correct way of adding a script like this to the boot sequence so that the changes take effect without rebooting another time? Or is there a better way to achieve this?
I would really appreciate any help regarding this question.
Solution
As roaima pointed out, I only had to add hostname "$new" at the end of the script to make the changes work. I also added stopping and starting of the network-manager service to force the client register with the network using the new hostname.
#!/bin/bash
### BEGIN INIT INFO
# Provides: randomhostname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Changing hostname to random value
# Description: Changing hostname to random value
### END INIT INFO
service network-manager stop
old=$(cat /etc/hostname)
new=$(tr -dc 'A-Z0-9' < /dev/urandom | head -c12)
sed -i "s/$old/$new/g" /etc/hosts
sed -i "s/$old/$new/g" /etc/hostname
hostname "$new"
service network-manager start
exit 0
|
You don't appear to be setting the hostname after rewriting /etc/hostname. This should do the trick, added after the two sed lines:
hostname "$new"
If you're using DHCP and this hasn't resolved the problem, take a look at I changed my hostname, why is my bash PS1 prompt unchanged to see if that's at all relevant to your situation.
"Rebecca" uses systemd, and the file that is used to set the hostname is /etc/init/hostname.conf. How to add your change hostname script into systemd is something I'm going to leave for another Question (more commonly known as "an exercise for the Reader").
| Changing the hostname on a Linux Mint desktop to a random value at boot time |
1,609,942,831,000 |
I set up my hostname to a number, where running hostname gives:
6592
But when I run ping 6592, I get:
connect: Invalid argument
I checked the related Wikipedia page, and it does say that such a hostname is allowed (IIUC). What am I missing?
|
What the RFC says is actually immaterial here. The RFC specifies what goes on at the DNS level, but that's moot if ping doesn't make a DNS query in the first place. When ping receives an all-numeric argument, it interprets it as an IP address.
IPv4 addresses are technically 32-bit numbers. They are almost always written in dot-decimal notation, so-called “dotted quads” like 127.0.0.1. But they can also be written as a single number in decimal like 2130706433 or in hexadecimal like 0x7f000001.
$ ping 2130706433 # 127*2^24 + 1
PING 2130706433 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.027 ms
$ ping 0.0.25.192
connect: Invalid argument
Addresses in the range 0.0.0.0/8 are reserved for use as source addresses in broadcasts. You can't send a packet to them, which is why connect(2) returns EINVAL.
Many programs, including most ping implementations, have no option to force a DNS lookup. You would run into similar trouble if you made a local network with all-numeric subdomains, and ended up with a valid hostname that looked like a dotted quad.
If your local network has a name, ping 6592.mynetwork will work. But you're likely to run into similar trouble down the line, as sooner or later you'll want to omit the domain name. Just go with the flow and include a letter, preferably at the start.
| What is a valid hostname label? |
1,609,942,831,000 |
What is the most concise way to resolve a hostname to a local IP address in Arch Linux?
|
You can use either host or nslookup from bind-tools:
$ host 172.217.19.195
195.19.217.172.in-addr.arpa domain name pointer fra02s21-in-f3.1e100.net.
$ nslookup 172.217.19.195
Server: 192.168.2.1
Address: 192.168.2.1#53
Non-authoritative answer:
195.19.217.172.in-addr.arpa name = fra02s21-in-f3.1e100.net.
| How can I resolve an IP address to a hostname in Arch Linux? [duplicate] |
1,609,942,831,000 |
I know I can associate hostname with my IP address in /etc/hosts:
1.2.3.4 foo
and then, for example in tcpdump output, I will see foo instead of my IP address (if -n was not used)
Anyways, can I temporarily add such IP -> hostname mapping on the commandline, without actually editing the file?
Lets suppose I connect to a wifi, and get some random IP. I want this IP to be resolved into my hostname in tcpdump for this current session (without adding an entry permanently into /etc/hosts.
UPDATE:
In case it was not clear from my question, and the title, I am looking for a solution how to do this without modifying /etc/hosts.
In a same way as I can use the command hostname to set the hostname for current session (ie until next restart) without having to edit /etc/hostname, I am looking for setting up reverse lookup for current session (ie until next restart) without having to modify /etc/hosts.
|
The hostname resolution service of the C library (which is used by almost all software that needs hostname resolution) is controlled primarily by the hosts: line in the /etc/nsswitch.conf file. Each keyword on that line causes the corresponding libnss_*.so library to be loaded, and those libraries will ultimately handle the hostname resolution requests from the applications.
If your distribution includes a package called nss-myhostname (or any other package that will provide a libnss_myhostname.so.* library), then you could install that package, add myhostname to the hosts: line of nsswitch.conf, and then that library will automatically associate the locally configured system hostname with any and all IP addresses configured to network interfaces on your system. With this configuration, you would not need to run any commands to update the association: it will all happen automatically. It will also associate your local hostname with IP address 127.0.0.2 (and IPv6 address ::1) if you have no IP addresses configured on your system at all.
If the hosts: line of your nsswitch.conf includes the keyword resolve or your /etc/resolv.conf has a line nameserver 127.0.0.53, then you are using systemd-resolved as your DNS resolver. It can provide similar automatic association for your local hostname to any locally configured IP addresses as libnss_myhostname (see above). If this is your case, see man systemd-resolved and read the chapter titled SYNTHETIC RECORDS. It will also include optional mDNS (see below) and LLMNR (link-local multicast name resolver/responder) functionality, which might also provide local hostname resolution in a roundabout way.
If the hosts: line of your nsswitch.conf includes a hostname resolution service that can use multicast-DNS (mDNS) like mdns4_minimal and your system includes a mDNS responder (e.g. avahi-daemon), it might enable automatic resolving of <hostname>.local to the local system's IP addresses, and vice versa.
If the hosts: line of your nsswitch.conf includes any other options (or your distribution offers other libnss_*.so libraries), you will have to investigate the functionalities offered by them on your own, since you did not specify your distribution.
If the hosts: line of your nsswitch.conf includes only the classic files and dns keywords, or you need to assign names to IP addresses that are not currently configured to any of the local network interfaces (e.g. names for IP addresses of other hosts), then see the methods in Marcus Müller's answer.
If none of these answers are suitable to you, then I'm afraid the answer will be "No, there is no functionality like you're asking for. But if you have programming skills, there would be nothing stopping you from implementing it yourself" - and the list of possible methods above and in Marcus Müller's answer should give you ideas on the interfaces you could use to plug your own solution into.
| associate IP with hostname without editing /etc/hosts |
1,609,942,831,000 |
I puchased a domain, say fireworks.com, and I would like to call my server ubuntu-18-04. How am I expected to edit /etc/hosts?
Is it possible to add multiple aliases as follows?
127.0.0.1 localhost
127.0.1.1 ubuntu-18-04.fireworks.com fireworks.com ubuntu-18-04
5.247.221.66 ubuntu-18-04.fireworks.com fireworks.com ubuntu-18-04
Usually in documentation the /etc/hosts format has only three records:
1. An IP address
2. A fqdn
3. The hostname
Is it possible (and necessary?) to add a fourth record, as in my previous example, including fireworks.com? I would like to receive mail as [email protected] other than as [email protected]
|
From man hosts:
This manual page describes the format of the /etc/hosts file. This
file is a simple text file that associates IP addresses with
hostnames, one line per IP address. For each host a single line
should be present with the following information:
IP_address canonical_hostname [aliases...]
Yes, you can add multiple lines of IPs and aliases. But for your mail reception, I'd suggest you use DNS for domain name mapping. Use dnsmasq to make it easier, it resolves from /etc/hosts too
| /etc/hosts and aliases |
1,609,942,831,000 |
I am referencing the following question because it's similar but not the same:
hostname -i returns strange result in linux
On my CentOS 7 system, I get a strange IP address from "hostname -i" after I change my hostname, and I am trying to figure out why this is the case.
I change the hostname with following command:
# hostnamectl set-hostname saturn
# systemctl restart systemd-hostnamed
My /etc/hosts file shows:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
The following is in my /etc/nsswistch.conf file:
hosts: files dns myhostname
My server IP address is 192.168.1.13, but "hostname -i" returns strange a IP address:
# hostname -i
92.242.140.21
However, "hostname -I" is fine:
# hostname -I
192.168.1.13
Why does hostname -i return 92.242.140.21. Is it a random dynamic IP assigned to my system by the DNS? Can someone explain? Thanks!
|
Unlike the hostname -I command, which just lists all configured IP addresses on all network interfaces, the hostname -i command performs name resolution (see the hostname man page).
Since your newly assigned hostname cannot be resolved using the /etc/hosts file, running hostname -i will cause your system's name resolver to generate a DNS query to an external DNS server. At this server (which I presume belongs to your ISP), this query comes up empty (NXDOMAIN result: i.e. non-existent domain). Because your ISP has partnered up with Barefruit, rather than receiving the NXDOMAIN result, you receive a Barefruit IP address in response to your query:
$ dig +short -x 92.242.140.21
unallocated.barefruit.co.uk.
I imagine that adding your new hostname to your /etc/hosts file will make the weird Barefruit IP address disappear when you run the hostname -i command. If not, you may disregard this answer : )
Just for the fun of it: using the dig command, you can interrogate different name servers. To see the difference in response, you could run the following two commands:
$ dig saturn
$ dig @8.8.8.8 saturn
The first causes name resolution via your system's preconfigured DNS server, and likely results in a Barefruit IP address being returned. The second command asks Google Public DNS to resolve the name, and returns with an NXDOMAIN status. Or not?
If so, your ISP may be involved in the dubious practice of DNS hijacking, and you may want to figure out if there is an opt-out possibility, or change your DNS service provider.
| Understanding why hostname -i returns strange IP address |
1,609,942,831,000 |
I'm having an issue relating to host names and SSL signing. The certificate signing process works fine if my host name is puppet. With the IP of the puppet master server being set in /etc/hosts.
I don't want to use the IP as it will likely change and I'll have to update /etc/hosts again.
Instead I point directly to the url but this causes additional issues relating to inconsistency in certificate names.
Is there anyway to set a host to url? E.g. something like the following in /etc/hosts:
example.com puppet
|
Is there anyway to set a host to url? E.g. something like the following in /etc/hosts
That is not a URL. Its a hostname. The point of the /etc/hosts file is that it provides an alternative to DNS for resolving hostnames to addresses.
The files nameservice (the bit of code that sits between your application and the /etc/hosts file) does not support this.
If you have your own nameserver then you could setup a CNAME record pointing the name puppet to example,com
Alternatively you could write a script to capture the DNS address of example.com and append it to a template to create the hosts file (at boot up or at intervals).
Or just fix your certificates.
| Set a host name alias in /etc/hosts? |
1,609,942,831,000 |
# hostname --help | grep ip
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
According to the above, -i should output just one IP address, while -I should output all. In my case, it works the other way around.
# hostname -i
127.0.1.1 123.123.123.123
# hostname -I
123.123.123.123
Why is that?
Here's my /etc/hosts file in case it matters:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 tmp-1 tmp-1
123.123.123.123 tmp-1
(Where 123.123.123.123 is my real actual IP v4 address.)
|
The hostname(1) manpage describes these options in full, which should clarify the confusion:
-i, --ip-address
Display the network address(es) of the host name. Note that this works only if the host name can be resolved. Avoid using this option; use hostname --all-ip-addresses instead.
-I, --all-ip-addresses
Display all network addresses of the host. This option enumerates all configured addresses on all network interfaces. The loopback interface and IPv6 link-local addresses are omitted. Contrary to option -i, this option does not depend on name resolution. Do not make any assumptions about the order of the output.
(In any case, the help text for -i says "addresses", so multiple addresses can be expected there.)
| The hostname command outputs two IP addresses when one is expected |
1,609,942,831,000 |
I have an issue where my customer used a different hostname naming convention than my company did, for the devices they purchased from us. Example:
We named the devices Lenny1, so the FQDN is lenny1.whatever.com and user@Lenny1 is what is visible to users when they log in to the device.
The customer used the name PCAP02 for this same device. This creates confusion for users when they log in and see Lenny1 as the system name.
For very complex reasons, we cannot easily change the /etc/hosts file to use the names that our customer uses. My question is, is there a way to spoof the system name that the customer will see, when they log in? This change needs to be purely cosmetic, so that the users won't get confused about what system they're logging in to.
|
You can change that in the /etc/bashrc file.
Please make a backup of this file in case you make any mistakes.
Within the file, you will see this line:
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
\h is the hostname of the machine. Remove that and replace it with PCAP02.
That line should then look like this:
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@PCAP02 \W]\\$ "
Save the file and enter bash and you will see user@PCAP02 in the terminal. Your customers will see the change when they SSH into the machines.
| Is it possible to display a different hostname, when a user logs in? |
1,609,942,831,000 |
I have recently converted one of my main Linux servers into my router as well, and made my old router simply a switch and an access point. My one issue is that I am unable to automatically determine hostnames on my local network and add them to the DNS cache. If I need to switch back to DNSMasq for this, I'm willing to, it's just that I wound up with BIND in my research. From what I've found, nmblookup is one of the best things I've found so far, but I'd really rather not install samba and start nmbd on all of the devices in my house just to get hostname resolution. I know that there is some way to do this, as my previous router was able to do this just fine for all hosts. Any ideas?
|
ISC dhcpd is capable of doing dynamic DNS updates in combination with BIND, but not without some configuration. The full information can be found in the dhcpd.conf man page; essentially, you should do something along the following lines:
Run ddns-confgen. This generates some config blocks that you need to add to your named.conf file, along with instructions. Follow them. It also talks about nsupdate. This isn't necessary since you'll be using dhcpd, but you can use nsupdate to verify that your bind configuration was done correctly.
Copy the key block to your dhcpd.conf as well.
In your dhcpd.conf, also add the following config blocks:
zone example.com. {
primary 127.0.0.1;
key ddns-key;
}
zone 0.0.10.in-addr.arpa. {
primary 127.0.0.1;
key ddns-key;
}
Obviously, you should replace the zone names with the zones you're trying to update.
Once you've done that, it should work.
Disclaimer: I've only ever used the bind side of the above myself, never the dhcp bit.
Also note that the TSIG keys aren't strictly necessary; it is possible to allow IP-based dynamic DNS updates, in which case it will work out of the box from the DHCP side of things. However, for security reasons this isn't recommended.
| Local hostname resolution with BIND and custom domain |
1,609,942,831,000 |
I got this error during the installation of 2 packages.
root@blackbox:~# apt-get install mpack ssmtp
Reading package lists... Done
Building dependency tree
Reading state information... Done
mpack is already the newest version.
ssmtp is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up ssmtp (2.64-8) ...
hostname: Name or service not known
dpkg: error processing package ssmtp (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mailutils:
mailutils depends on default-mta | mail-transport-agent; however:
Package default-mta is not installed.
Package mail-transport-agent is not installed.
Package ssmtp which provides mail-transport-agent is not configured yet.
dpkg: error processing package mailutils (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
ssmtp
mailutils
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@blackbox:~#
|
The problem is that the value entered in /etc/hostname doesn't match any entries in /etc/hosts.
This causes the command hostname --fqdn to return an unresolvable hostname, which results in ssmtp not installing.
Make sure you add your machine's hostname to /etc/hosts.
Related bugs:
https://bugs.launchpad.net/ubuntu/+source/ssmtp/+bug/582191
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=611302
| hostname: Name or service not known |
1,609,942,831,000 |
Whenever i try to start a daemon service with the
service name start
I get the following error:
/etc/sysconfig/network: line 3: HOSTNAME: command not found
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
I get the same error message for vsftpd when using the same command.
Using the hostname command i can see my hostname and it is correct.
I am on centOS release 6.6
Not really sure what the problem is, and wondering if anyone could help me.
Thanks in advance.
|
In Red Hat-based systems, most services which use networking (including MySQL) load the networking configuration into shell variables by sourcing /etc/sysconfig/network. This configuration file contains shell variable assignments similar to:
NETWORKING="yes"
NETWORKING_IPV6="no"
HOSTNAME="www.example.com"
GATEWAYDEV="eth0"
Your error message indicates that there’s a problem with line 3 of /etc/sysconfig/network. Since the shell thinks HOSTNAME is a command, I suspect that you have a space after the word HOSTNAME, probably something similar to
HOSTNAME = "www.example.com"
When the first word in a shell command is followed by a space, it is parsed by the shell as being the name of a command. This space should be removed.
| service start: HOSTNAME: command not found |
1,609,942,831,000 |
I need to use the a custom URL name which is accessible from all devices in a LAN.
I know that it can be set in the /etc/hosts file
127.0.0.1 myname
127.0.1.1 system09-System-Product-Name
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
While entering the myname hosts it is available to access myname/urlpath . It is accessible only for my system. How can I make this available systems in my LAN too?
|
Localhost as its name says can only be accessed from your local system.
If you need other users to access yout custom URL you need to map your system IP address with the name used and then add this entry on all your LAN workstations by editing theirs /etc/hosts files for example:
127.0.0.1 <custom_name> # this is for localhost
<your_ip_address> <custom_name> # this is to be added to other workstations in the LAN
Other solution is to use a DNS server in your local LAN and create an A record for your custom name that will allow other users in you LAN to access your link.
| How to change the name of localhost to a custom name which is available to other users in LAN |
1,609,942,831,000 |
I have a very basic question here. This thing is puzzling me a little bit.
I have one Ubuntu machine which is running 12.04 and I am connecting to that machine from putty in my desktop (which is running windows).
I started Netflix Exhibitor like this in that Ubuntu machine -
cronusapp@phx5qa01c:/zook$ java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file
v1.5.1
INFO com.netflix.exhibitor.core.activity.ActivityLog Exhibitor started [main]
INFO org.mortbay.log Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog [main]
INFO org.mortbay.log jetty-1.5.1 [main]
Dec 18, 2013 7:10:35 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9.1 09/14/2011 02:36 PM'
INFO org.mortbay.log Started [email protected]:8080 [main]
And then I went to chrome browser in my desktop and I opened the url like this with the machine hostname -
http://phx5qa01c.stratus.phx.qa.host.com:8080/exhibitor/v1/ui/index.html
And this url is showing me blank white page on the screen. But if I replace the hostname with IP Address of that machine, then it starts working and I can see the actual content on my browser.
http://10.108.24.132:8080/exhibitor/v1/ui/index.html
Now I am not sure why this is happening. Is there any file which I am supposed to modify in my Ubuntu box to recognize the hostname instead of ip address.
I believe this is pretty basic question which I am not aware of? Any idea what I am supposed to do to fix this?
UPDATE:-
This is what I have done to figure out the IP Address, I am taking IP Address for etho -
root@phx5qa01c:/home/david# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:ad:5b:a9
inet addr:10.108.24.132 Bcast:10.108.27.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:351211 errors:0 dropped:590 overruns:0 frame:0
TX packets:291409 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:426570999 (426.5 MB) TX bytes:39383233 (39.3 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:15839 errors:0 dropped:0 overruns:0 frame:0
TX packets:15839 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1455090 (1.4 MB) TX bytes:1455090 (1.4 MB)
And below is for the hostname -
root@phx5qa01c:/home/david# hostname -f
phx5qa01c.stratus.phx.qa.host.com
UPDATE2:-
This is what I got after nslookup from my desktop -
david@desktop /cygdrive/c/ApacheExhibitor/Exhibitor-1.5.1/target
$ nslookup phx5qa01c.stratus.phx.qa.host.com
Non-authoritative answer:
Server: sjd-entdc-001.corp.host.com
Address: 10.244.128.25
Name: phx5qa01c.stratus.phx.qa.host.com
Address: 10.108.24.132
|
If your hostname doesn't resolve to the IP address ( you can check it by pinging your hostname) add an entry in the /etc/hosts file like below
10.108.24.132 phx5qa01c.stratus.phx.qa.host.com
Update
For windows machines hosts file is in c:\WINDOWS\system32\drivers\etc\hosts
| URL with hostname doesn't work but it works with IP Address |
1,375,318,850,000 |
I just registered a domain name and paid for hosting with CentOS and I found that I had to do the binding myself following the lengthy steps http://www.linux-sxs.org/internet_serving/bind9.html
I was wondering, is there an easier way to do this binding?
I thought by configuring the dns name in Apache should be enough, is that wrong?
Any feedbacks appreciated.
|
The steps they provide effectively set up caching name service:
zone "." {
type hint;
file "root.hints";
};
Serve DNS for the 192.168.1.0/24 and 127.0.0.0/8 netblock reverse DNS zones:
zone "0.0.127.in-addr.arpa" {
type master;
file "pz/127.0.0";
allow-update { none; };
};
and
zone "1.168.192.in-addr.arpa" {
type master;
file "pz/192.168.1";
allow-update { none; };
};
These are both wrapped in views so that only hosts from those two netblocks can resolve the DNS. It also hides the version of bind from remote queries:
zone "." {
type hint;
file "/dev/null";
};
You can provide the same by adding:
127.0.0.1 localhost
192.168.1.1 localhost
to /etc/hosts and removing/stopping any exisiting BIND services. Provided that they allow DNS queries out (which they will have to if they want to allow DNS recursion from the root hints zone, to provide a caching name server), then you can use an external DNS provider (such as Google) with:
echo "nameserver 8.8.8.8" > /etc/resolv.conf
This should also be sufficient for apache to be to determine its hostname and save you the long winded process of creating a bind name server.
[EDIT] The OP has made these changes and still has issues. I suspect this is not related to the original issue, so will ask some additional questions.
If dig <domain-name>. @8.8.8.8 is giving the correct details then your External DNS is correct, and it most likely is internal ip config / routing / firewalls.
Does the output of ifconfig show interfaces with more than just 127.0.0.1 and 192.168.1.1? If it is just these, then something outside of your host NATs your address to your external IP, and MAY also decide what you are allowed in terms of open ports. If global-ip is your external IP address and appears in this list, then you may have to edit the Apache configuration to listen on that address as opposed to 192.168.1.x.
Do you have something like iptables installed? What does iptables -nvL INPUT show? (this has to be run as root, or via sudo). IPTables may be blocking incoming/outgoing requests.
[EDIT 2] The OP was interested in how DNS works.
A user on youtube has provided a basic DNS 101 video. which stands out as illustrative and straight forward enough to get the basics of DNS.
If you really want to understand DNS thoroughly the O'Reilly "Grashopper" book DNS and Bind 5th Edition is an excellent resource and also will teach you how to use in in conjuction with BIND.
| binding ip address to hostname |
1,375,318,850,000 |
Below rsync works and helps copy remote directory to localhost
/bin/rsync -rv myremoteuser@myremotehost:/tmp/Deployments/ /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/
Once i add -o StrictHostKeyChecking=no it fails with the below error:
/bin/rsync -rv -o StrictHostKeyChecking=no myremoteuser@myremotehost:/tmp/Deployments /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/
Unexpected remote arg: myremoteuser@myremotehost:/tmp/Deployments
rsync error: syntax or usage error (code 1) at main.c(1348) [sender=3.1.2]
I want it to work and also work when i put it under double quotes like below:
"/bin/rsync -rv -o StrictHostKeyChecking=no myremoteuser@myremotehost:/tmp/Deployments /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/"
bash: /bin/rsync -rv -o StrictHostKeyChecking=no myremoteuser@myremotehost:/tmp/Deployments /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/: No such file or directory
Below are the details:
$ /bin/rsync --version
rsync version 3.1.2 protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, prealloc
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
[mylocaluser@mylocalhost myremotehost]$ uname -a
Linux mylocalhost 3.10.0-1160.76.1.el7.x86_64 #1 SMP Tue Jul 26 14:15:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
|
Rsync doesn't take ssh -o options on its command line. You have to put ssh options into an ssh command string you pass to rsync's -e option. Something like:
/bin/rsync -rv -e 'ssh -o StrictHostKeyChecking=no' myremoteuser@myremotehost:/tmp/Deployments /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/
You should be able to wrap the above in double-quotes as you mentioned, since the -e argument is in single quotes. The man page also mentions using the RSYNC_RSH environment variable as an alternative to the -e command-line option.
| rsync fails to work with -o StrictHostKeyChecking=no option |
1,375,318,850,000 |
I have a simple backup script with this line to come up with a name for the backup:
backup=$(/bin/date +'%Y-%m-%d_%H:%M_%S')_$(hostname).gz
It works great when I run it under the root user. Unfortunately when I set it to run as a cronjob, the $(hostname) part is always empty and I don't get the hostname. Why isn't it working, and how can I get the hostname in a cron job?
I'm running ubuntu 18.04
|
hostname doesn't seem to be in the PATH in your script. Either put /bin/hostname there, like you did for date, or set PATH to include /bin (inside the script or in the crontab).
| $(hostname) doesn't work in cronjob [duplicate] |
1,375,318,850,000 |
I have set up a local ssh server, which I like to access with this neat alias from my local network:
~/.ssh/config:
Host myserver-local
HostName 192.168.2.8
User iago-lito
Port 22
In order to access it remotely, I have set up a no-ip account to access it via a dyndns IP resolution, which I like to access with this neat alias from any other network:
~/.ssh/config:
Host myserver
HostName myserver.ddns.net
User iago-lito
Port 22
Unfortunately, because my router do not allow NAT loopbacks, I need to use:
ssh myserver
when I'm away and:
ssh myserver-local
when I'm at home.. which makes scripting quite annoying when it comes to automately scp, git push etc.
How could I make the same alias work in both cases?
|
With a reasonably modern OpenSSH, you can run a shell command to select a Match block in ~/.ssh/config. Assuming you have a script am-on-home-network that returns 0 when executed on your home network and 1 when executed outside:
Match Host myserver exec "am-on-home-network"
HostName myserver
User iago-lito
Port 22
Host myserver
HostName myserver.ddns.net
User iago-lito
Port 22
For am-on-home-network, you can use arp to explore the local network. Look for your home router's MAC address. (Looking for IP addresses is unreliable because many private networks use the same ranges of private IP addresses.)
#!/bin/sh
timeout 0.2 arping -f -q -I eth0 12:34:56:78:9a:bc
Adjust the MAC address to the MAC address of your router that your computer sees when it's at home. Adjust eth0 to the network interface on your computer that is used to connect to your home router.
The pure SSH approach has the advantage that it can be done in userland, but it only works for SSH, and it increases the connection establishment delay noticeably. A better solution is to run a DNS server at the system level, and configure it to serve the local IP address the global name myserver.ddns.net when on the local network. Dnsmasq is a small, simple DNS cache and server, suitable for running on an endpoint machine or a small network. If you aren't already running a DNS cache on your machine, it will make general Internet usage a bit faster. Ubuntu runs dnsmasq by default.
In dnsmasq, create a file /etc/dnsmasq.d/home-server containing
host-record=myserver.ddns.net,192.168.2.1
Add the following script to your network startup scripts (whatever they are on your distribution):
#!/bin/sh
comment=\#
if timeout 0.2 arping -f -q -I eth0 12:34:56:78:9a:bc; then
comment=
fi
sed -i "\$s/^#*/$comment/" /etc/dnsmasq.d/home-server
service dnsmasq restart
If your system sets up Dnsmasq through D-Bus, editing the configuration file isn't the best option, and I don't even know if it'll work. You would need to call dbus-send to add or remove the host record based on the output of arping. Or, if you're using NetworkManager, configure it to set the host entry on the connection corresponding to your home network.
| Make hostname adapt to local/remote situation |
1,375,318,850,000 |
We have a list of dns server IPs in /etc/resolv.conf. When doing nslookup for a particular scenario we would like to ingore the second entry below, so that naming resolution occurs via other 3 DNS server IPs.
$ cat /etc/resolv.conf
domain example.com
nameserver 192.168.1.1
nameserver 10.10.10.1
nameserver 192.168.1.2
nameserver 192.168.1.3
Anyone has ideas? Thanks.
|
One solution might be to temporarily change the order of the nameservers in /etc/resolv.conf .
Another approach is to iterate through the nameservers and use them separately:
while read IP
do
echo "Testing nameserver ${IP}"
nslookup google.com "${IP}"
done < <(grep nameserver /etc/resolv.conf| awk '(FNR != 2) {print $2;}')
| any option to ignore a dns server ip from /etc/resolv.conf when doing nslookup? |
1,375,318,850,000 |
Ippsec does a lot of hackthebox boxes walkthroughs and in many of them he edits the /etc/hosts file.
Sometimes he adds multiple hostnames to the same ip address and when he browses those hostnames he gets different webpages. Shouldn't all hostnames return the same webpage? Because my understanding(may be very wrong) is that the /etc/hosts file only links ip addresses to hostnames and so there is no need to do a DNS lookup. Can anybody help me?
Thanks!
|
Web servers see the host header (IE the website name) that the browser is attempting to contact. The host header is sent regardless of how the IP was resolved. A single web server can host multiple sites on a single IP and thus uses the host header to determine which site/content to respond with.
| Why adding hostnames to /etc/hosts entries change the website viewed |
1,375,318,850,000 |
I have a fresh CentOS 7 install. During installation, I provided centa.home.local as hostname.
Now one of the software needs to see "host -v centa" output to locate the server IP address on server. Unfortunately it can't find the IP address.
[user1@centa ~]$ ifconfig | grep inet
inet 192.168.101.128 netmask 255.255.255.0 broadcast 192.168.101.255
inet6 fe80::20c:29ff:fe00:f049 prefixlen 64 scopeid 0x20<link>
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
[user1@centa ~]$ hostname
centa.home.local
[user1@centa ~]$ hostname -d
home.local
[user1@centa ~]$ hostnamectl status
Static hostname: centa.home.local
Icon name: computer-vm
Chassis: vm
Machine ID: b2d53d8cc49e486f980d0f8461c415e2
Boot ID: e2dbffd536434cc4ba530a17e8b186d6
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[user1@centa ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
192.168.101.128 centa.home.local centa
[user1@centa ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain home.local
nameserver 192.168.101.2
[user1@centa ~]$ host -v centa
Trying "centa.localdomain"
Trying "centa.home.local"
Trying "centa"
Host centa not found: 3(NXDOMAIN)
Received 98 bytes from 192.168.101.2#53 in 136 ms
[user1@centa ~]$
|
Since the host utility is performing DNS lookups, it's not using /etc/hosts. Meaning for it to succeed, the host has to be in a DNS server somewhere.
Since the question is here, I'm assuming adding this DNS record to your DNS server (the one at 192.168.101.2) is not an option. Fortunately you can actually solve this rather easy since you're using NetworkManager (as indicated by the comment line in your /etc/resolv.conf).
The solution is to enable & configure dnsmasq. dnsmasq is a DNS forwarder that runs on the local host. It can perform simple tasks such as recursive lookups, and caching the results. It can also do things like serving records from /etc/hosts. NetworkManager has built-in functionality for managing dnsmasq. So using it is very simple.
Configuration
The configuration part is to tell dnsmasq to serve records from /etc/hosts, as the default configuration NetworkManager uses for dnsmasq does not enable this functionality.
Create the file /etc/NetworkManager/dnsmasq.d/hosts.conf with the following content:
addn-hosts=/etc/hosts
Enabling
Enabling is done by adding the dns = dnsmasq parameter to the [main] section of /etc/NetworkManager/NetworkManager.conf. For example:
[main]
dns = dnsmasq
After doing so, restart NetworkManager (via systemctl restart NetworkManager.service).
Usage
You should now notice that /etc/resolv.conf only has a single nameserver entry pointing to 127.0.0.1. Any tools which consult /etc/resolv.conf to find the name servers should now end up hitting dnsmasq, and receive records found in /etc/hosts. If the record doesn't exist in /etc/hosts, the lookup will be forwarded to your upstream DNS server (192.168.101.2).
| Making "host -v hostname" command work for CentOS 7 |
1,375,318,850,000 |
I recently installed CentOS 7 on a new hard drive with all default settings and when I enter:
# hostname
I get:
SVP
But "SVP" is neither in /etc/hostnames nor /etc/hosts configured.
But I have the default hostname localhost.localdomain.
SVP was the machine name of my old windows install but that hard drive wasn't even connected during my CentOS install and isn't connected now so my best guess is that the hostname SVP was saved on my NIC and written during my CentOS install. Can anyone confirm this?
|
I find it more likely that the name comes from the DNS. The machine gets the same IP address from DHCP (because the MAC address is still the same), and CentOS does a reverse lookup on the IP address and gets the old name back from the DNS server.
| Does your hostname save on your NIC | centos 7? |
1,375,318,850,000 |
My question is similar but opposite to to Telnetting the Local port not working but trying the ip working
For me, telnet to the local port works but trying with IP does not work :(
I am running pgbouncer on port 6432:
$ telnet 192.x.x.x 6432
Trying 192.x.x.x...
telnet: Unable to connect to remote host: Connection refused
I set listen_addr = *, but still using telnet with IP from another server is not working.
See http://lists.pgfoundry.org/pipermail/pgbouncer-general/2013-January/001097.html for the same scenario (but no useful answer).
The output of netstat -plnt is
tcp 0 0 127.0.0.1:6432 0.0.0.0:* LISTEN 19879/./pgbouncer
How can I fix this?
|
A quick Google shows that recommended safe configurations for pgbouncer often set up the listening port only on the loopback interface (localhost). Here is one example:
[pgbouncer]
listen_port = 5433
listen_addr = localhost
auth_type = any
logfile = pgbouncer.log
pidfile = pgbouncer.pid
The configuration documentation explains clearly how to change the addresses on which the service listens:
listen_addr
Specifies list of addresses, where to listen for TCP connections. You
may also use * meaning “listen on all addresses”. When not set, only
Unix socket connections are allowed.
Addresses can be specified numerically (IPv4/IPv6) or by name.
Default: not set
listen_port
Which port to listen on. Applies to both TCP and Unix sockets.
Default: 6432
Since you've now responded that you've already done this, I'll leave it here for the record, but make an additional suggestion below.
The follow-up posts on the mailing list to the one you referenced provide the answer. I'll quote it here:
User 1
I restarted using /etc/init.d/pgbouncer restart, which effectively
launches pgbouncer with -R for a online restart.
User 2
I suspect the -R is working too well for you - it reuses the old
listening socket, with means the bind address stays the same.
This preference is natural - you rarely change bind addres, but may
change other settings (or pgbouncer version).
You should just do proper stop/start, then it should take new address in use.
| Telnetting the local port working but trying with ip not working |
1,375,318,850,000 |
I have an application that I want to be able to change the hostname in Linux. Currently doing so by running the hostname command. I don't want to set CAP_SYS_ADMIN either. I also don't want to edit /etc/hostname and reboot.
Is there a capability that only just allows changing the hostname? If not what are my options?
|
Setting the hostname in linux is done via the sethostname(2) syscall. And /bin/hostname is a bare wrapper around this syscall (and a few related syscalls). /etc/hostname is supposed to be read during the boot process by some script, who subsequently runs /bin/hostname to complish its job.
CAP_SYS_ADMIN is one of linux capabilities(7), allows a thread to perform various system administration operations, which include sethostname. I'm not aware of a smaller ganularity within the capabilities framework.
However there are other options. We can grant some user ability to run some command as another user, by sudo(8), in a customisable manner. This example sudoers(5) configuration will allow user alice to run /bin/hostname as root.
alice ALL=(root:ALL) /bin/hostname
As described in this superuser question, the first "ALL" can be replaced by the hosts where the command is run on, not of use unless in a cooperative environment. "root" can be replaced by "ALL" to allow alice to run as any user. Second "ALL" can be replaced by the groups.
The last field is commands alice is allowed to run. As /bin/hostname has limited usage, I guess it is fine. Otherwise we may have it followed by an argument, thus alice cannot run the command without this argument, to restrain the power.
| Set hostname without root, and without CAP_SYS_ADMIN |
1,375,318,850,000 |
Recently I installed apache2 on Raspbian and after end of installation I entered the following cmd and got two IP's.
$ hostname -I
192.168.1.17 192.168.1.24
Of this, I have been using the IP ending in 17 from beginning. But I have never seen the one with 24. Can I use them both to access my RPi or each one present only for a specific use. Like 24 only for apache ???
|
hostname -I doesn't work here (openSUSE 13.2) but there is no problem with one host using several IP addresses. That is obviously possible by having several network adapters but you can have several addresses per interface (aliases) and even several interfaces per hardware NIC.
The usual way to see the network configuration is ip addr show.
| Can a Linux system have two IP's Simultaneously? |
1,375,318,850,000 |
I'm using a Debian on a RaspberryPi and the problem that I'm having is that I can't connect to the Internet.
Every time I try I see a message that says "cannot resolve hostname". From the terminal, I tried:
$ ping www.google.com
unknown host google.com
$ ping 8.8.8.8
network is unreachable
output of 'ip addr list'
1: <LOOPBACK, UP, LOWER_UP> mt 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 vrd 00:00:00:00:00:00:
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BOADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 dis pfifo_fast state UP qlen 100
link/ether b8:27:eb:18:b9:17 brd ff:ff:ff:ff:ff:ff
This appears after doing the ifdown eth0 and ifup eth0 as drobert suggest
innet 1393.182.112.9116 brd 139.182.255.255 scope global eth0
valid_lft forevere preferred_lft forever
ip route ls
139.182.0.0/16 dev eth0 proto kernel scope link src 139.182.112.9
etc/network/interface
auto lo
iface lo inet loopback
iface eth0 inet dhcp
address 139.182.112.9
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.cong
iface default inet dhcp
ifconfig
bcast: 139.182.255.255
Mask: 255.255.0.0
I try the up route list command nothing happed
|
Your /etc/network/interfaces is confused. There are several methods of assigning an IP address to the interface; you've specified dhcp which means to ask the DHCP server for an address. But then you went ahead and specified an address anyway.
I think what you want is something like this
auto lo
iface lo inet loopback
allow-hotplug eth0 # omit this line if using ifplugd
iface eth0 inet static
address 139.182.112.9
netmask a.b.c.d
gateway 139.182.e.f
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
You hopefully know the right netmask and gateway. If not, you'll need to get them from your network administrator. They should have been provided along with the IP address.
| Cannot resolve hostname |
1,375,318,850,000 |
I am trying to type this comand but for some reason it takes the first and not the second version.
I have entered both the host names in the host file, FYI.
This command works (hostname zq13c1):
mkcifsmnt -f /aix_bk5 -d AIX -h zq13c1 -c 'aix_user' -p 'Cognizant123' -u 214 -g 204 -t rw
This command does not work (hostname zq13c1_bk):
mkcifsmnt -f /aix_bk5 -d AIX -h zq13c1_bk -c 'aix_user' -p 'Cognizant123' -u 214 -g 204 -t rw
|
Quoting from this wiki article:
The Internet standards (Request for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.
The underscore _ is not a valid character in a hostname.
| AIX cifs hostname with underscore |
1,375,318,850,000 |
Right now our team can connect to servers via SSH public key authentication.
Each team member has a private key on his PC in ~/.ssh/ and the public key is on the server in the authorized_key file.
A request has been made to authorize ssh connections to the servers only from the PCs given to each team member.
Indeed right now even though the team members have no root access to these PCs, they can theoretically copy the private key from the home folder and use it on other machines to connect to the servers. So my question was how to do this?
I read a lot of documentation and tested the approach that seemed best to me : Host-based authentication.
This seemed to be the perfect solution to my problem, each PC would have a private key in /etc/ssh/ that is not readable for anon-root user and that is used to authenticate the host in addition to the existing public key authentication configuration.
The problem I have is the hostname that is sent by the SSH client to the server.
I noticed that depending on the network I am connected to, the hostname that is sent will be fooMachine.localdomain, fooMachine.home, fooMachine.
I used ssh -vvv user@ip and looked at the lines beginning with
debug2: userauth_hostbased: chost ...
to notice that.
The PCs will not always connect to the SSH servers from the same network, we don't have a VPN or static IP.
So all this means that on the SSH servers, I will have to declare the host that is connecting multiple times (fooMachine.localdomain, fooMachine.home, fooMachine) and it may happen that I am connected to a network where I will have another suffix after fooMachine and I won't be able to connect my servers.
How do I solve this? Or is my approach wrong ?
Note that I tried to force the hostname to something like fooMachine.test.com. After reboot, the hostname --fqdn displayed fooMachine.test.com but the hostname used by the SSH client was still fooMachine.localdomain.
I also tried wildcards in the shosts.equiv file on the ssh server where I declare the hosts that will connect to the server, but it didn't work. And after reading the source code it makes sense since wildcards (+ in rhosts style files) are ignored.
|
The typical method to add restrictions to what is allowed when attempting to authenticate with particular private key, is via the relatively underused "options" field in a ~/.ssh/authorized_keys file on the server - specifically for your use-case would be the ability to configure/restrict from which hosts a particular keypair can be used with the from="pattern-list" option.
For example:
# ~/.ssh/.authorized_keys
from="10.80.0.0/14,192.168.1.2,hbruijns-workstation.internal.example.com" ssh-rsa AAAAB3NzaC1y***...***== hbruijn@serverfault
That for example only allows login with the matching private key only from hbruijns-workstation.internal.example.com, the IP-address 192.168.1.2 and/or any IP-address from the range 10.80.0.0/14.
As a further refinement you can place the ~/.ssh/.authorized_keys under control of the server admin to ensure that your team members don't override that restriction.
As I already commented and you already mentioned as well, that doesn't help you much when your network does not support the prerequisites for implementing a security model that depends on trusted clients:
you need to have a reliable method to identify your trusted clients.
When your clients do not get assigned a fixed IP and/or hostname this method won't work (but neither will any other).
So the request "to authorise ssh connections to the servers only from the PCs given to each team member" should be declined or countered with a request to for example get the required static IP-address assignments for your team member PC's, or for example a management network where your team members can connect to with VPN.
| Hostname problem in Host-based authentication when using SSH |
1,375,318,850,000 |
I have several Raspberry Pi's named numerically (pi0, pi1, etc). They have static IP addresses, but I wanted a simple tool to check on them and make sure they were online even if they got the wrong IP (I've had some trouble in the past. Nothing recently, but it seemed like a good idea to make it foolproof regardless). Instead of using IPs, this tool uses MDNS hostnames that are already in a nice format. The script I wrote is:
#!/bin/bash
report+="Device Name Status Location\n"
report+="----------- ------ --------\n"
for i in {0..3}
do
report+="Pi$i "
ping -c1 pi$i.local > /dev/null
if [ $? == 0 ]
then
report+="Online "
report+=$(ping -c1 pi$i.local | grep -o "\w*192.168.1.\w*" | head -1)
else
report+="Unreachable"
fi
report+="\n"
done
echo -e "$report"
It works wonderfully when devices are online, returning
Device Name Status Location
----------- ------ --------
Pi0 Online 192.168.1.3
Pi1 Online 192.168.1.4
Pi2 Online 192.168.1.5
Pi3 Online 192.168.1.6
However, when they are offline the output looks like this
ping: pi0.local: Name or service not known
ping: pi1.local: Name or service not known
ping: pi2.local: Name or service not known
ping: pi3.local: Name or service not known
Device Name Status Location
----------- ------ --------
Pi0 Unreachable
Pi1 Unreachable
Pi2 Unreachable
Pi3 Unreachable
Is there a way to suppress the "Name or service not known" for the MDNS lookup on the ping? I already direct output to /dev/null, so I don't see how it is still giving output.
Alternatively, if you have a better/faster/easier/prettier way to do this checking, I'd love to hear it.
|
As was briefly pointed out in the comments, ping is displaying that message to stderr, which you had not redirected. Do so with:
...
ping -c1 pi$i.local > /dev/null 2>&1
...
| Suppress "Name or service not known" on ping |
1,375,318,850,000 |
I set the hostname.
# more /etc/hostname
kafka01.ocff4.com
The hostname is still as follows.
hostname
kafka01
I restart using the following command.
systemctl restart systemd-hostnamed
But still, hostname does not show the FQDN.
hostname
kafka01
Why did systemctl restart systemd-hostnamed not take affect? Is it a bug?
|
Take a look at your /etc/sysconfig/network file. If your hostname isn't present in the file, place the following line in it:
hostname kafka01.ocff4.com
You'll also have to "sudo hostname kafka01.ocff4.com" at the command line to make the change take affect immediatly, or restart to make the change take affect.
| Why isn’t the hostname command getting the FQDN from /etc/hostname? [duplicate] |
1,375,318,850,000 |
I have 2 Virtualbox VM's on which I have Ubuntu 15.
The hostnames are:
Machine 1: satya-VirtualBox
Machine 2: sam1-VirtualBox
Hosts file on machine 1-
But I am able to ping machine 2 from 1 using hostname without any DNS server in my environment. How is the hostname getting resolved?
|
The Ubuntu machines are using Multicast DNS.
| How a Virtualbox ubuntu VM able to resolve another ubuntu VM's hostname.? |
1,375,318,850,000 |
I have a CentOS 7 install that is giving me some weird returns when I lookup the hostname of the localmachine. I am used to working with Windows and the hosts file (/etc/hosts in CentOS) so feel like I have this setup correct. I do have a few entries in the hosts file as I am running a group of virtual machines for a test deployment scenario - Hence the extra names defined in there. All the machines in the deployment (3) have the same setup and are returning essentially the same data.
admin@node2$ hostname
node2.deployment.local
admin@node2$ hostname -f
chef-node2
admin@node2$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.5.99 node1 node1.deployment.local
192.168.5.100 master master.deployment.local
192.168.5.98 node2 node2.deployment.local
admin@node2$ printenv | grep -i -e "hostname"
HOSTNAME=node2.deployment.local
admin@node2$ cat /etc/environment
http_proxy=http://stupidproxy.itsaywehavetohaveit.local:3128
https_proxy=http://stupidproxy.itsaywehavetohaveit.local:3128
java_home=/applications/jre1.8.0_92/
DISPLAY=127.0.0.1:0.0
What I am trying to figure out is why the system prints the netbios name when running the 'hostname -f' command and prints the FQDN when I run the 'hostname' command. I believe that this is causing me some issue.
Your help understanding and hopefully resolving this is appreciated.
|
swap the hosts in your /etc/hosts, the format should be long then short.
good:
176.31.91.220 www.mikejonesey.co.uk mike
bad:
176.31.91.220 mike www.mikejonesey.co.uk
hostname will work off this, also I on epel systems i tend to change the domain in /etc/sysconfig/network to be just the hostname, then add the extra def for domain.
| CentOS 7 hostname netbios/fqdn output |
1,375,318,850,000 |
how do I set the hostname, FQDN, in yast?
I ran yast => network devices => network services => hostname/DNS:
YaST2 - lan @ arrakis
Network Settings
┌Global Options──Overview──Hostname/DNS──Routing──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌Hostname and Domain Name───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││Hostname Domain Name ││
││arrakis▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ bounceme.net▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ││
││[ ] Change Hostname via DHCP ││
││[x] Assign Hostname to Loopback IP ││
│└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
│Modify DNS configuration Custom Policy Rule │
│Use Default Policy▒▒▒▒▒↓ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓ │
│┌Name Servers and Domain Search List────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││Name Server 1 ┌Domain Search──────────────────────────────────────────────────────────────────────┐││
││▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │bounceme.net │││
││Name Server 2 │ │││
││▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │││
││Name Server 3 │ │││
││▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ └───────────────────────────────────────────────────────────────────────────────────┘││
│└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
│ │
│ │
│
which made this alteration:
linux-k7qk:~ #
linux-k7qk:~ #
linux-k7qk:~ # cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
127.0.0.2 arrakis.bounceme.net arrakis
linux-k7qk:~ #
and now I see that my hostname, apparently, is arrakis -- is that correct?
linux-k7qk:~ #
linux-k7qk:~ # hostname
arrakis
linux-k7qk:~ #
linux-k7qk:~ # ping arrakis
PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data.
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.049 ms
^C
--- arrakis.bounceme.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.039/0.047/0.053/0.005 ms
linux-k7qk:~ #
linux-k7qk:~ #
linux-k7qk:~ # ping arrakis.bounceme.net
PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data.
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.037 ms
^C
--- arrakis.bounceme.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.034/0.037/0.040/0.002 ms
linux-k7qk:~ #
why does the prompt stay as k7qk?
Is the hostname actually the FQDN arrakis.bounceme.net?
(Please note that I'm not running a publicly available web server or anything like that, just on the LAN. I only want to ensure that the hostname has been changed.)
uname shows:
linux-k7qk:~ #
linux-k7qk:~ # uname -a
Linux arrakis 3.11.10-25-default #1 SMP Wed Dec 17 17:57:03 UTC 2014 (8210f77) x86_64 x86_64 x86_64 GNU/Linux
linux-k7qk:~ #
While I'm not running arrakis as a publicly available web server, or anything like that, I want it set up for that eventuality. Perhaps just on the LAN.
The FQDN arrakis.bounceme.net is registered on noip.com as a host name; part of their free services. (No, that's not a plug for noip, well, it is in a round-a-bout way...)
|
In order for your changes to be visible in your current shell you need to terminate the current session and log back in. Your hostname will have changed to arakis.
Explanation: a terminal session needs to be closed and re-opened for the profile to be re-read.
| how do I set a hostname in yast? |
1,375,318,850,000 |
I have a very strange problem with my hostname on Debian 7+. I've changed the hostname on my new server but for some reason it doesn't change in wierd places. Right now I get the old hostname when I login using SSH AND all my cron emails send the emails as [email protected].
/etc/hosts has the correct new hostname (new.hostname.com)
/etc/sysconfig/network has the correct new hostname (new.hostname.com)
hostname shows the correct new hostname (new.hostname.com)
hostname -A and hostname --fqdn shows the correct new hostname (new.hostname.com)
Where else can I look to see if there's a missconfiguration somewhere?
This is the example welcome text when logging in using SSH:
login as: root
[email protected]'s password:
Linux old.hostname.com 2.6.32-042stab094.7 #1 SMP Wed Oct 22 12:43:21 MSK 2014 x86_64
|
Powering the server off and then powering it on again forced it to update the hostname.
A regular reboot would probably do it as well in most cases.
| Correct hostname doesn't change in entire system |
1,375,318,850,000 |
I've seen some questions asking why xxx can't connect to MyMacName.local, which answer regarding Avahi as a requirement.
I don't think I am in the same category as I can successfully connect to a Windows machine without needing to do anything on my Debian one.
I am able to SSH into both Windows and Mac via IP address, but the Mac only via IP.
Does something need to change on the Mac side or the Debian host?
UPDATE:
Debian can connect to Windows via hostname
Windows can connect to Debian via hostname
Debian cannot connect to OS X via hostname
OS X cannot connect to Debian via hostname
All can connect to each other via IP
|
When I had this problem it has been DNS based. Basically, when a DCHP client gets a IP from a "retail" router (or many other DNS/DHCP combined servers), they add an entry to the the DNS server so that ping mybox will work.
Apple like to be just a little bit different about things, so I would not be surprised to find that your DNS server has no idea who "MyMacName.local" is.
Avahi, shouldn't have anything to do with "resolution" of the name when it comes to SSH, (though Avahi could make entries in your local DNS server).
First check if your DNS server has any idea who "MyMacName.local" is. If it doesn't then I would configure your router, or your mac to play better with each other.
Second, check if you mac is "advertising" ssh on Bojour. This link may help with that.
| Debian cannot SSH to OS X by hostname (Windows OK) |
1,375,318,850,000 |
I changed the name of the hosts in /etc/hosts to
IP.GOES.HERE newname
Apache does recognize the new server name; but still, via ssh i get this on the ssh prompt:
[root@oldname]
Why? Where else do I need to change the server name?
I'm using CentOS 6.3
|
On CentOS you set the system hostname in /etc/sysconfig/network.
This setting change takes effect on reboot. To change the hostname on a running system without rebooting use the hostname command.
| Changing the server name |
1,375,318,850,000 |
I am trying to install nacl crypto on my system:
% uname -a
Linux (none) 2.6.39-ARCH #1 SMP PREEMPT Mon Jun 6 22:37:55 CEST 2011 x86_64 Intel(R) Core(TM) i5 CPU M 540 @ 2.53GHz GenuineIntel GNU/Linux
But the build process didn't succeed:
~/nacl-20110221 % ./do
./do: line 9: hostname: command not found
Did I forget something?
[update]
% cat /etc/hosts
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
# End of file
|
You don't have the hostname command. It just moved from net-tools to coreutils, so make sure you have the latest coreutils. Though there is some debate as to whether this is right, so it might change again.
As of 2020, the package containing hostname is now inetutils.
| nacl crypto installation on arch |
1,667,594,652,000 |
I am trying to use part of the hostname output in Linux and use it in a file using sed. For example, I am using this command as
hostname |tail -c 4 which shows me output as last 4 numbers and then use this output and substitute it with another text inside a file.
Assuming part of the hostname command shows with tail -c 4 option, "1234" How can I take it this further and use it to replace it with another file. I can do this manually by:
hostname |tail -c 4 ; sed -i 's/oldtext/1234/g' filename.txt
but not sure how can I achieve this with script? Any ideas?
|
You could store the output of the first command in a variable
$ var=$(hostname |tail -c 4)
Once stored, you can then use it as the replacement with sed
$ sed -i.bak "s/oldtext/$var/g" filename.txt
| Using hostname output in linux with sed |
1,667,594,652,000 |
I have cloned a KVM vm from one host to other host, I tried to rename the hostname and it's been renamed. But after reboot still it goes to old name.
hostnamectl command output
Static hostname: new_name
Transient hostname: old_name
Icon name: computer-vm
Chassis: vm
How do I find the root cause for this name change and what's the fix?
I'm using static IP and there's no hostname entry in /etc/sysconfig/network or in interfaces files.
|
If you are getting Transient hostname: old_name and Static hostname: new_name. Then it's user space modification of hostname.
Make sure there's no entry for Hostname in 2 below files
1. ~/.bash_profile - for respective user
2. /etc/rc.local
| Hostname overrided after Reboot even after making entry in /etc/hostname |
1,667,594,652,000 |
I would like to know what files must I edit in order to add a domain on a RHEL7 machine?
Example:
Hostname: Server1
Domain Name: qwer.tyu.iop
Result:
Server1.qwer.tyu.iop
|
I'd do this via the hostnamectl command.
$ hostnamectl
Static hostname: centos7
Icon name: computer-vm
Chassis: vm
Machine ID: 1ec1e304541e429e8876ba9b8942a14a
Boot ID: 1fccc9bc187646549c942457b95ed299
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.21.1.el7.x86_64
Architecture: x86-64
To set your hostname:
$ hostnamectl set-hostname blah.blah.com
To confirm:
$ hostnamectl
Static hostname: blah.blah.com
Icon name: computer-vm
Chassis: vm
Machine ID: 1ec1e304541e429e8876ba9b8942a14a
Boot ID: 1fccc9bc187646549c942457b95ed299
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.21.1.el7.x86_64
Architecture: x86-64
NOTE: Doing it this way it'll persists between reboots etc.
References
3.3. CONFIGURING HOST NAMES USING HOSTNAMECTL
| How to attach domain to RHEL7 using the shell? |
1,667,594,652,000 |
I found something weird in my debian 9 config.
I changed my hostname by editing /etc/hostname and rebooting from "myhost" to "myhost-hello".
Since this modification connecting to the machine via it's ip (I don't use WINS or other functions like that at all) shows the server not reacheable.
I said myself.. maybe it's some kind of firewall issue, so I directly connected to the machine but the machine was still not reacheable via smb:// from an ubuntu test pc.
I tried to reboot the samba daemon various times with any success..
When I switched the hostname of the target machine back to "myhost" samba returned available.
I wonder.. is there some kind of automatic configuration of the hostname that makes samba not reacheable if the hostname changes? (note again that I connect to that machine via it's ip, and I don't use the wins feature or try to connect to it via it's hostname)
|
Seems that the error got solved editing also the /etc/hosts making the machine able to understand that the hostname must be searched locally instead being passed via the default gateway.
So.. TL;DR:
/etc/hosts
edit the line
myhost 127.0.0.1 for example to
myhost-hello 127.0.0.1
... that's all
| Changing system hostname makes samba being unaccessible |
1,667,594,652,000 |
I tried setting up a DNS Lookup on CentOS 7 (in a Virtual Box VM), which works for FQDN on the same virtual machine as the DNS. However when I try to resolve the short hostname, it fails.
I have seen this working on some servers and wanted to learn how to set it up myself. Appreciate any help on this.
Below are the configurations in place:
File - /etc/named.conf
//
// named.conf
//
options {
listen-on port 53 { 127.0.0.1; 192.168.56.101; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost; 192.168.0.0/24; };
allow-transfer { localhost; 192.168.56.101; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "eai.com" IN {
type master;
file "forward.linuxzadmin";
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "reverse.linuxzadmin";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
File - /etc/resolv.conf
# Generated by NetworkManager
# nameserver 169.144.126.136
# nameserver 146.11.115.200
# nameserver 153.88.112.200
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
# nameserver 147.128.170.138
# nameserver 127.0.0.1
nameserver 192.168.56.101
File - /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.101 eai16.eai.com eai16 eai16-oam
File - /var/named/forward.linuxzadmin
$TTL 86400
@ IN SOA masterdns.eai.com. root.eai.com. (
2014051001 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
@ IN NS masterdns.eai.com.
@ IN A 192.168.56.101
masterdns IN A 192.168.56.101
node1 IN A 192.168.56.101
eai16 IN A 192.168.56.101
File - /var/named/reverse.linuxzadmin
$TTL 86400
@ IN SOA masterdns.eai.com. root.eai.com. (
2014051001 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
@ IN NS masterdns.eai.com.
@ IN PTR eai.com.
masterdns IN A 192.168.56.101
node1 IN A 192.168.56.101
eai16 IN A 192.168.56.101
101 IN PTR masterdns.eai.com.
101 IN PTR node1.eai.com.
101 IN PTR eai16.eai.com.
101 IN PTR eai16.
Command Output
Hostname
[root@eai16 etc]# hostname -f
eai16.eai.com
[root@eai16 etc]# hostname -s
eai16
NS Lookup on FQDN
[root@eai16 etc]# nslookup eai16.eai.com
Server: 192.168.56.101
Address: 192.168.56.101#53
Name: eai16.eai.com
Address: 192.168.56.101
Dig on FQDN
[root@eai16 etc]# dig eai16.eai.com
; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> eai16.eai.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62927
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;eai16.eai.com. IN A
;; ANSWER SECTION:
eai16.eai.com. 86400 IN A 192.168.56.101
;; AUTHORITY SECTION:
eai.com. 86400 IN NS masterdns.eai.com.
;; ADDITIONAL SECTION:
masterdns.eai.com. 86400 IN A 192.168.56.101
;; Query time: 0 msec
;; SERVER: 192.168.56.101#53(192.168.56.101)
;; WHEN: Wed Jun 28 21:13:38 IST 2017
;; MSG SIZE rcvd: 98
Host on FQDN
[root@eai16 etc]# host eai16.eai.com
eai16.eai.com has address 192.168.56.101
[root@eai16 etc]# host `hostname`
eai16.eai.com has address 192.168.56.101
Now all the commands (nslookup, dig and host) fail on the short hostname.
[root@eai16 etc]# host eai16
Host eai16 not found: 2(SERVFAIL)
[root@eai16 etc]# host eai16
;; connection timed out; no servers could be reached
[root@eai16 etc]# nslookup eai16
Server: 192.168.56.101
Address: 192.168.56.101#53
** server can't find eai16: SERVFAIL
[root@eai16 etc]# dig eai16
; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> eai16
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 23006
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;eai16. IN A
;; Query time: 0 msec
;; SERVER: 192.168.56.101#53(192.168.56.101)
;; WHEN: Wed Jun 28 21:25:18 IST 2017
;; MSG SIZE rcvd: 34
I know there is something missing/wrong in my configuration, but am not able to figure out what.
|
The problem is in your resolv.conf/DHCP configuration if resolv.conf is not static.
You have got to add to the search directive of resolv.conf the domain eai.com
When you try a DNS name lookup, the resolver libraries, if unsuccessful, try in turns to resolve the name adding the domains in the search directive until they find a resolvable name, or until they exhaust the domain list in the search directive.
| CentOS7 unable to resolve nslookup for short hostname |
1,667,594,652,000 |
I am trying to change the hostname of a CentOS6 system and somehow it keeps returning back to localhost.
Basically, I am using: "hostname new_name" as a superuser, and it works.
Then when I log in sometimes later, it forgets the new name and turns back to "localhost". Is there any suggestion what I did miss?
I am using DHCP with reserved IP addresses, it is important.
|
Open /etc/sysconfig/network with a text editor like vim or nano.
Specify the desired hostname on the line:
HOSTNAME=ExamplePC
| Hostname keeps turning back to localhost |
1,667,594,652,000 |
I was following this tutorial to setup two virtual hosts in Centos 7.
The issue is i am getting the following error while restarting the httpd.
[userme@server ~]$ sudo systemctl restart httpd.service
[sudo] password for userme:
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
My configurations are
[userme@server ~]$ cat /etc/hosts
127.0.0.1 server.workstation.com server
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[userme@server ~]$ hostname
server.workstation.com
[userme@server ~]$ cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=server
[userme@server ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
search workstation.com
nameserver fe80::1%p3p1
nameserver 192.168.100.1
[userme@server ~]$ domainname
(none)
EDIT As per request
[userme@server ~]$ systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2018-01-18 12:55:25 +04; 57min ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 1285 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 1283 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 1283 (code=exited, status=1/FAILURE)
Jan 18 12:55:25 server.workstation.com systemd[1]: Starting The Apache HTTP Server...
Jan 18 12:55:25 server.workstation.com httpd[1283]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using server.workstation.com. Set the 'ServerName' directive globally to suppress this message
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 18 12:55:25 server.workstation.com kill[1285]: kill: cannot find process ""
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 18 12:55:25 server.workstation.com systemd[1]: Failed to start The Apache HTTP Server.
Jan 18 12:55:25 server.workstation.com systemd[1]: Unit httpd.service entered failed state.
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service failed.
[userme@server ~]$ sudo firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: p3p1
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[userme@server ~]$ apachectl configtest
Syntax OK
What is the issue with my network/hostname settings ?
Any help would be appreciated.
|
This looks like an issue with SELINUX that is enable be default on CentOS 7.
Setting SELINUX=permissive and rebooting the server will log the issues to /var/log/audit/audit.log so that set the appropriate SELINUX setting can be set up to allow the SELINUX to protect the server.
In addition setting up firewalld to allow access to ports 80 and 443 to allow external connections is needed:
firewall-cmd --add-service=http
firewall-cmd --add-service=https
linode has a good write up for firewalld but I've not found a good SELINUX resource...
| Could not reliably determine the server's fully qualified domain name |
1,667,594,652,000 |
Could you please explain the difference between:
echo ${hostname};
and echo $(hostname);
echo ${hostname}; - shows nothing, just an empty line.
echo $(hostname); - shows information from /etc/hostname.
tested on Ubuntu 22.04.1 and CentOS 7
|
${hostname} or $hostname is called parameter expansion, and here it gives the value of the shell variable hostname. It's probably unset, so you get the empty string which gets removed during word splitting since the expansion is not quoted. But you could of course define it, and Bash would automatically fill the uppercase HOSTNAME with the hostname.
See e.g. $VAR vs ${VAR} and to quote or not to quote
$ hostname=foo
$ echo "$hostname"
foo
$(hostname) is called command substitution, and here it runs the command hostname and gives its output.
$ hostname
ulpukka
$ foo=$(hostname)
$ echo "$foo"
ulpukka
Word splitting applies to both unquoted parameter expansions and command substitutions, see e.g. Quoting within $(command substitution) in Bash and When is double-quoting necessary?
| echo ${hostname}; vs echo $(hostname); |
1,667,594,652,000 |
I am getting the following error when trying to set the Primary node for DRBD.
'node1' not defined in your config (for this host).
I know this is related to DNS/Hostname/Hosts and the config clusterdb.res. I know this because I originally got an error when trying to start clusterdb.res if node1 didn't resolve correctly. So what confuses me is that I can start the clusterdb.res if either use:
I have used this command on the hosts
hostnamectl set-hostname $(uname -n | sed s/\\..*//)
To make the hostname resolve to node1 instead of node1.localdomain
Or add node1.localdomain to the config, either works. But I have tried all combinations and can't seem to get this command to take :
drbdadm primary --force node1 && cat /proc/drbd
My Configs
/etc/drbd.d/clusterdb.res
resource clusterdb{
protocol C;
meta-disk internal;
device /dev/drbd0;
startup {
wfc-timeout 30;
outdated-wfc-timeout 20;
degr-wfc-timeout 30;
}
net {
cram-hmac-alg sha1;
shared-secret sync_disk;
}
syncer {
rate 10M;
al-extents 257;
on-no-data-accessible io-error;
verify-alg sha1;
}
on node1 {
disk /dev/sda3;
address 192.168.1.216:7788;
}
on node2 {
disk /dev/sda3;
address 192.168.1.217:7788;
}
}
/etc/hosts :
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.216 node1
192.168.1.217 node2
/etc/hostname
node#
My full write up ATM (wip)
Edits :
[root@node1 ~]# hostname
node1
[root@node1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.1.1 node1
192.168.1.216 node1
192.168.1.217 node2
[root@node1 ~]#
Update: I have gotten this to work with LVM following this guide exactly, so I think my issue actually lies with the following lines of code. But for now I think i will stick with LVM since it works, unless somebody else really wants to work on this. (My working LVM writeup)
device /dev/drbd0;
or
device /dev/drbd0;
The reason I say this, is I used the same hosts/hostname/shortname/ip_addr but LVM and it worked, but maybe I missed something the first time, I fixed in my new VM Template (I started from scratch to build LVM)
|
You're not using the drbdadm command correctly. It wants the resource name, where you're giving it a node name.
Try this instead (from node1):
drbdadm up clusterdb
drbdadm primary --force clusterdb
As a side note, DRBD expects the hostnames in its config to be the same as uname -n.
| DRBD - 'node1' not defined in your config (for this host) - Error when setting Primary |
1,667,594,652,000 |
I am quite new to Linux and I was wondering how to change the following when in terminal permanently. When I set up my computer I used a name that I now want to change:
In terminal, the name I want to change would be of this form:
TheNameIWantToChange@HostName ~ $
So my question is, what exactly is this name and how do I go about changing it? Thanks!
|
If I understand correctly you'd like to change your user name.
usermod -l TheNameIWantToChange -d /home/TheNameIWantToChange -m CurrentName
usermod : modify an account
-l : change the name
-d : chnage the location (name) of the home directory
-m : move the contents of the current home dir to the new one
E.g. suppose current name is albert and you'd like to change it to benny:
sudo usermod -l benny -d /home/benny -m albert
As an added bonus, you can use environment variables:
NewUser="benny"
sudo usermod -l ${NewUser} -d /home/${NewUser} -m $USER
| How to change ThisName@HostName ~ $ |
1,667,594,652,000 |
"No news is good news", which, sticking with the normal convention should return 0. Why does
hostname -h
return 255, especially when, 255 by convention, is meant to mean "Exit status out of range"
|
"hostname -h"
does not return 255 on my RHEL machine.
it does return error 4 which make sense
hostname -h
Usage: hostname [-v] {hostname|-F file} set hostname (from file)
........
echo $?
4
If you take a look at hostname.c from net-utils you will clearly see that:
static void usage(void)
{
fprintf(stderr, _("Usage: hostname [-v] {hostname|-F file} set hostname (from file)\n"));
........
exit(4); /* E_USAGE */
}
and reference to usage() in here in the same file:
........
case '?':
case 'h':
default:
usage();
};
So i am not really sure why you are getting 255, on MAC version you might get "1", but i never seen "255".
EDIT you are right, i've just looked at fedora19 and hostname comes from hostname RPM
and indeed for usage they do return 255:
void
usage(FILE *stream)
{
fprintf(stream,
.....
exit(-1);
}
;
So here I will try to explain your confusion.
Well, first doing exit(-1) there is a mistake by a programmer, at least for POSIX environment, since in such OS anything that not 0 in exit status considered FAILURE, but:
What about the exit() function found in the standard C library?
It’s manpage tells us that “the exit() function causes normal process termination and the value of status & 0377 is returned to the parent”.
Now, status & 0377?
What does that mean?
Well, 0377 is 377 in octal, which is 255 in decimal, or 0xFF in hexadecimal.
#include <stdlib.h>
void exit(int status);
So, if exit takes a signed argument, but returns a 0xFF masked one to its parent( which is shell), and “-1” is represented as all ones in two’s-complement, this only means that the value the shell is going to see and, thus, $? is going to store = 0xff
Recall that 0xff is 255, and that’s pretty much it.
Even if programmer is aware that all user will get is 255 when he calls exit(-1), it is a poor habit to do that while programming in POSIX environment. The code will eventually reach someone that will misunderstand the meaning of the -1(255) argument and raise a question like you(OP) did.
| Why does hostname -h return 255 |
1,667,594,652,000 |
I had set my hostname while installing linux as "ankit". i want to change it to "ankit.centos". I tried changing hostname in /etc/hosts, /etc/sysconfig/network and sysctl kernel.hostname=ankit.centos.
Though the hostname is set correctly which I verified by typing hostname on terminal, but even after restarting the system the name on terminal is not changed it still is showing root@ankit$.
Any clues how do change that?
|
The default PS1 prompt behavior is to display the hostname up to the first '.' as noted in this excerpt from the bash man page:
PROMPTING
When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt
PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of
backslash-escaped special characters that are decoded as follows:
snip
\h the hostname up to the first ‘.’
\H the hostname
You can correct this by changing how your PS1 prompt is displayed in /etc/bashrc
This CentOS website details methods for customizing your bash prompt, including this:
System-wide Configuration
System-wide configuration is done in /etc/bashrc. Comment out the default settings and add your customization below:
# [ "$PS1" = "\s-\v\\$ " ] && PS1="[\u@\h \w]\$ "
PS1='\u@\H:\w\$ '
| Changing hostname doesn't change the terminal name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.