找回密碼
 註冊
查看: 7220|回覆: 32

[其他] How to modify your "hosts" file

    [複製鏈接]
69 元錢 回覆本帖可獲得 1 元錢獎勵! 每人限 1 次
發表於 2017-11-27 06:08:30 | 顯示全部樓層 |閱讀模式

登入後,內容更豐富

您需要 登錄 才可以下載或查看,沒有賬號?註冊

×
How to modify your "hosts" file

Modifying your hosts file enables you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without the test link, prior to going live with SSL; verify that an alias site works, prior to DNS changes; and for other DNS-related reasons. Modifying your hosts file causes your local machine to look directly at the IP address specified.

To modify the hosts file, you add two entries to the file that contains the IP address that you want the site to resolve to and the address. Adding the following two lines, for example, point www.domain.com and domain.com to our current PHP5-ITK (“Refreshed” PHP5) cluster:

64.49.219.194 www.domain.com
64.49.219.194 domain.com

The sections in this article provide instructions for locating and editing the hosts file on the following operating systems:

    Windows 10, Windows 8, Windows 7, and Windows Vista
    Windows NT, Windows 2000, and Windows XP
    Linux
    Mac OS X 10.0 through 10.1.5
    Mac OS X 10.6 through 10.12

After you add the domain information and save the file, your system begins resolving to the specified IP address. After testing is finished, remove these entries.

Windows

Windows 10, Windows 8, Windows 7, and Windows Vista use User Account Control (UAC), so Notepad must be run as Administrator.

For Windows 10 and 8

    Press the Windows key.
    Type Notepad in the search field.
    In the search results, right-click Notepad and select Run as administrator.
    From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
    Make the necessary changes to the file.
    Click File > Save to save your changes.

For Windows 7 and Vista

    Click Start > All Programs > Accessories.
    Right-click Notepad and select Run as administrator.
    Click Continue on the Windows needs your permission UAC window.
    When Notepad opens, click File > Open.
    In the File name field, type C:\Windows\System32\Drivers\etc\hosts
    Click Open.
    Make the necessary changes to the file.
    Click File > Save to save your changes.

Windows NT, Windows 2000, and Windows XP

    Click Start > All Programs > Accessories > Notepad.
    Click File > Open.
    In the File name field, type C:\Windows\System32\Drivers\etc\hosts
    Click Open.
    Make the necessary changes to the file.
    Click File > Save to save your changes.

Linux

    Open a terminal window.

    Open the hosts file in a text editor (you can use any text editor) by typing the following line:

    sudo nano /etc/hosts

    Enter your domain user password.
    Make the necessary changes to the file.
    Press Control-x.
    When asked if you want to save your changes, answer y.

Mac OS X 10.0 through 10.12

Mac OS X 10.0 through 10.1.5

    Open /Applications/Utilities/NetInfo Manager.
    To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.
    Enter your domain user password and click OK.

    In the second column of the browser view, select the node named machines.

    The third column contains entries for -DHCP-, broadcasthost, and localhost.
    In the third column, select localhost.

    From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)

    A confirmation alert appears.

    Click Duplicate.

    A new entry called localhost copy appears, and its properties are shown below the browser view.
    Double-click the value of the ip_address property and enter the IP address of the other computer.
    Double-click the value of the name property and enter the hostname you want for the other computer.
    Click the serves property and select Delete from the Edit menu.

    From the File menu, select Save.

    A confirmation alert appears.
    Click Update this copy.
    Repeat steps 6 through 12 for each additional host entry that you want to add.

    From the NetInfo Manager menu, select Quit.

    You do not need to restart the computer.

Mac OS X 10.6 through 10.12

    Open Applications > Utilities > Terminal.

    Open the hosts file by typing the following line in the terminal window:

    sudo nano /private/etc/hosts

    Type your domain user password when prompted.

    Edit the hosts file.

    The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.
    Save the hosts file by pressing Control+x and answering y.

    Make your changes take effect by flushing the DNS cache with the following command:

    dscacheutil -flushcache

The new mappings should now take effect.
發表於 2017-11-27 06:58:04 | 顯示全部樓層

回帖獎勵 +1 元錢

回復 The_Matrix ##1 的帖子

學吓野先
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 07:05:47 | 顯示全部樓層

回帖獎勵 +1 元錢

又有嘢學
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 07:17:53 | 顯示全部樓層

回帖獎勵 +1 元錢

的确是很有用的--------------
How to modify your hosts file啊!谢谢
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 07:31:59 | 顯示全部樓層

回帖獎勵 +1 元錢

回復 The_Matrix ##1 的帖子

有用,多谢大大分享
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 07:38:48 | 顯示全部樓層

回帖獎勵 +1 元錢

这个信息很好,有用。
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 07:45:55 | 顯示全部樓層

回帖獎勵 +1 元錢

好似寫程式咁難
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 08:19:39 | 顯示全部樓層

回帖獎勵 +1 元錢

我都想學吓嘢
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 08:24:30 | 顯示全部樓層

回帖獎勵 +1 元錢

又有野學!
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 08:43:42 | 顯示全部樓層

回帖獎勵 +1 元錢

回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 10:17:05 | 顯示全部樓層

回帖獎勵 +1 元錢

回復 The_Matrix ##1 的帖子

又學到嘢,謝謝你
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 10:44:01 | 顯示全部樓層

回帖獎勵 +1 元錢

多多學習
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 10:54:16 | 顯示全部樓層

回帖獎勵 +1 元錢

睇5明
回覆 讚好 不讚 使用道具

舉報

 樓主| 發表於 2017-11-27 11:04:08 | 顯示全部樓層
回復 cegong ##10 的帖子

Hope this helps~

Windows 10,Windows 8,Windows 7和Windows Vista使用用戶帳戶控制(UAC),因此記事本必須以管理員身份運行。

對於Windows 10和8

    按下Windows鍵。
    在搜索字段中鍵入記事本。
    在搜索結果中,右鍵單擊記事本,然後選擇以管理員身份運行。
    在記事本中,打開以下文件:c:\ Windows \ System32 \ Drivers \ etc \ hosts
    對文件進行必要的更改。
    單擊文件>保存以保存您的更改。

對於Windows 7和Vista

    單擊開始>所有程序>附件。
    右鍵單擊記事本,然後選擇以管理員身份運行。
    點擊Windows上的繼續需要您的權限UAC窗口。
    當記事本打開時,單擊文件>打開。
    在“文件名”字段中,鍵入C:\ Windows \ System32 \ Drivers \ etc \ hosts
    點擊打開。
    對文件進行必要的更改。
    單擊文件>保存以保存您的更改。

Windows NT,Windows 2000和Windows XP

    單擊開始>所有程序>附件>記事本。
    單擊文件>打開。
    在“文件名”字段中,鍵入C:\ Windows \ System32 \ Drivers \ etc \ hosts
    點擊打開。
    對文件進行必要的更改。
    單擊文件>保存以保存您的更改。
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 11:28:55 | 顯示全部樓層

回帖獎勵 +1 元錢

本帖最後由 i雕刻 於 2017-11-27 11:30 編輯

good trick.. from time to time, I changed the host file for various purposes  this is a handy way to do it.  thank you
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 12:37:53 | 顯示全部樓層

回帖獎勵 +1 元錢

回復 The_Matrix ##1 的帖子

有用,多谢師兄分享
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 12:42:50 | 顯示全部樓層

回帖獎勵 +1 元錢

回復 The_Matrix ##1 的帖子

改host.......有2個情況
1) 老翻時主動改host 防止正版check s/n;
2) 畀病毒改host以誤導browser 進入陷阱網站
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 12:52:20 | 顯示全部樓層

回帖獎勵 +1 元錢

很有用的
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 14:06:33 | 顯示全部樓層

回帖獎勵 +1 元錢

又有嘢學,多謝師兄分享!
回覆 讚好 不讚 使用道具

舉報

發表於 2017-11-27 14:36:59 | 顯示全部樓層

回帖獎勵 +1 元錢

要慢慢消化先
回覆 讚好 不讚 使用道具

舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|聯絡我們|141華人社區

GMT+8, 2024-5-4 06:41

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回覆 返回頂部 返回列表