Home>

Currently, we are connecting to linux in a virtual environment by specifying the IP address from teraterm.
On teraterm

Host (T): 192.168.0.10


The connection is successful by inputting as.
This is not addressing

Host (T): localhost


I want to connect by specifying the host name like, so I want to know how to do it.

After investigating, it seems that it can be realized by adding to "/ etc/hosts"
I found out that.

Added to hosts, now

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.10 localhost

It is like this.
Now if you specify "localhost" and the host name on teraterm,
We interpret that it is possible to do the same as when "192.168.0.10" is specified.
I wasn't sure if the settings were reflected, so I restarted linux once.

Since it was "inet addr: 192.168.0.10" in ifconfig after rebooting,
The connection (host name is 192.168.0.10) from teraterm with the IP address specified was successful.
However, in a connection with a host name (host name: localhost)
The connection failed with a "connection refused" error ...

The cause has not been found, whether the method of adding to "/ etc/hosts" is incorrect, or whether there is other work to be done.

I would like to ask you what is missing. I look forward to working with you.

  • Answer # 1

    If you are using teraterm, is the host windows?
    If so, the file to be set is
    C: \ Windows \ System32 \ drivers \ etc \ hosts
    Will be.
    (windows hosts editPlease check around. Editing is possible only with an editor executed with administrator privileges. )

    192.168.0.10 ssh.localhostIn the form oflocalhostLet's set a name other than the IP of the virtual machine.
    (Even if the host side is Linuxlocalhost (IPv4)Do not set multiple names for)

  • Answer # 2

    You have to set it in the hosts file on the host side, not on the guest side of the virtual environment.