Unix/Linux/MacOSx : Get local IP address
Problem :
How to find out my MacOSX/ Linux / UNIX system ip address, subnet and related networking information from a command prompt?
Solution :
Use this command :
ifconfig
- Ifconfig is used to configure the network interfaces during boot time.
- If no arguments are given to ifconfig command it displays the status of the current active interfaces.
- It displays Ethernet IP address, Mac address, subnet mask and other information.
- ifconfig tool is available to all *nix based OS.
Example output :
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether f8:d1:11:16:ea:34
inet6 fe80::fad1:11ff:fe16:ea34%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.65 netmask 0xffffff00 broadcast 192.168.1.255
media: autoselect
status: active
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+9.3k Golang : Qt Yes No and Quit message box example
+17.1k Golang : When to use init() function?
+8.9k Golang : Get SPF and DMARC from email headers to fight spam
+13k Golang : Handle or parse date string with Z suffix(RFC3339) example
+13.4k Golang : Get user input until a command or receive a word to stop
+13.6k Golang : Tutorial on loading GOB and PEM files
+8.4k Linux/Unix : fatal: the Postfix mail system is already running
+5.2k Javascript : Change page title to get viewer attention
+7.2k Golang : Accessing dataframe-go element by row, column and name example
+33.5k Golang : How to check if slice or array is empty?
+11.9k Golang : Convert a rune to unicode style string \u
+18.8k Golang : Padding data for encryption and un-padding data for decryption