Cum sa modificam hosts file din cmd fara notepad

Configurare noua (How To)

Situatie

In caz ca a fost schimbat serverul dns sau nameserverul si site-ul dorit se afla in perioada de propagare (48h), putem accesa acel site cu ajutorul fisierului “hosts”.

Solutie

Deschidem cmd cu drepturi de admin si de acolo navigam in directorul unde se afla fisierul dorit.

1. utilizam urmatoarea comanda:

cd %windir%/system32/drivers/etc

cd= change directory

2. scriem type hosts aici ar trebuii sa vedem un output de genul:

C:\Windows\System32\drivers\etc>type hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

3. in caz ca avem mai multe setari in hosts file si nu vrem sa le stricam le facem un mic backup cu:

type hosts > hosts.bak

4. in final pentru a edita folosim urmatoarea comanda:

!!atentie folositi >> deoarece >>= append iar > = rescriere

echo “adresa ip” “domeniu” >> hosts (totul este fara “”)

daca scriem iar type hosts o sa vedem ca la final a fost adaugat ce am scris mai sus

C:\Windows\System32\drivers\etc>type hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
adresa ip domeniu

Tip solutie

Permanent

Voteaza

(8 din 18 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?