请选择 进入手机版 | 继续访问电脑版

苹果发烧友论坛

 找回密码
 注册
查看: 6545|回复: 8

[网络] 在Mac上查找你的IP地址

[复制链接]
发表于 2010-11-24 22:12:26 | 显示全部楼层 |阅读模式
本帖最后由 macing2010 于 2010-11-24 22:14 编辑

来自Macing的Blog,enjoy!
      我们都知道Mac OS X的IP地址在设置网路或者共享文件方面非常重要,这里有两个不同的办法可以在Mac OS X上找到你的IP地址;一种通过GUI(Graphical User Interface,图形用户接口。下面的系统偏好设置即属这种──macing),简单快捷;另一种办法则更技术一点,需要使用终端命令。不管你使用的是以太网还是无线,这两个办法都是适用的。

从GUI里找IP地址

你可以从Mac的系统偏好设置里察看IP地址,过程如下:
打开系统偏好设置──网络──选择正在使用的网络,状态下面即是。
屏幕快照 2010-11-24 下午09.32.34.png

通过终端查找IP地址
终端对那些偏爱技术风格的童鞋来说,是最快捷的办法了。
打开终端(/Applications/Utilities),输入下面命令:
  1. ifconfig |grep inet
复制代码
你会看到类似下面的显示:
  1. inet6 ::1 prefixlen 128
  2. inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
  3. inet 127.0.0.1 netmask 0xff000000
  4. inet6 fe80::226:bbff:fe03:b88f%en1 prefixlen 64 scopeid 0x6
  5. inet 192.168.1.101 netmask 0xffffff00 broadcast 192.168.1.255
  6. inet 192.168.199.1 netmask 0xffffff00 broadcast 192.168.199.255
  7. inet 172.16.152.1 netmask 0xffffff00 broadcast 172.16.152.255
复制代码
你的IP地址通常都是跟在最后一个inet6后面,在这个例子里是:192.168.1.101。它的形式是:x.x.x.x,不过永远不会是127.0.0.1,因为这是你机器的回送地址(欲深入了解,请查百科)。你通常不用管它,它是保证你的IP地址是inet和netmask之间(inet 192.168.1.101 netmask)除127.0.0.1以外的其他地址。

另外一个命令是:
  1. ipconfig getifaddr en1
复制代码
这个命令只返回你的en1(无线网络)的IP地址,你也可以把0改为1察看以太网的IP地址。我听说ipconfig不是所有的Mac OS X版本都支持,所以我不推荐首选使用这个终端命令。不过,ipconfig却可以用来设置你的IP地址。
在Mac OS X里察看外部IP地址
      你的外部IP地址是向世界广播的地址,而非你的本地网络地址(比如你的无线路由分配的地址)。同样,终端命令也是察看外部IP最简单的办法,命令如下:
  1. curl whatismyip.org
复制代码
 楼主| 发表于 2010-11-24 22:16:11 | 显示全部楼层


Knowing your Mac’s IP address is important for setting up a network or sharing files, here’s two different ways to find your IP address in Mac OS X; an easy way through the GUI and a more technical approach with the command line. These methods will be the same whether you are connected via ethernet or wireless.

Find your IP Address on a Mac
You can find your IP address from the Mac System Preferences:

From the Apple menu pull down “System Preferences”
Click on the “Network” preference pane
Your IP address will be visible to the right, as indicated in the screenshot below


Your IP address is the number listed, in the above case it is 192.168.0.100

Now we’ll cover the more technical approaches to getting your IP address using the Mac OS X command line:

Find your IP Address via the Mac OS X Terminal
This is how to find the IP address of your Mac through the Terminal, this is often the quickest way for those that are more technically inclined.

Launch the Terminal located in /Applications/Utilities/
Type the following command:
ifconfig |grep inet

You will see something that looks like this:
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::fa1e:dfff:feea:d544%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255

Your IP address is usually next to the last entry of ‘inet’ and in this case is 192.168.0.100, an IP address is always in the format of x.x.x.x but it will never be 127.0.0.1 because that is your machines loopback address. Because you can always ignore 127.0.0.1, this guarantees that your IP address will be the other IP between ‘inet’ and ‘netmask’
The other command line option is to use:
ipconfig getifaddr en1
which reports back only your en1 (usually wireless) IP address. You can change this to en0 for wired/ethernet too. I have heard ipconfig is not supported in all versions of Mac OS X so I did not recommend this as the first choice. However, using ipconfig you can also set your IP address from the command line.

Find your External IP Address in Mac OS X
Your external IP address is what is broadcast to the world rather than your local network (behind a wireless router, for instance). This is easiest to find through a Terminal command a well:
curl whatismyip.org
This will instantly report back your external IP address.
回复 支持 反对

使用道具 举报

发表于 2010-11-25 18:40:08 | 显示全部楼层
好文…………
回复 支持 反对

使用道具 举报

发表于 2010-11-25 18:52:45 | 显示全部楼层
谢谢,十分感谢!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-11-25 19:50:27 | 显示全部楼层
好文…………
roy120981387 发表于 2010-11-25 18:40



    谢谢啊,翻译组的东西一定是好东西。
回复 支持 反对

使用道具 举报

QQ|小黑屋|手机版|Archiver|苹果发烧友论坛 ( 京ICP备16012027号-3 )

GMT+8, 2017-12-13 09:21 , Processed in 0.013323 second(s), 10 queries , Xcache On.

Powered by Discuz! X3.3 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表