Windows hosts and server alias do not work - windows

I have 2 domains that are on 2 servers. (migration)
I switched to the new one in hosts file.
Records in hosts:
1.2.3.4 domain.com
1.2.3.4 alias.eu //alias is just an alias without redirect
I can ping domain.com -> 1.2.3.4 and I can open it in browser and it works.
I can ping alias.eu -> 1.2.3.4 but when I open it in a browser I get 403 forbidden.
Is it possible to have it like that? Or I have to change DNS on servers?

To clarify the question, is your web server at 1.2.3.4 responding with the same site to both hostnames ?

Related

Ansible inventory: how to identify hosts by port

I have set 2 servers for testing purposes, which are behind a NAT network. So I configured port forwarding to SSH port for both of them.
My inventory file looks like this:
[webservers]
example.com:12021
example.com:12121
[webservers:vars]
ansible_user=root
ansible_ssh_private_key_file=~/test/keys/id_ed25519
But Ansible only identifies one of them(whichever is first in the list). My "hack" to run ansible-playbook commands on both of them is by changing the order in the hostlist, and running the playbook twice.
So, is there any way to identify the hosts by port number, and not by hostname?
Thanks in advance.
Use any label you like:
[webservers]
server1 ansible_host=example.com ansible_port=12021
server2 ansible_host=example.com ansible_port=12121

cannot add new host to mac OS X

I am trying to add new entry to the /etc/hosts in mac os (el Capitan)
how ever when I try to ping this entry , I am getting error of not resolved
there is no nsswitch file
what am I missing?
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
local.datafabric.io localhost
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
In the man page for the hosts file
man hosts
the syntax is explained:
IP_address canonical_hostname [aliases...]
so, if you want to add the name local.datafabric.io as an alias for localhost (127.0.0.1), the line should look like this:
127.0.0.1 localhost local.datafabric.io
man is your friend.
You will probably also want to flush your dnscache. The correct commands for that are depending on the actual version of MacOS.

Cannot block specific websites

I've been able to block Youtube and Facebook sites, but not amazon or google. Why? Seems these two websites have something different. Thanks
Bernardos-MacBook-Pro:~ bernardo$ sudo nano /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.youtube.com
127.0.0.1 http://www.amazon.es
127.0.0.1 https://www.google.es
127.0.0.1 www.facebook.com
try it without http:// like on facebook and youtube

How to redirect a website

Within the /etc/hosts file you can block traffic via
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
# Block Adobe Activation
127.0.0.1 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 hl2rcv.adobe.com
#127.0.0.1 reddit.com
#127.0.0.1 www.reddit.com
However I want to redirect these websites to another website I have online informing the user this is blocked content
You cannot redirect to a website per se - the only think you can try is to get the ip address the website is hosted on and if the server is set to handle the request, it will work. That means it's not going to work on shared servers that has one IP.
For more sophisticated redirect, you have to use other solution.
Instead of setting those IPs to 127.0.0.1 set them to the IP of the "Sorry, blocked" server

Windows hosts file

What's the difference between these lines:
::1 localhost
...and
127.0.0.1 localhost
in Windows hosts file?
Initially I had the line of the first kind in my hosts file and typing localhost in the browser led me to 127.0.0.1. Then I didn't use localhost prompt in the browser for some time, and when I needed to use it again it just didn't work. I changed the first line form the second one in my hosts file and it worked. Why could that happen?
::1 is IPv6.
127.0.0.1 is IPv4.
::1 is IPv6
127.0.0.1 is IPv4
I guess you disabled IPv6 in between tests?
The former, "::1" is IPv6 compressed syntax for the localhost. It is equivalent to 127.0.0.1. Did you disable IPv6 support in your OS or network adapter? Maybe that's why it stopped working.
I believe ::1 is the IPV6 notation of 127.0.0.1.

Resources