Bind the ip adresses with the hosts using socat command - proxy

I have squid proxy installed in my server, and I want to bind the ip adresses with the hosts I want to connect to them.
How can I do it with socat command?
Example :
prox_IP : 1.1.1.1
proxy_port : 1111
host_to_connect: 2.2.2.2
port_to connect: 2222
How can I connect to 2.2.2.2:2222 connect like my address IP is 1.1.1.1:1111?

Related

mongod Failed to obtain address information for hostname OS X

Having an issue starting mongo using mongod --dbpath. I get the following error:
NETWORK [HostnameCanonicalizationWorker] Failed to obtain address information for hostname ##########: nodename nor servname provided, or not known
Host name only has latin characters. I've tried multiple networks, deleted all DNS entries, confirmed my /etc/hosts looks fine and now I'm at a standstill.
Here is my /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
Try enabling the ipv6 and restart the mongod server
::1 localhost
I followed the answer in this JIRA ticket.
And here is my /etc/hosts file.
1 ##
2 # Host Database
3 #
4 # localhost is used to configure the loopback interface
5 # when the system is booting. Do not change this entry.
6 ##
7 # 127.0.0.1 localhost
8 127.0.0.1 localhost localhost.localdomain
9 255.255.255.255 broadcasthost
10 # ::1 localhost
change your HOSTNAME in /etc/sysconfig/network likes:
HOSTNAME=Steven
Then change your hostname in /etc/hosts:
127.0.0.1 localhost localhost.localdomain ...............
to
127.0.0.1 localhost Steven ...............

Accessing vagrant on port 80 locally on mac

I'm trying run vagrant on port 80 locally. In the Vagrant file I have tried the following two things, which does not work. When I go to localhost or 127.0.0.1 in the browser the page will load for a while and then eventually redirect to port 8080 with a "This webpage is not available" error...
config.trigger.after [:provision, :up, :reload] do
system('echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef - >/dev/null 2>&1;'
)
end
config.trigger.after [:provision, :up, :reload] do
system('echo "
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080
" | sudo pfctl -ef - > /dev/null 2>&1;')
end
(I did install the vagrant-triggers plugin. I'm on a Mac 10.10.5)
What seems to be missing?

Windows hosts and server alias do not work

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 ?

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