ipv4 interview questions
Top ipv4 frequently asked interview questions
Do web developers need to be concerned by the end of IPv4?
Or is this strictly a hosting level concern?
What can the average PHP/JavaScript/Ajax etc. developer do to mitigate the impact of the changeover?
Discuss!
(if this has come up before I apologies, but my search revealed nothing)
Source: (StackOverflow)
I'm looking for a function that will convert a standard IPv4 address into an Integer. Bonus points available for a function that will do the opposite.
Solution should be in C#.
Source: (StackOverflow)
I'm curious as to how fiddler is able to capture traffic when you use the URL ipv4.fiddler. Is ipv4 a special domain that resolves local and fiddler just registers with http.sys to proxy the call?
Any insight would be great.
Source: (StackOverflow)
I have created some web app using Rook
which listen to my network ip (192.168.xx.xx) at port 8000. Everyone inside my office can connect to them just typing http://192.168.xx.xx:8000/page_name
in the browser. I need to monitor these pages usage and wonder how I can get the network ip address of those connected to them.
I'm not experienced in web development and from the research done so far it seems that using client side code like JavaScript
it's very difficult (almost impossible) to achieve that, (correct me if I'm wrong). So, my question is: is there any way of getting the network client ip using server side code inside an Rook application? (If needed I'd be willing to change the web server, any solution appreciated).
Thanks and sorry in advance should my question seem confusing... in particular I'm unsure if other tags are needed.
EDIT: I would also accept answers using something different than Rook
(but still in R
)
EDIT 2:
I have set Shiny Server following this link. I'm at step of configuring the Server in order to get the access_log
that, according to @Thell, contains the information I need. In The shiny-server.conf
I have added the relative statement and now is:
run_as shiny;
server {
listen 3838;
location / {
site_dir /var/shiny-server/www;
log_dir /var/shiny-server/log;
directory_index on;
}
}
access_log /home/michelec/log.txt;
the last line should tell shiny to write the access_log into my home folder. Nothing happens however, the log remains blank. according to here, in the Formats section, I should receive one of these logs:
default ':remote-addr - - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'
short ':remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms'
tiny ':method :url :status :res[content-length] - :response-time ms'
dev concise output colored by response status for development use
depending if you leave the default format or you change it.
Source: (StackOverflow)
I'm working on an IP geolocation library that uses the first three octets of an IPv4 address to determine a user's country, city, lat, lon, etc. Works like a charm.
But it doesn't handle IPv6 addresses, and I'd like it to do so.
Is there any way to transform an IPv6 address to get the equivalent of the first three octets of an IPv4 address, or are they on an entirely different numbering scheme, requiring a completely different ipgeo mapping?
Source: (StackOverflow)
Upon receiving a UDP packet, I need to respond to the sender with the address he used to send the packet to which I'm replying.
The recvfrom
call lets me get the address of the sender, but how do I get the destination address of the received packet, which should match the address of one of the local host's interfaces?
Source: (StackOverflow)
I'm saving the user's IP addresses by saving the value of $_SERVER['REMOTE_ADDR']
in a MySQL database. Problem is that for both Firefox and Chrome $_SERVER['REMOTE_ADDR']
is ::1
(that means localhost in IPv6) and for IE and Opera is 127.0.0.1
(IPv4).
So, my questions are
Are IP versions browser-dependant? (I used to think it depended on
the computer)
Should I create two fields in the database, one for IPv4 addresses and one for IPv6 ones?
Should I unify all IPs to IPv6? And how can I do this in PHP (if it's even possible)?
Source: (StackOverflow)
Is it possible to set the IP address of an interface in Android within an application?
I can query the available interfaces and their current addresses using java.net.NetworkInterface
, but this doesn't provide a facility to change these. Did I just miss something somewhere, or is it not allowed?
I was hoping to be able to make my application either change or add an alias to one or more of the existing interfaces at runtime on an "off the shelf" device. (2.1/2.2). Ideally I'd like to do this for both IPv4 and IPv6 addresses.
Source: (StackOverflow)
This code throws an ArgumentOutOfRangeException on the last line
var initAddress = IPAddress.Parse("1.65.128.190");
var ipv6Address = initAddress.MapToIPv6();
Assert.IsTrue(ipv6Address.IsIPv4MappedToIPv6);
var ipv4Address = ipv6Address.MapToIPv4();
Can anyone explain why MapToIPv6() and MapToIPv4() are not round trip compatible?
edit: The exception originates from the IPAddress constructor, called by MapToIPv4().
Also, when the first line is
var initAddress = IPAddress.Parse("1.65.128.90");
no exceptions are thrown anymore
edit2: as @Luaan reproduced this, I added the tag [bug-reporting]. Also added [bcl]. Let's see if any MS personnel tracks those tags :)
edit3: reported at Connect https://connect.microsoft.com/VisualStudio/feedback/details/871964
Source: (StackOverflow)
I would like to know the possible values of st
column in /proc/net/tcp
. I think the st
column equates to STATE column from netstat(8)
or ss(8)
.
I have managed to identify three codes:
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 0100007F:08A0 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7321 1 ffff81002f449980 3000 0 0 2 -1
1: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 6656 1 ffff81003a30c080 3000 0 0 2 -1
2: 00000000:0272 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 6733 1 ffff81003a30c6c0 3000 0 0 2 -1
3: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7411 1 ffff81002f448d00 3000 0 0 2 -1
4: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7520 1 ffff81002f4486c0 3000 0 0 2 -1
5: 0100007F:089F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 7339 1 ffff81002f449340 3000 0 0 2 -1
6: 0100007F:E753 0100007F:0016 01 00000000:00000000 02:000AFA92 00000000 500 0 18198 2 ffff81002f448080 204 40 20 2 -1
7: 0100007F:E752 0100007F:0016 06 00000000:00000000 03:000005EC 00000000 0 0 0 2 ffff81000805dc00
The above shows:
- On line sl 0: a listening port on tcp/2208.
st = 0A = LISTEN
- On line s1 6: An established session on tcp/22.
st = 01 = ESTABLISHED
- On line sl 7: An socket in TIME_WAIT state after ssh logout. No inode.
st = 06 = TIME_WAIT
Can anyone expand on this list? The proc(5)
manpage is quite terse on the subject stating:
/proc/net/tcp
Holds a dump of the TCP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local address" is the local address and
port number pair. The "remote address" is the remote address and port number pair (if connected). ’St’ is the internal status of the socket. The ’tx_queue’ and ’rx_queue’ are the outgoing and incom-
ing data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields hold internal information of the kernel socket state and are only useful for debugging. The "uid" field
holds the effective UID of the creator of the socket.
And on a related note, the above /proc/net/tcp output is showing a few listening processes (2208, 62, 111 etc). However, I cannot see a listening tcp connection on tcp/22, althought the established and time_wait states are shown. Yes, I can see them in /proc/net/tcp6
but should they not be present in /proc/net/tcp
also? Netstat output shows it differently to applications bound only to ipv4. E.g.
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 4231/portmap
tcp 0 0 :::22 :::* LISTEN 4556/sshd
Many thanks,
-Andrew
Source: (StackOverflow)
How do I get only Internet Protocol version 4 addresses from Dns.GetHostAddresses()
? I have the code below, and it gives me IPv4 and IPv6 addresses.
I have to make it work with boxes that have multiple IPv4 addresses.
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
private void get_IPs()
{
foreach (IPAddress a in localIPs)
{
server_ip = server_ip + a.ToString() + "/";
}
}
Source: (StackOverflow)
In Oracle, what is the appropriate data type or technique for representing network addresses, which addresses may be IPv4 or IPv6?
Background: I'm converting a table recording network activity, built using the PostgreSQL inet
data type to hold both v4 and v6 addresses in the same table.
No row contains both v4 and v6 addresses, however. (That is, a record is either from a machine's v4 stack, or a machine's v6 stack.)
Source: (StackOverflow)
Yes, I am needing to know what the total number possible IPs in the public IPv4 space.
I'm not sure where to even get a neat list of all the IP address ranges, so could someone point me to a resource to calculate this myself or calculate the total number of IPs for me?
Also, by Public IPs I mean not counting reserved or private-range IP addresses.. Only the ones that can be access through the internet.
Source: (StackOverflow)
I'm trying to understand what the getaddrinfo function returns :
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
int main (int argc, char *argv[])
{
struct addrinfo *res = 0 ;
getaddrinfo("localhost", NULL ,NULL,&res);
printf("ai_flags -> %i\n", res->ai_flags) ;
printf("ai_family -> %i\n", res->ai_family) ;
printf("ai_socktype -> %i\n", res->ai_socktype) ;
printf("ai_protocol -> %i\n", res->ai_protocol) ;
printf("ai_addrlen -> %i\n", res->ai_addrlen) ;
struct sockaddr_in* saddr = (struct sockaddr_in*)res->ai_addr;
printf("ai_addr hostname -> %s\n", inet_ntoa(saddr->sin_addr));
freeaddrinfo(res);
return 0 ;
}
results :
ai_flags -> 40
ai_family -> 2
ai_socktype -> 1
ai_protocol -> 6
ai_addrlen -> 16
ai_addr hostname -> 127.0.0.1
In /etc/hosts, I 've got :
127.0.0.1 localhost
::1 localhost
Getaddrinfo returns only 127.0.0.1 and not ::1 ? I don't understand why ?
The second question is where can I find the meaning of those ints (40,2,1,6 etc) ? I've read the man but there is nothing about that.
I also wanted to know if it's possible to give a IPv6 adress (for example ::1) and the function returns the name : localhost ?
Thanks a lot !!
Source: (StackOverflow)
Over the years I've developed a small mass of C++ server/client applications for Windows using WinSock (Routers, Web/Mail/FTP Servers, etc... etc...).
I’m starting to think more and more of creating an IPv6 version of these applications (While maintaining the original IPv4 version as well, of course).
Questions:
- What pitfalls might I run into?
- Is the porting/conversion difficult?
- Is the conversion worth it?
For a reference (or for fun), you can sneek a peak of the IPv4 code at the core of my applications.
Source: (StackOverflow)