Hot answers tagged

168

Use ipconfig getifaddr en1 for wireless, or ipconfig getifaddr en0 for ethernet. Update: ipconfig getifaddr en0 is default for wifi interface.


98

The following works for me on 10.8 and on 10.10 Yosemite. ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' If you find the above gives you more than one answer, save the following to a script, and run it instead ip_address.sh #!/usr/bin/env bash dumpIpForInterface() { IT=$(ifconfig "$1") if [[ "$IT" != *"status: active"* ]]; then ...


79

To forward all port 80 traffic to port 8080, you can enter the following from the Terminal command line. echo " rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080 " | sudo pfctl -ef - Taken from https://salferrarello.com/mac-pfctl-port-forwarding/


43

Just type curl ifconfig.me in the terminal.


39

Your computers should be accessible as computer-name.local, e.g. Kens-Computer.local or something like that, so depending on what you're trying to do, you might be able to just use that name rather than the IP. So you can just type vnc://Kens-Computer.local in the 'Connect to' window. You can see the computer's network name if you go to the Sharing ...


36

The modern way to forward ports in El Capitan is using pf. In the example below all port 80 requests are forwarded to port 8080 on the same host. Please adjust the redirections to your needs. Create an anchor file org.user.forwarding in /private/etc/pf.anchors sudo touch /private/etc/pf.anchors/org.user.forwarding with the following content and a ...


35

Use the built-in CUPS web interface to get detailed printer information: http://localhost:631/printers/ On newer versions of macOS you'll need to run the following command to enable the web interface: cupsctl WebInterface=yes


25

You can do this without having to install any additional apps or software. Just use the command curl and the free geo ip website http://freegeoip.app. Execute the following command in Terminal (I am using Apple's IP for this example): curl https://freegeoip.app/xml/17.178.96.59 You will get your results in an XML format: <Response> <IP>...


19

I've got this set up in an .aliases dotfile for frequent ip lookup: alias ip="dig +short myip.opendns.com @resolver1.opendns.com" alias localip="ipconfig getifaddr en0"


19

I have found it myself. It's already built in in OS X. In System Preferences, goto Network and at the top of the window, you can see a combobox which says: Location. You have to click it and select Edit Locations. At this picture I have already created my Home Network. Create and configure the Home network. And click Apply afterwards. Close the window. ...


17

You can do the following: Type ifconfig or ifconfig -a. This command shows you the list of interfaces along with their IP and MAC addresses (the latter one only if applicable). You can also type ifconfig en0 or ifconfig en1 for the configuration of a particular interface only (as someone said in their answers, en0 is typically the wired Ethernet while en1 ...


17

Probably the easiest way to do this is to use a command line utility called nmap. You can download the binaries from the main site. Alternatively, if you have Homebrew installed, you can use that to install nmap from a terminal by typing brew install nmap Once you have downloaded and installed nmap, you need one other piece of information about your LAN - ...


11

iproute2mac https://github.com/brona/iproute2mac is available on brew so far


10

Open Terminal and type: arp -a it will list all the computers on the network and (usually) the host names.


10

If using a third-party utility is not an issue for you, then I recommend giving these a try: arp-scan (available via Homebrew) brew install arp-scan arp-scan --localnet fing (download and install the "Desktop Embedded CLI" package from fing.com or via Homebrew brew cask install fing) sudo fing -r 1 -d true -o table,text Both utilities have a number of ...


9

I used: ipconfig getifaddr en1


8

Or ping the broadcast address ping -c 3 192.168.1.255 | grep 'bytes from' | awk '{ print $4 }' | sort | uniq


8

There is a thing similar to iptables called pf. Configuration The configuration file is located in the /etc/pf.conf To get started, let’s look at the /etc/pf.conf configuration file that comprises pf: scrub-anchor "com.apple/*" nat-anchor "com.apple/*" rdr-anchor "com.apple/*" dummynet-anchor "com.apple/*" anchor "com.apple/*" ...


8

Unless your computer is directly connected to your ISP via the modem, your computer's IP address is actually assigned by your router (either provided by the ISP or yourself). The IP address you see when you go to a whatsmyip website is the public IP address that the ISP has assigned your router, which is the only IP address devices on the internet can talk ...


7

I can't believe nobody has suggested the simplest method of all, only 2 clicks (or 3 if your adapter isn't at the top of the list). Click System Preferences, click Network. It will display the IP address of the adapter under Status to the right of the network adapters. If your device isn't at the top (which will be the default selected) then simply click ...


7

The one you get from Google is your external address - your public one, which is actually assigned to the WAN (external) connection of your router by your ISP. The one from ifconfig is your internal, private address - which is assigned from the LAN (internal) interface of your router. You can use the caching utility to find your external, public IP address:...


7

The IP you're seeing (73.170.168.215) is the address your router is exposing to the outside world. The router is masking you're real address to keep you safe. Any device that uses that router to connect to the outside world will be 'seen' as having that same IP. This is why your Mac and your iPhone appear to have the identical IP's when viewed from ...


6

If you're using Lion, you can use smbutil: usage: smbutil [-hv] subcommand [args] where subcommands are: help display help on specified subcommand lookup resolve NetBIOS name to IP address status resolve IP address or DNS name to NetBIOS names view list resources on specified host dfs list DFS referrals identity identity ...


6

Alternatively, you could try running ifconfig in the terminal. It will show a list of interfaces with IPs by default, along with many many other details such as physical addresses. It can also be used to configure network adapter settings, the man page is here: http://linux.die.net/man/8/ifconfig or you can run man ifconfig on the terminal. In your case ...


6

This small application runs in the background and shows the current IP dddress of your Mac in the menu bar. There are options available to customize the appearance of the menu entry. The IP dddress is updated regulary. Switch on the Router option if you are behind a router or gateway. You can still see your local IP address in the menu. https://www....


6

On a Mac computer, download Apple Configurator from the Mac App Store In Configurator, go to File > New Profile (or Command+n) Fill out the General section, then go to Cellular and select Configure Under Configured APN Type, select Default and Data APNs Fill out the necessary data using your carrier's APN settings Under Data APN Supported IP Versions, ...


5

There are several methods... ...but some methods give different kinds of IP addresses. Make sure you know which kind of IP address you need. For many (most?) purposes, the public IP address is what's required. Your public IP address is the one people on the internet will see. (This is usually what people mean if they don't specify which kind of IP address....


5

From netstat's manual page: The netstat command symbolically displays the contents of various network-related data structures. There are a number of output formats, depending on the options for the information presented. The first form of the command displays a list of active sockets for each protocol. pse@Mithos:~$ netstat Active ...


5

$ netstat -nr -f inet Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.1.254 UGSc 10 0 en4 default 10.0.2.1 UGScI 0 0 ppp0 10 ppp0 USc 0 0 ppp0


4

To get the IP address of your computer facing the Internet, here is a working receipe: if=`netstat -nr | awk '{ if ($1 ~/default/) { print $6} }'` ifconfig ${if} | awk '{ if ($1 ~/inet/) { print $2} }' It should work even when you have multiple interfaces active, even when you have interfaces you don't know which one is actually the default gateway.


Only top voted, non community-wiki answers of a minimum length are eligible