如何修改HOSTS文件访问一个固定的站
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何修改HOSTS文件访问一个固定的站相关的知识,希望对你有一定的参考价值。
公司网站托管到外网去了,内网机器不好上网,如何让内网机器访问原来的网站服务器直接访问到现在新的外网的网站,可以上网的机器是通过域名访问的,听别人说可以修改HOSTS文件实现,请高手帮忙
内网机器不能上网怎么改你也访问不了,除非你的服务器是双网卡,你在hosts文件里指定网址是内网IPhosts文件在c:\windows\systen32\drivers\etc里面
后面加一行,格式是网址 IP
比如说www.xxx.com 218.123.123.123 参考技术A hosts文件在c:\windows\systen32\drivers\etc,找到后用记事本打开.
输入格式为:(我用例子来说明,其他的类似)
127.0.0.1 www.baidu.com
127.0.0.1 www.sina.com
上面的例子意思是,当在浏览器里输入www.baidu.com或则是www.sina.com 时,网页就自动转向loaclhost页面了
hosts 文件只能对所在的主机有用!如果你有10台电脑,那就要把编辑好的hosts文件复制到10台电脑上!!!
希望能帮助到你!!!
Google无法访问,修改hosts文件
<>更新 hosts
- 下面介绍的操作均可能覆盖现有 hosts ,进行操作前请先确认是否需要备份。
-
推荐使用本项目的 Host Tools 来自动化 备份/配置 工作。
-
若更新 hosts 未立即生效,请重置网络:
- 在系统设置内开关网络
- 启用禁用飞行模式
- 重启系统
Windows
用文本编辑器(如 Notepad++)打开文件:
C:\Windows\System32\drivers\etc\hosts
将 hosts 全部内容复制到上述文件内并保存
注意:如果遇到无法保存,请右键文件hosts并找到“属性” -> “安全”,然后选择你登陆的用户名,最后点击编辑,勾选“写入”即可。
Linux
将 hosts 全部内容复制到/etc/hosts
中并保存。
或开启终端(快捷键为Ctrl + Alt + T)输入命令:
wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -qO /tmp/hosts && sudo sh -c ‘cat /tmp/hosts > /etc/hosts‘
Mac OS
将 hosts 全部内容复制到 /etc/hosts
中并保存。
Android
将 hosts 全部内容复制到 /etc/hosts
中并保存。
iOS
将 hosts 全部内容复制到 /etc/hosts
中并保存。
更多
获取更多信息,请访问 Wiki 页面 。如有问题,请开 Issue 反馈。
License
- 本项目的所有代码除另有说明外,均按照 MIT License 发布。
- 本项目的hosts,README.MD,wiki等资源基于CC BY-NC-SA 4.0 这意味着你可以拷贝、并再发行本项目的内容,但是你将必须同样提供原作者信息以及协议声明。同时你也不能将本项目用于商业用途, 按照我们狭义的理解(增加附属条款),凡是任何盈利的活动皆属于商业用途。
- 请在遵守当地相关法律法规的前提下使用本项目。
可以先将自己电脑下的C:\Windows\System32\drivers\etc\hosts文件备份,然后将如下内容添加到hosts中:
# Copyright (c) 2014-2016, racaljk. # https://github.com/racaljk/hosts # Last updated: 2016-05-22 # This work is licensed under a CC BY-NC-SA 4.0 International License. # https://creativecommons.org/licenses/by-nc-sa/4.0/ # Localhost (DO NOT REMOVE) 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost # Modified hosts start # Amazon AWS Start 27.0.1.125 ap-northeast-1.console.aws.amazon.com 54.240.226.19 ap-southeast-1.console.aws.amazon.com 54.240.195.197 ap-southeast-2.console.aws.amazon.com 176.32.100.36 aws.amazon.com 72.21.194.168 console.aws.amazon.com 54.239.54.107 eu-central-1.console.aws.amazon.com 178.236.4.251 eu-west-1.console.aws.amazon.com 54.231.66.16 s3.amazonaws.com 54.231.229.10 s3-ap-northeast-1.amazonaws.com 54.231.242.150 s3-ap-southeast-1.amazonaws.com 54.231.252.130 s3-ap-southeast-2.amazonaws.com 72.21.203.5 s3-console-us-standard.console.aws.amazon.com 54.231.192.41 s3-eu-central-1.amazonaws.com 54.231.132.112 s3-eu-west-1.amazonaws.com 54.231.253.78 s3-sa-east-1.amazonaws.com 54.231.237.85 s3-us-west-1.amazonaws.com 54.231.160.48 s3-us-west-2.amazonaws.com 177.72.244.68 sa-east-1.console.aws.amazon.com 204.246.162.198 us-west-1.console.aws.amazon.com 54.240.250.61 us-west-2.console.aws.amazon.com 54.231.34.41 github-cloud.s3.amazonaws.com 54.231.48.40 github-com.s3.amazonaws.com # Amazon AWS End # Archive Start 207.241.224.22 archive.org 207.241.226.190 web.archive.org # Archive End # Battle.NET Start 12.129.206.133 enUS.patch.battle.net 208.111.148.7 llnw.blizzard.com 121.254.200.133 zhTW.patch.battle.net # Battle.NET End # Box.com Start 74.112.184.70 app.box.com 74.112.184.90 box.com 74.112.184.85 m.box.com 104.218.203.34 support.box.com 74.112.184.85 www.box.com 74.112.184.80 www.box.net # Box.com End # BundleStars Start 23.253.146.21 bundlestars.com 54.192.232.60 cdn-images.bundlestars.com 185.12.83.2 support.bundlestars.com # BundleStars End # DuckDuckGo Start 46.51.216.186 duckduckgo.com 46.51.216.186 www.duckduckgo.com 46.51.216.186 ac.duckduckgo.com 54.251.178.52 icons.duckduckgo.com 54.251.178.52 images.duckduckgo.com 96.45.83.209 help.duckduckgo.com # DuckDuckGo End # Facebook start 173.252.81.7 fb.me 173.252.81.7 facebook.com 173.252.81.7 www.facebook.com 173.252.81.7 m.facebook.com 173.252.81.7 mqtt.facebook.com 173.252.81.7 s-static.ak.facebook.com 173.252.81.7 profile.ak.facebook.com 173.252.81.7 static.ak.facebook.com 173.252.81.7 b.static.ak.facebook.com 173.252.81.7 graph.facebook.com 173.252.81.7 ssl.facebook.com 173.252.81.7 api.facebook.com 173.252.81.7 secure-profile.facebook.com 173.252.81.7 secure.facebook.com 173.252.81.7 zh-cn.facebook.com 173.252.81.7 login.facebook.com #50.63.202.88 message-facebook.com 173.252.81.7 attachments.facebook.com 173.252.81.7 touch.facebook.com 173.252.81.7 apps.facebook.com 173.252.81.7 upload.facebook.com 173.252.81.7 developers.facebook.com 173.252.81.7 act.channel.facebook.com 173.252.81.7 0-act.channel.facebook.com 173.252.81.7 1-act.channel.facebook.com 173.252.81.7 2-act.channel.facebook.com 173.252.81.7 3-act.channel.facebook.com 173.252.81.7 4-act.channel.facebook.com 173.252.81.7 5-act.channel.facebook.com 173.252.81.7 6-act.channel.facebook.com 173.252.81.7 inyour-slb-01-05-ash3.facebook.com 173.252.81.7 origincache-starfacebook-ai-01-05-ash3.facebook.com 173.252.81.7 beta-chat-01-05-ash3.facebook.com 173.252.81.7 channel-ecmp-05-ash3.facebook.com 173.252.81.7 channel-staging-ecmp-05-ash3.facebook.com 173.252.81.7 channel-testing-ecmp-05-ash3.facebook.com 173.252.81.7 0-edge-chat.facebook.com 173.252.81.7 1-edge-chat.facebook.com 173.252.81.7 2-edge-chat.facebook.com 173.252.81.7 3-edge-chat.facebook.com 173.252.81.7 4-edge-chat.facebook.com 173.252.81.7 5-edge-chat.facebook.com 173.252.81.7 6-edge-chat.facebook.com 173.252.81.7 api-read.facebook.com 173.252.81.7 bigzipfiles.facebook.com 173.252.81.7 check4.facebook.com 173.252.81.7 check6.facebook.com 173.252.81.7 code.facebook.com 31.13.95.14 connect.facebook.com 173.252.81.7 edge-chat.facebook.com 173.252.81.7 pixel.facebook.com 173.252.81.7 star.c10r.facebook.com 173.252.81.7 star.facebook.com 173.252.81.7 zh-tw.facebook.com 173.252.81.7 b-api.facebook.com 173.252.81.7 b-graph.facebook.com 173.252.81.7 orcart.facebook.com 173.252.81.7 s-static.facebook.com 173.252.81.7 vupload.facebook.com 173.252.81.7 vupload2.vvv.facebook.com 173.252.81.7 d.facebook.com 23.63.99.242 fbexternal-a.akamaihd.net 23.67.255.208 fbcdn-creative-a.akamaihd.net 23.63.99.186 fbcdn-video-a-a.akamaihd.net 23.63.99.171 fbcdn-video-b-a.akamaihd.net 23.63.99.120 fbcdn-video-c-a.akamaihd.net 23.63.99.144 fbcdn-video-d-a.akamaihd.net 23.63.99.131 fbcdn-video-e-a.akamaihd.net 23.63.99.160 fbcdn-video-f-a.akamaihd.net 23.63.99.171 fbcdn-video-g-a.akamaihd.net 23.63.99.130 fbcdn-video-h-a.akamaihd.net 23.63.99.145 fbcdn-video-i-a.akamaihd.net 23.63.99.178 fbcdn-video-j-a.akamaihd.net 23.63.99.201 fbcdn-video-k-a.akamaihd.net 23.63.99.170 fbcdn-video-l-a.akamaihd.net 23.63.99.136 fbcdn-video-m-a.akamaihd.net 23.63.99.169 fbcdn-video-n-a.akamaihd.net 23.63.99.171 fbcdn-video-o-a.akamaihd.net 23.63.99.144 fbcdn-video-p-a.akamaihd.net 23.63.99.123 fbcdn-vthumb-a.akamaihd.net 77.67.4.11 fbcdn-sphotos-a-a.akamaihd.net 77.67.4.64 fbcdn-sphotos-b-a.akamaihd.net 77.67.4.74 fbcdn-sphotos-c-a.akamaihd.net 77.67.4.73 fbcdn-sphotos-d-a.akamaihd.net 77.67.4.74 fbcdn-sphotos-e-a.akamaihd.net 77.67.4.10 fbcdn-sphotos-f-a.akamaihd.net 23.63.99.56 fbcdn-sphotos-g-a.akamaihd.net 23.63.99.88 fbcdn-sphotos-h-a.akamaihd.net 2.16.162.11 fbcdn-profile-a.akamaihd.net 72.246.188.82 fbcdn-photos-a.akamaihd.net 72.246.188.19 fbcdn-photos-e-a.akamaihd.net 23.205.168.10 fbcdn-sphotos-a.akamaihd.net 23.63.99.209 fbstatic-a.akamaihd.net 173.252.81.7 fbcdn.net 31.13.95.14 video.xx.fbcdn.net 183.111.23.18 scontent.xx.fbcdn.net 183.111.23.18 scontent-a.xx.fbcdn.net 183.111.23.18 scontent-b.xx.fbcdn.net 183.111.23.18 scontent-c.xx.fbcdn.net 183.111.23.18 scontent-d.xx.fbcdn.net 183.111.23.18 scontent-e.xx.fbcdn.net 183.111.23.18 scontent-mxp.xx.fbcdn.net 183.111.23.18 scontent-a-lax.xx.fbcdn.net 183.111.23.18 scontent-a-sin.xx.fbcdn.net 183.111.23.18 scontent-b-lax.xx.fbcdn.net 183.111.23.18 scontent-b-sin.xx.fbcdn.net 184.28.188.240 vthumb.ak.fbcdn.net 184.28.188.152 photos-a.ak.fbcdn.net 184.28.188.154 photos-b.ak.fbcdn.net 184.28.188.171 photos-c.ak.fbcdn.net 184.28.188.171 photos-d.ak.fbcdn.net 184.28.188.153 photos-e.ak.fbcdn.net 184.28.188.153 photos-f.ak.fbcdn.net 184.28.188.171 photos-g.ak.fbcdn.net 184.28.188.146 photos-h.ak.fbcdn.net 184.28.188.171 creative.ak.fbcdn.net 184.28.188.153 external.ak.fbcdn.net 184.28.188.153 b.static.ak.fbcdn.net 184.28.188.153 static.ak.fbcdn.net 184.28.188.153 origincache-ai-01-05-ash3.fbcdn.net 183.111.23.18 profile.ak.fbcdn.net 183.111.23.18 vpn.tfbnw.net 183.111.23.18 ent-a.xx.fbcdn.net 183.111.23.18 ent-b.xx.fbcdn.net 183.111.23.18 ent-c.xx.fbcdn.net 183.111.23.18 ent-d.xx.fbcdn.net 183.111.23.18 ent-e.xx.fbcdn.net 23.207.122.24 s-external.ak.fbcdn.net 23.34.45.177 s-static.ak.fbcdn.net 173.252.81.7 static.thefacebook.com # 192.168.52.23 ldap.thefacebook.com 173.252.81.7 attachment.fbsbx.com 104.78.23.174 connect.facebook.net # Facebook end # FlipBoard start 54.225.64.251 beacon.flipboard.com 54.225.64.251 fbprod.flipboard.com # FlipBoard End # Twitter Start 104.244.42.1 twitter.com 104.244.42.1 www.twitter.com 104.244.42.197 t.co 104.244.42.2 api.twitter.com 104.244.42.6 mobile.twitter.com 104.244.42.7 support.twitter.com 104.244.42.11 upload.twitter.com 104.244.42.132 tweetdeck.twitter.com 104.244.42.136 syndication.twitter.com 104.244.42.136 syndication-o.twitter.com 104.244.42.3 platform.twitter.com 104.244.42.3 about.twitter.com 104.244.42.3 blog.twitter.com 104.244.42.3 p.twitter.com 104.244.42.3 betastream.twitter.com 104.244.42.3 dev.twitter.com 104.244.42.3 pic.twitter.com 104.244.42.3 search.twitter.com 104.244.42.3 status.twitter.com 104.244.42.3 assets0.twitter.com 104.244.42.3 assets1.twitter.com 104.244.42.3 assets2.twitter.com 104.244.42.3 assets3.twitter.com 104.244.42.3 static.twitter.com 104.244.42.3 help.twitter.com 104.244.42.3 ton.twitter.com 104.244.42.3 s.twitter.com 104.244.42.3 analytics.twitter.com 104.244.42.3 urls-real.api.twitter.com 104.244.42.3 userstream.twitter.com 104.244.42.3 sitestream.twitter.com 104.244.42.3 stream.twitter.com 104.244.42.3 tdweb.twitter.com 173.236.110.98 twitpic.com 173.236.110.98 m1.twitpic.com 173.236.110.98 web1.twitpic.com 173.236.110.98 web10.twitpic.com 173.236.110.98 web2.twitpic.com 173.236.110.98 web3.twitpic.com 173.236.110.98 web4.twitpic.com 173.236.110.98 web5.twitpic.com 173.236.110.98 web6.twitpic.com 173.236.110.98 web7.twitpic.com 173.236.110.98 web8.twitpic.com 173.236.110.98 web9.twitpic.com 209.17.68.209 oi40.tinypic.com 209.17.68.209 oi41.tinypic.com 209.17.68.209 oi42.tinypic.com 209.17.68.209 oi43.tinypic.com 209.17.68.209 oi44.tinypic.com 209.17.68.209 oi45.tinypic.com 209.17.68.209 oi46.tinypic.com 209.17.68.209 oi47.tinypic.com 209.17.68.209 oi48.tinypic.com 209.17.68.209 oi49.tinypic.com 209.17.68.209 oi50.tinypic.com 209.17.68.209 oi51.tinypic.com 209.17.68.209 oi52.tinypic.com 209.17.68.209 oi53.tinypic.com 209.17.68.209 oi54.tinypic.com 209.17.68.209 oi55.tinypic.com 209.17.68.209 oi56.tinypic.com 104.244.43.199 a0.twimg.com 104.244.43.199 a1.twimg.com 104.244.43.199 video.twimg.com 104.244.43.199 abs.twimg.com 104.244.43.199 g.twimg.com 104.244.43.199 o.twimg.com 104.244.43.199 p.twimg.com 104.244.43.199 r.twimg.com 104.244.43.199 ma.twimg.com 104.244.43.199 pbs.twimg.com 104.244.43.199 si0.twimg.com 104.244.43.199 si1.twimg.com 104.244.43.199 si2.twimg.com 104.244.43.199 si3.twimg.com 104.244.43.199 si4.twimg.com 104.244.43.199 si5.twimg.com 104.244.43.199 ton.twimg.com 104.244.43.199 syndication.twimg.com 104.244.43.199 syndication-o.twimg.com 104.244.43.199 image-proxy-origin.twimg.com 104.244.43.199 si0.twimg.co 104.244.43.199 si1.twimg.co 104.244.43.199 si2.twimg.co 104.244.43.199 si3.twimg.co 104.244.43.199 si4.twimg.co 104.244.43.199 si5.twimg.co 104.244.42.132 tweetdeck.com 104.244.42.132 api.tweetdeck.com 104.244.42.132 web.tweetdeck.com 104.244.42.132 www.tweetdeck.com 104.244.42.132 downloads.tweetdeck.com 104.244.42.136 cdn.syndication.twimg.com 104.244.42.136 cdn.syndication.twitter.com 104.244.42.2 cdn.api.twitter.com 104.244.42.1 preview.cdn.twitter.com # Twitter End # Gmail web Start 220.255.2.153 chatenabled.mail.google.com 220.255.2.153 filetransferenabled.mail.google.com 220.255.2.153 gmail.com 220.255.2.153 gmail.google.com 220.255.2.153 googlemail.l.google.com 220.255.2.153 inbox.google.com 220.255.2.153 isolated.mail.google.com 220.255.2.153 m.gmail.com 220.255.2.153 m.googlemail.com 220.255.2.153 mail.google.com 220.255.2.153 www.gmail.com 220.255.2.153 mail-settings.google.com # Gmail web End # Google Start 220.255.2.153 www.google.com 220.255.2.153 google.com 220.255.2.153 gcr.io 220.255.2.153 www.gcr.io 220.255.2.153 com.google 220.255.2.153 admin.google.com 220.255.2.153 accounts.google.com 220.255.2.153 aboutme.google.com 220.255.2.153 passwords.google.com 220.255.2.153 bpui0.google.com 220.255.2.153 cse.google.com 220.255.2.153 clients1.google.com 220.255.2.153 clients2.google.com 220.255.2.153 clients3.google.com 220.255.2.153 clients4.google.com 220.255.2.153 clients5.google.com 220.255.2.153 clients6.google.com 220.255.2.153 clients7.google.com 220.255.2.153 contributor.google.com 220.255.2.153 desktop.google.com 220.255.2.153 desktop2.google.com 220.255.2.153 encrypted.google.com 220.255.2.153 encrypted-tbn0.google.com 220.255.2.153 encrypted-tbn1.google.com 220.255.2.153 encrypted-tbn2.google.com 220.255.2.153 encrypted-tbn3.google.com 220.255.2.153 fi.google.com 220.255.2.153 goto.google.com 220.255.2.153 gxc.google.com 220.255.2.153 history.google.com 220.255.2.153 investor.google.com 220.255.2.153 jmt0.google.com 220.255.2.153 keep.google.com 220.255.2.153 linkhelp.clients.google.com 220.255.2.153 upload.clients.google.com 220.255.2.153 myaccount.google.com 220.255.2.153 peering.google.com 220.255.2.153 places.google.com 220.255.2.153 pki.google.com 220.255.2.153 script.google.com 220.255.2.153 security.google.com 220.255.2.153 services.google.com 220.255.2.153 store.google.com 220.255.2.153 suggestqueries.google.com 220.255.2.153 support.google.com 220.255.2.153 upload.google.com 220.255.2.153 uploads.clients.google.com 220.255.2.153 uploads.client.google.com 220.255.2.153 upload.client.google.com 220.255.2.153 video.google.com 220.255.2.153 video-stats.video.google.com 220.255.2.153 voice.google.com 220.255.2.153 upload.video.google.com 220.255.2.153 vp.video.google.com 220.255.2.153 ads.google.com 220.255.2.153 www.googlegroups.com 220.255.2.153 a.orkut.gmodules.com 220.255.2.153 www.googlestore.com 220.255.2.153 ig.ig.gmodules.com 220.255.2.153 redirector.c.youtube.com 220.255.2.153 relay.google.com 220.255.2.153 image.google.com 220.255.2.153 mapsengine.google.com 220.255.2.153 client-channel.google.com 220.255.2.153 0.client-channel.google.com 220.255.2.153 1.client-channel.google.com 220.255.2.153 2.client-channel.google.com 220.255.2.153 3.client-channel.google.com 220.255.2.153 4.client-channel.google.com 220.255.2.153 5.client-channel.google.com 220.255.2.153 6.client-channel.google.com 220.255.2.153 7.client-channel.google.com 220.255.2.153 8.client-channel.google.com 220.255.2.153 9.client-channel.google.com 220.255.2.153 10.client-channel.google.com 220.255.2.153 11.client-channel.google.com 220.255.2.153 12.client-channel.google.com 220.255.2.153 13.client-channel.google.com 220.255.2.153 14.client-channel.google.com 220.255.2.153 15.client-channel.google.com 220.255.2.153 16.client-channel.google.com 220.255.2.153 17.client-channel.google.com 220.255.2.153 18.client-channel.google.com 220.255.2.153 19.client-channel.google.com 220.255.2.153 20.client-channel.google.com 220.255.2.153 21.client-channel.google.com 220.255.2.153 22.client-channel.google.com 220.255.2.153 23.client-channel.google.com 220.255.2.153 24.client-channel.google.com 220.255.2.153 25.client-channel.google.com 220.255.2.153 26.client-channel.google.com 220.255.2.153 27.client-channel.google.com 220.255.2.153 28.client-channel.google.com
以上是关于如何修改HOSTS文件访问一个固定的站的主要内容,如果未能解决你的问题,请参考以下文章
命令行修改文件文件夹访问权限 cacls, 修改hosts内容方法