If you're setting up a new web server or another device that's going to be connected to the internet and you want to put it through its paces before it's live, or if you're having trouble with spyware and adware networks, there's an invisible file on your Mac that can help. It's called the Hosts file, and this is how to use it. The Domain Name System When you type in the domain name of a web site you want to visit there's a lot happening behind the scenes.
If not, How can I make it only access those directories in Read Only mode? If so, how can I change the locations to something acceptable for Apple. The apple guidelines say, that I can only write to ~/Library/Application Support/GameName.
Every web site, every service, almost every device connected to the Internet has a unique numeric address that tells all the other devices where it is — its TCP/IP address. The Domain Name System (DNS) translates those numeric addresses into something a bit more recognizable and memorable to humans, like, 'www.imore.com' for example. The first time you type in a web address, your Mac pings a DNS server — typically one automatically configured for you by your Internet Service Provider — to find out the TCP/IP address of the server you're trying to connect to. Your Mac builds up a hidden cache file to remember those details later on, when you visit the same site again.
The Hosts file The Domain Name System and its associated cache is your Mac's standard way of knowing how to get to where it's going on the Internet, but there's another file that can be very useful. It's called the Hosts file, and it can be used to override the default DNS information. There are some practical reasons for why you'd want to use the Hosts file instead of just letting DNS do its thing. Let's say you're testing a development server you're about to deploy, and you'd like to use its domain name instead of the machine's specific IP address. Before the system's online and accessible to anyone using DNS, you can use the Host file instead: Enter the machine's IP address and when you use that domain name, your Mac will go to that device instead.
You can also use the Hosts file to block or work around spyware and ad networks by 'zeroing out' their IP addresses - putting in 0.0.0.0 then the name of the domain you'd like to block. How to edit the Hosts file You'll need to know the IP address of the device you'd like to send your Mac to, or the domain names you're trying to keep your Mac away from. The best way to work with the Hosts file is using the Terminal application found in your Mac's Utilities folder. You can search for Terminal using or by selecting it in Finder. Open a Finder window. Select Applications from the sidebar.
Double-click on Utilities. Double-click Terminal. In the Terminal window, you will need to enter a command to open the Nano text editor. You will need your administrator password, as well. type sudo nano /etc/hosts and then hit return. Enter your administrator password and then hit return.
You're now in the Nano text editor. You should see something that looks like this. If you want to add a new device or domain, move the cursor using the arrow keys and position it after the text in the window.
Then, begin typing. If you're mapping a particular IP address on your local network to a domain, you can type the IP address, hit tab, then type the domain name. Conversely, if you'd like to make sure a web URL doesn't go to its intended site — if you're trying to keep your Mac away from certain sites, use '127.0.0.1.' That'll map it back to your Mac.
Even if your Mac is assigned a different IP address by its router, 127.0.0.1 defaults to the local machine thanks to the default settings in that hose file. Once you're done, hold down the control and O keys to save the file, then control and X to exit. One last step Back at the command line, type sudo killall -HUP mDNSResponder then type return. That will flush your Mac's DNS cache, so it doesn't get confused by any changes you've made to the Hosts file.
. Open Sharing preferences (choose Apple menu System Preferences, then click Sharing).
Select the File Sharing checkbox. To select a specific folder to share, click the Add button at the bottom of the Shared Folders list, locate the folder, select it, then click Add. The Public folder of each user with an account on your Mac is shared automatically.
To prevent a folder from being shared, select it in the Shared Folders list and click the Remove button. By default, any user set up on your Mac in Users & Groups preferences can connect to your Mac over the network. A user with an administrator account can access your entire Mac.
To give only specific users access to a folder, select the folder in the Shared Folders list, then click the Add button at the bottom of the Users list. Then do one of the following:.
Select a user from Users & Groups, which includes all the users of your Mac. Select a user from Network Users or Network Groups, which includes everyone on your network. Select a person from your contacts. Create a password for the person, then click Create Account. To specify the amount of access for a user, select the user in the Users list, click the triangles next to the user name, then choose one of the following:. Read & Write: The user can see and copy files to and from the folder.
Read Only: The user can view the contents of the folder but can’t copy files to it. Write Only (Drop Box): The user can copy files to the folder but can’t view its contents. No Access: The user can’t see or copy files from the folder. Guests can access shared folders on your Mac. To turn off guest access, deselect “Allow guests to connect to shared folders” in the Guest Account pane of Users & Groups preferences. With macOS file sharing, you can allow up to ten users to connect to your Mac at once using File Sharing. If you need to allow more than ten computers to connect to your Mac at once, use macOS Server, which is available in the App Store.