/etc/hosts ignored in mac El Capitan (10.11.5) - dns

I'm attempting to redirect an existing web address to a remote machine on my subnet. To do that, I put the following into /etc/hosts
192.168.1.249 holub.com
and flush the DNS cache with
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
However, when I ping holub.com (the most reliable way that I know to see how the address is actually resolved), I see the real web address (204.13.10.74), not the one specified in /etc/hosts (192.168.1.249). Interestingly, the mysqladmin utility does not resolve the address correctly, but the Chrome browser does resolve the address correctly. I'm guessing that Chrome has some sort of internal workaround.
In general, it looks like /etc/hosts is being used after the actual DNS lookup, not before as it should be, so an external address is not overridable.
I've tried using various IPv6 equivalents to my local address (0:0:0:0:0:ffff:c0a8:01f9 ::ffff:192.168.1.249 ::192.168.1.249), but that doesn't help. Rebooting (instead of flushing the cache) doesn't help either.
I have found one unsatisfactory workaround. If I disable the DNS reponder with
sudo launchctl unload -w
/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
then /etc/hosts is used, but then I can't access the internet.
If anybody's encountered this problem, I'd love to know if there's a workaround.

I came across this while searching for an answer to a similar problem and wanted to post my findings for anyone else in the same position.
As a team of three, we found that edits to my /etc/hosts file appeared to work, while editing the other two's host files seemingly did not. Upon further digging, we realized I was on OS X 10.10, while they were on newer versions.
We found, after trying about a million things, that additions to the hosts file in 10.11 and up apparently could not have more than one space between the IP and the domain, for example:
DID NOT WORK:
1.2.3.4 some.site.com
DID WORK:
1.2.3.4 some.site.com
After making this change, we immediately started seeing expected results without any cache clears, reboots, or otherwise.
I know in your example you are only showing one space, but in the off chance that's now how it appeared in your actual file I wanted to share this anyway.

Related

Virtual Machine with FBCTF

I'm trying FBCTF competition (https://github.com/facebook/fbctf)
My problem is that, when I try to add a base level, using a VBox machine, when I try to acces to this machine's network ip, I always get the FBCTF index.php.
Networks IP is 192.168.56.1, so I use nmap -p- -A 192.168.56.0/24 for scanning the box, but cant find the correct one.
Someone knows why? I'm missing something on the port scan?
Thank you.
Already works. FBCTF is using a NAT, so all trafic is coming to the computer is being redirected to this IP.
Removing the NAT and using Bridge, solves the problem.

I need all name servers (DNS) in linux

If there are multiple NICs on a machine, and each NIC is configured for multiple name servers, I need a list of all of them.
I have written simple java code to parse ipconfig /all in Windows (I need this in java), but getting the same information in Linux seems unclear from researching.
Some articles say "cat /etc/resolv.conf". Some say that is the old way for some distributions and to use nmcli with appropriate arguments and just parse the information.
My research has led me to believe the following is how it probably should be done:
Check of nmcli is available
Check if network-manager is on
if so, parse nmcli output
if not, parse cat /etc/resolv.conf
I am not an expert in linux, so I am seeking validation or correction here.
Thanks for answering!
EDIT: If it helps, I care about RHEL6+ and Suse 11
EDIT2: So per Suse's documentation, parsing resolv.conf seems to be sufficient because they just update the file. Still looking into RHEL.
Looks like reading resolv.conf is a safe bet for the current releases of RHEL and Suse.

When is it ok to assume /etc/hosts file will be used

This may be a bit of an open ended question, and truth be told I would prefer an exhaustive list, however, this has been bugging me for a while: When is it ok for me to assume a program will use the hostnames specified in /etc/hosts?
Will any of these programs use it?
ssh (via ~/.ssh/config) YES
dhcp (via /etc/dhcp/dhcpd.conf) YES
iptables ?
Every program which needs to map between URL and IP address (gethostbyname and such) will use /etc/hosts and DNS. The order is configurable via nsswitch.conf.

andlinux slirp network failed

I have installed andlinux Beta 2 on my WinXP. Everything works fine until last night, I don't recall that I ever changed anything on network configuration or andlinux setup, the network stop working inside andlinux. With that said, I mean open a KDE console, I do "ping yahoo.com", I see DNS is resolved correctly, however, no response at all.
My andlinux is startup as a WinXP service. Open windows task manager I can see following services are up and running:colinux-daemon.exe colinux-net-daemon.exe colinux-slirp-net-daemon.exe
On andlinux side, there are two network interface eth0 and eth1. eth1 is configured to communicate with local WinXP. I configured it to use samba to access windows directories, no problem. From WinXP side, I can use ssh to login into andlinux box via eth1 IP address.
eth0 is configured as slirp, no port forwarding. eth0 has IP=10.0.2.15, default gateway is 10.0.2.2, netmask=255.255.255.0; These are configured in /etc/network/interfaces. DNS is 10.0.2.3, which as I just mentioned resolve yahoo.com correctly.
On the windows side, internet works fine. I disabled firewall on all network interface. I rebooted my laptop, no luck. I searched over inet, seem no one has this problem. People say network is done if they kill the colinux-slirp-net-daemon. What frustrated me is that this whole thing worked well, but for no reason it's broken all the sudden. Anyone has experience on this issue, please help, appreciate!
I thought I had the same problem, but then found my andLinux system's network connectivity was actually working fine, and that several things made it difficult to tell what was going on.
Test I did to validate connectivity: wget www.yahoo.com
Behavior I observed that made troubleshooting difficult:
Pings from andLinux - not all hosts will respond to pings from the andLinux OS (ie Ubuntu, not the Host Windows OS). According to my packet captures the pings appear as UDP pings instead of ICMP pings once they leave the host OS's adapter. The major IPs/hosts (like yahoo, google, 4.2.2.2 etc.) on the internet I usually ping to test connectivity currently don't respond to these type of pings.
Traceroutes from andLinux - even when successful, these never show more than 2 hops when done from the andLinux OS. If successful, both hops show 10.0.2.2. If unsuccessful, the second hop just times out. Not sure why, I'm sure there is an explanation.
Packet captures - at the host OS level, the capture (eg wireshark) must be done on the physical interface the traffic is going over. I was initially capturing on the TAP-Win32 Adapter but this only showed X Window traffic.
Installed apt sources URLs no longer valid - Ubuntu 9.04 is long out of support by now, so the URLs in the apt sources.list file didn't exist anymore. This is what got me thrown off in the first place, because I didn't troubleshoot this specifically and just tried to test my internet connectivity first, then got confused by the ping and traceroute behavior seen above. Changed http://us.archive.ubuntu.com/ubuntu to http://old-releases.ubuntu.com/ubuntu/ in sources.list and was good to go.

JMeter - Loopback address error when launching jmeter-server on Linux

I'm trying to set up a distributed load testing environment using JMeter. I need to set up the remote clients using something portable like a Linux Live CD, but whenever I attempt to launch jmeter-server in Linux, I receive the following error...
Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:49018](local),objID:[3b0d3d42:12985b7a49b:-7fff, -8459389540436649718]]]
Server failed to start: java.rmi.RemoteException: Cannot start. testbox01.qa.nwr.lan is a loopback address.
After extensive googling, the only remedy I can find is to edit the /etc/hosts file so the hostname maps to something other than the 127.0.0.1 loopback address. I've tried this using Ubuntu, Fedora and CentOS, and apparently they all default to setting the hostname to 127.0.0.l.
The way I see it, I have four options...
1) Customize the /etc/hosts file for every remote test box I set up, which involves upwards of 20-50 dynamically DHCP-assigned IP addresses.
2) Figure out a way to force Linux itself to assign the hostname to its DHCP IP address by default. This is certainly the more graceful solution, but I have no idea how to do this. Anyone know?
3) Find and use a Linux distro available as a Live CD that doesn't map its hostname to 127.0.0.1 by default. Anyone know one?
4) Dive into JMeter's code and start yanking wires, but if it comes to this, I'd just as soon use another open source tool with a slimmer feature set, but whose distributed architecture doesn't suffer from this issue.
If anyone has any advice, I'd be grateful. Thanks!
In latest version, you can run your script with:
./jmeter-server -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
Replace xxx.xxx.xxx.xxx with this server's IP address, i.e., the IP address that the controlling jmeter machine will use to connect to this server.
Looks like Glen was right on the money with his comment.
Not sure is this helps but I found a bug which seems to contain a patch for this issue.
https://bugs.launchpad.net/ubuntu/+source/jakarta-jmeter/+bug/589042
Thanks again, Glen!
(If you decide to make it into an actual answer, I'll be sure to accept it!)
Change your hostname from localhost to your right ip address.
Check your hostname
hostname
Check your internet ip address
ifconfig
Add this line to /etc/hosts
your_ip_address your_hostname
Comment hostname which assigned localhost in /etc/hosts
I was able to get it to start after setting this environment variable:
export RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
Also have downloaded jmeter 2.8 from here: http://archive.apache.org/dist/jmeter/binaries/
Ubuntu apt-get version is 2.3.4
You can edit jmeter.server file to add:
RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
This solved mine problem.
You can try to check this page for more details.
Add RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
Add ipaddress hostname to /etc/hosts file
on my system ,/etc/hosts mentioned 127.0.0.1 hostname.
I removed 127.0.0.1 and added public Ip address

Resources