Possible to get the hostname of an IP using SystemConfiguration? - objective-c

I'm using the SystemConfiguration framework to get the current IP from the dynamic store in my app.
Is it possible to get the hostname from the dynamic store as well? The current IP could be local, so I'm trying to get the returned value to be something like "mymac.local" or "2adg3.dsl.lgtpmi.sbcglobal.net", depending on how I'm connected to the net.
I tried SCDynamicStoreCopyLocalHostName(NULL), but it only returns the computer name itself (and not with the .local part), even if the IP resolves to a hostname that's accessible to everyone on the internet.

You could try
[[NSHost currentHost] names]
I just tried it and it returns all local hostnames of my machine.
Update:
This is a good blog post that fixes some NSHost issues:
http://cocoawithlove.com/2009/11/drop-in-fix-for-problems-with-nshost.html

Related

What would cause apache to redirect from a local IP to a remote IP address

Here's a scenario that I can't figure out; I simply can't understand why an slightly oldish webserver (totally inactive/powered-off for 2y) is behaving this way. I MUST be overlooking something quite simple.
Specifically, when i try to access an Apache instance on Centos 7 residing on my local network (192.168.2.XXX), the apache page responds just fine (Testing 1,2,3; Yay). Watching the access logs on this simple request shows up fine. On this same machine, I have four additional paths set up. One for example is a locked down phpMyAdmin that is accessible only from an internal IP. This route works fine, and the databases can be browsed, etc. Yet, for the other route, such as a wordpress installation or a route to a Magento instance, the the request comes up on the access log (no error log entry), and then just sits there. When the request finally times out, the URL in the browser changes to a new ip address (ABC.XXX.YYY.ZZZ), and then terminates any efforts.
Admittedly, the machine WAS originally configured to be outward facing, and my suspicion is that the IP to which the pages revert may have been the public IP last time the machine was alive. the IP is no longer associated with the site, and the domain which was likely setup with that IP address, is also no longer active.
Does anyone have any suggestions as to what I may look at? I have combed the httpd configurations and there is nothing resembling any such redirection address. Could there be some DNS data that needs to be flushed? A network configuration in sysconfig/ that I am overlooking?
It was nothing to do with my apache configuration. Everything was related to the site urls that were embedded inside the wordpress and magento installations. Upon finding and replacing all instances of the site IP address in some configuration tables, I was able to get both applications to respond properly.

How resolve ERR_CONNECTION_REFUSED

Hi guys i'm stuck with my web api. i hosted my api locally on my computer. if i request using localhost e.g http://localhost:85/api/user/getallusers it works fine.
see this image
but if i use the my local ip e.g. http://192.168.43.86:85/api/user/getallusers it returns "ERR_CONNECTION_REFUSED".
see this image using locally assigned ip
see my ipconfig result
any idea? thank you...
From this link,you can see rsplak says When you access localhost, your /etc/hosts file will tell your computer not to look any further and redirects you to your own computer. When you access the local IP adress, your computer will ask the router to fetch the data, and your router will then point back to your computer.
So it means the mapping of localhost maybe wrong in localhost(it maybe 127.0.0.1 by default).
You can change it in C:\WINDOWS\system32\drivers\etc\hosts.Change the IP to your 192.168.43.86.

How to test a coturn server?

I have tried setting up a coturn server with docker implementation with a Redis database. Now My concern is how to test this system. I tried testing it with the following
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
But when I give the IP it shows the following error
URI scheme xx.xx.xxx.xxx is not valid
I would like to know what is the right way to do this.
Thanks in advance for your time – if I’ve missed out anything, over- or under-emphasised a specific point let me know in the comments.
You need to include the scheme when specifying your STUN or TURN URI.
If the IP address of your TURN server is 192.168.0.1 you will put turn:192.168.0.1 in that input field.
See RFC 7065 for more examples!

Wrong document root after giving dedicated IP to an account

I'm trying to assign a dedicated IP to an account on my cPanel/WHM installation and I get the default cgi-sys/defaultwebpage.cgi showed when I try to access the website...
When I ping the domain on both my server and at home, I get to good IP (suppose it's 1.1.1.1).
I take a look into /var/cpanel/userdata/website.com (website.com is an example) to see if the documentroot is correctly set and also the IP. Everything is fine. (for ssl and non-ssl)
After, I take a look into the /usr/local/apache/conf/httpd.conf to see if everything was correctly configured and it's also good.
I check if the DNS zone was correctly updated and it is.
I have used WHM to assign the new IP so it should work (I have done this before and everything was fine...).
I use the latest stable version of cPanel/WHM.
When I try to access the link website.com/lol.php, it look into /usr/local/apache/htdocs/ not in /home/website/public_html ...
Also, the SSL work, but not the non-ssl (yesterday I've added a new wildcard SSL to my domain).
The problem was related to a third party product : Varnish.
I had to refresh the address pool to get it working.

Web-page redirection

I am trying to achieve the following:
when a user types "print" (or "http://print") in the address-bar of the browser :
I want the user to be re-directed to a page : www.abc.com/print/
How can one achieve this ? I tried to lookup some squid configurations but was unable to find the same.
Thanks!
Edit : I do not understand the deal with down votes, this is a perfectly valid question.
If you want to enable a user on your LAN to type "print" in the address bar and be redirected to a given hostname, you'll have to supply a DNS record to that effect. This is not accomplished on a web server, nor is it web development in any respect.
There are several methods to resolving a given hostname to a given IP or to another hostname. One way is to edit the client hosts file, as described in another answer. One could also, if you have a DNS server running within your LAN environment, add A records to this effect.
You must understand how hostname lookups work from a browser. When you type something in the address bar, your browser uses your operating system to resolve the hostname to an IP address. Your operating system uses its hosts file, internet connection, and other mechanisms to accomplish this. This process itself has several tiers and steps that are outside the scope of the browser and which cannot be influenced by the browser. Nor will arbitrary web servers be consulted in this process. Your aim is to inject something in this process that resolves the hostname "print" to the webserver of your choosing - THEN web development might come in to play.
See: http://www.quackit.com/how-websites-work/how-dns-works.cfm