IP Address : An IP address, short for Internet Protocol address, is an identifying number for a piece of network hardware. Having an IP address allows a device to communicate with other devices over an IP-based network like the internet.
Subnet mask: A subnet mask is a 32-bit number used to differentiate the network component of an IP address by dividing the IP address into a network address and host address.Subnet masks are used to design subnetworks, or subnets, that connect local networks and determine what subnet an IP address belongs to.
Default Gateway: A default gateway serves as an access point or IP router that a networked computer uses to send information to a computer in another network or the Internet.Default simply means that this gateway is used by default, unless an application specifies another gateway.A default gateway allows computers on a network to communicate with computers on another network. Without it, the network is isolated from the outside.
Using system command
To get the IP Address, Subnet Mask and Default Gateway, we execute ipconfig command in the cmd.Here, we will make use of system() from < stdlib.h > to perform a system operation with the help of a C program:
Using execl command
This displays the IPv4 address, Subnet Mask and the Default Gateway.The same operation can also be performed with the execl() function.To execute the later, we code:
This article is contributed by Amaryta Ranjan Saikia. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Finding Network ID of a Subnet (using Subnet Mask)
- Introduction of Variable Length Subnet Mask (VLSM)
- Role of Subnet Mask
- Fixed Length and Variable Length Subnet Mask Numericals
- Difference Between Network Address Translation (NAT) and Port Address Translation (PAT)
- Difference between MAC Address and IP Address
- IPv4 Classless Subnet equation
- Features of Enhanced Interior Gateway Routing Protocol (EIGRP)
- Gateway Load Balancing Protocol (GLBP)
- Common Gateway Interface (CGI)
- Border Gateway Protocol (BGP)
- Difference between Bridge and Gateway
- Exterior Gateway Protocol (EGP)
- Difference between Router and Gateway
- Difference between Switch and Gateway
- Difference between Border Gateway Protocol (BGP) and Routing Information Protocol (RIP)
- Java program to find IP address of your computer
- Does C++ compiler create default constructor when we write our own?
- What are the default values of static variables in C?
- C++ Internals | Default Constructors | Set 1