Network Interface Info

/* Get Network Interface details of the Local machine */
import java.util.Collections;
import java.util.Enumeration;

public class networkParameter {
	public static void main(String args[]) throws SocketException {

		/* Collect network interface details */
		Enumeration<NetworkInterface> netInf = NetworkInterface.getNetworkInterfaces();
		for (NetworkInterface netInfo : Collections.list(netInf)) {

			/* Display network interface details */
			System.out.println("Display name: "+ netInfo.getDisplayName());
			System.out.println("Name: "+ netInfo.getName());
			Enumeration<InetAddress> ipAddresses = netInfo.getInetAddresses();
			for (InetAddress ipAddress : Collections.list(ipAddresses))
				System.out.println("IP Address: "+ inetAddress);


/* Output */
Display name: eth0
Name: eth0
IP Address: /fe80:0:0:0:eea8:6bff:fef5:1e5f%eth0
IP Address: /

Display name: lo
Name: lo
IP Address: /0:0:0:0:0:0:0:1%eth0
IP Address: /

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!