示例示例Linux下查看IP命令有以下几种:命令:
Linux下查看IP命令有以下几种:
1. ifconfig命令:
ifconfig命令是linux系统中常用的网络配置工具,可以查看本机的IP地址,代码示例如下:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:6D:A9:8F
inet addr:192.168.1.100 ast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3194 errors:0 dropped:0 overruns:0 frame:0
TX packets:2745 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:255907 (250.0 KiB) TX bytes:380062 (371.2 KiB)
2. ip addr命令:
ip addr命令也可以查看本机的IP地址,代码示例如下:
$ ip addr
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:6d:a9:8f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe6d:a98f/64 scope link
valid_lft forever preferred_lft forever
3. hostname -I 命令:
hostname -I命令也可以查看本机的IP地址,代码示例如下:
$ hostname -I
192.168.1.100
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(7条)