首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

linux ip下令学习

2013-11-03 
linux ip命令学习ip命令可以用来查看ip地址,路由信息等。sh-# ip address1: lo: LOOPBACK,UP,LOWER_UP mt

linux ip命令学习

ip命令可以用来查看ip地址,路由信息等。
sh-# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:00:00:00:fd:19 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.155/24 brd 192.168.0.255 scope global eth0
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0
sh-#

sh-# ip route
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0  src 192.168.0.155
sh-#

使用ifconfig或route等命令也可以显示一些相关的网络信息,
sh-# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:FD:19
          inet addr:192.168.0.155  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:201 errors:0 dropped:109 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25732 (25.1 Kb)  TX bytes:11247 (10.9 Kb)
          Interrupt:40 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

sh-#

sh-# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

sh-#

ip命令也可以通过参数让其显示指定的信息,
sh-# ip -f inet route
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0  src 192.168.0.155
sh-#

sh-# ip -f inet6 route
unreachable default dev lo  metric -1  error -101
sh-#

sh-# ip -f link route
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0  src 192.168.0.155
unreachable default dev lo  metric -1  error -101
sh-#

sh-# ip -f inet address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    inet 192.168.0.155/24 brd 192.168.0.255 scope global eth0
sh-#


sh-# ip -f inet route
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0  src 192.168.0.155
sh-#

sh-# ip -f inet link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:00:00:00:fd:19 brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0
sh-#

热点排行