ip interview questions
Top ip frequently asked interview questions
Does anyone know of a simple way to retrieve the country for a given IP Address? Preferably in ISO_3166-1
format?
Source: (StackOverflow)
- what is the maximum value of data type INTEGER in sqlite3 ?
- How do you store ip address in database ?
- What is attached ?
- How to create table which belongs to a specific database using sql ddl?
- What is this error about ?
error while the list of system
catalogue : no such table: temp.sqlite_master
Unable to execute statement
- Does sqlite3 text data type supoports unicode?
Thanks.
Source: (StackOverflow)
I've heard it's meant to be a security feature, but it often seems like a security problem. If I want to write a server that uses a privileged port, not only do I have to worry about how secure my code is, I have to especially worry about whether I'm using setuid right and dropping privileges.
Source: (StackOverflow)
When a IP-Range is written as aaa.bbb.ccc.ddd/netmask (CIDR Notation) I need to calculate the first and the last included ip address in this range with C#.
Example:
Input: 192.168.0.1/25
Result: 192.168.0.1 - 192.168.0.126
Source: (StackOverflow)
I am newbie with regex and I want to use preg_match
function to find if a string is an IP adress.
For example if $string = "45.56.78.222"
or something like that , preg_match($regex, $string)
should return true. So, what $regex
should be?
Source: (StackOverflow)
I'm sorry if this is a repeated question but I don't completely understand how I should get a remote user IP address.
Let's say I have a simple request route such as:
app.get(/, function (req, res){
var forwardedIpsStr = req.header('x-forwarded-for');
var IP = '';
if (forwardedIpsStr) {
IP = forwardedIps = forwardedIpsStr.split(',')[0];
}
});
Is the above approach correct to get the real user IP address or is there a better way?
And what about proxies?
Source: (StackOverflow)
I understand it's a standard practice to look at both these variables. Of course they can easily be spoofed. I'm curious how often can you expect these values (especially the HTTP_X_FORWARDED_FOR
) to contain genuine information and not just be scrambled or have their values stripped away?
Anyone with the experience or statistics on this stuff?
Is there anything else that can be useful for the task of getting the client's IP address?
Source: (StackOverflow)
On a freshly installed (windows version of) MySQL 5.5.9
SELECT user, host FROM mysql.user
gives:
user host
root localhost
root 127.0.0.1
root ::1
localhost
But what IP/hostname does ::1
stand here for?
Source: (StackOverflow)
I have two domain names, two ssl certs and two ip addresses. I am trying to configure my apache virtualhost files for them.
First, i commented out all instances of "NameVirtualHost" and "Listen" for ports 80 and 443. Then i did the following with my virtual hosts files.
VirtualHost file for domain1:
NameVirtualHost 1.1.1.1:80
Listen 1.1.1.1:80
Listen 1.1.1.1:443
<VirtualHost 1.1.1.1:80>
ServerName domain1.com
...
</VirtualHost>
<VirtualHost 1.1.1.1:443>
...
</VirtualHost>
VirtualHost file for domain2:
NameVirtualHost 2.2.2.2:80
Listen 2.2.2.2:80
Listen 2.2.2.2:443
<VirtualHost 2.2.2.2:80>
ServerName domain2.com
...
</VirtualHost>
<VirtualHost 2.2.2.2:443>
...
</VirtualHost>
Source: (StackOverflow)
Possible Duplicate:
Is there an easy way to convert String to Inetaddress in Java?
I'm trying to convert a string(representing an IP address, e.g. 10.0.2.50
) into an InetAddress
obj.
According to the API it is possible to create an Object providing a String representing a hostname (e.g. www.google.ch
). This is not an option for me since I do not have the hostname for each InetAddress object I want to create(besides that it takes too long).
Is it possible to convert a String (e.g. 10.0.2.50
) into an InetAddress
obj.? (according to the api it is possible to do so if you have the IP as byte[]
, but how do I convert a String
containing an IP into byte[]
?)
Source: (StackOverflow)
So, I'm trying to get the IP-Address of my machine in my local network (which should be 192.168.178.41
).
My first intention was to use something like this:
InetAddress.getLocalHost().getHostAddress();
but it only returns 127.0.0.1
, which is correct but not very helpful for me.
I searched around and found this answer http://stackoverflow.com/a/2381398/717341, which simply creates a Socket
-connection to some web-page (e.g. "google.com") and gets the local host address from the socket:
Socket s = new Socket("google.com", 80);
System.out.println(s.getLocalAddress().getHostAddress());
s.close();
This does work for my machine (it returns 192.168.178.41
), but it needs to connect to the internet in order to work. Since my application does not require an internet connection and it might look "suspicious" that the app tries to connect to google every time it is launched, I don't like the idea of using it.
So, after some more research I stumbled across the NetworkInterface
-class, which (with some work) does also return the desired IP-Address:
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()){
NetworkInterface current = interfaces.nextElement();
System.out.println(current);
if (!current.isUp() || current.isLoopback() || current.isVirtual()) continue;
Enumeration<InetAddress> addresses = current.getInetAddresses();
while (addresses.hasMoreElements()){
InetAddress current_addr = addresses.nextElement();
if (current_addr.isLoopbackAddress()) continue;
System.out.println(current_addr.getHostAddress());
}
}
On my machine, this returns the following:
name:eth1 (eth1)
fe80:0:0:0:226:4aff:fe0d:592e%3
192.168.178.41
name:lo (lo)
It finds both my network interfaces and returns the desired IP, but I'm not sure what the other address (fe80:0:0:0:226:4aff:fe0d:592e%3
) means.
Also, I haven't found a way to filter it from the returned addresses (by using the isXX()
-methods of the InetAddress
-object) other then using RegEx, which I find very "dirty".
Any other thoughts than using either RegEx or the internet?
Source: (StackOverflow)
I am using Jekyll
and Vagrant
on my mac. I found that Jekyll server
will bind to 0.0.0.0:4000
instead of 127.0.0.1:4000
. Also gem server
will bind to this address by default. I can still visit it via http://localhost:port
. But for Jekyll
, it seems that the default setting (e.g. 0.0.0.0:4000) requires Internet access. I cannot run Jekyll server
without Internet. Is it a small bug?
I also use Vagrant
. I have set port forwarding(8080 => 4000) in Vagrantfile, since I install Jekyll
in Vagrant
virtual machine and test it under Macintosh. If I use the default setting (0.0.0.0:4000), it works. I can visit it from my safari with http://localhost:8080
. But if there is not internet, I cannot bind to 0.0.0.0:4000. I use jekyll server -H 127.0.0.1
to bind service to 127.0.0.1:4000
instead, then I cannot visit it via http://localhost:8080
.
Can anyone explain the difference between 0.0.0.0, 127.0.0.1 and localhost? And can anyone explain why the difference will cause this problem?
Source: (StackOverflow)
I was playing with sockets on local machine with no network connection. See below:
IPAddress address = IPAddress.Any; // doesn't work
IPAddress address = IPAddress.Parse("::1"); // works
So what is exactly ::1
IP address ? Is it the default available IP address or it's the loopback address ? what happens to above code (working line) on a machine with dedicated IP address and network connection ?
EDIT:
exact code is used to bind a specific IP address to socket. Here it is:
ServicePoint sp = ServicePointManager.FindServicePoint(uri);
sp.BindIPEndPointDelegate = new BindIPEndPoint(Bind);
// here's the bind delegate:
private IPEndPoint Bind(ServicePoint sp, IPEndPoint ep, int retryCount)
{
return new IPEndPoint(IPAddress.Parse("::1"), 0);
}
Source: (StackOverflow)