Linux(四)---------网络命令(ip命令)

一.ip命令简介

IP命令是iproute软件包中强大得网络管理工具,包括ifconfig和route命令的作用,查看系统路由,网络设备,设置策略等功能。

1.查看ip命令的使用宝典

复制代码
[root@localhost ~]# ip --help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
                   vrf }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec |
                    -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
                    -4 | -6 | -I | -D | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}

ip命令可以操作的对象

OBJECT :对象

link :网络设备

address :定义ipv4 ipv6的地址

neighbour:查看ARP缓存地址(ARP用于解析MAC地址)

route:路由表对象

maddress:多播地址

tunel:IP上的通道

二.IP命令案例学习

1.查看,显示网络设备信息

复制代码
ip addr show = ip a

2.查看指定网络设备显示信息

复制代码
[root@localhost ~]# ip link show dev ens33

3.显示网络设备,详细的数据包收发大小情况

复制代码
[root@localhost ~]# ip -s link show dev ens33

4.关闭,激活网络设备

复制代码
ip link set ens33 down/up #关闭启动网卡

5.修改网卡MAC地址信息

复制代码
[root@localhost ~]# ip link set ens33 address 0:0c:29:13:10:11

6.ip命令添加,删除ip信息(一般在集群时候用)

复制代码
[root@localhost ~]# ip address  add 193.168.178.150/24 dev ens

[root@localhost ~]# ip address del 192.168.178.161/24 dev ens33
#删除ip 信息

7.ip命令给网卡添加别名

复制代码
[root@localhost ~]# ip address add 192.168.178.161/24 dev ens33 label ens33:1
#起ens33:1的别名
#注意添加完毕后,用ifconfig命令能看到别名网卡信息

8.通过ip命令检查路由信息

复制代码
[root@localhost ~]# ip route
default via 192.168.23.2 dev ens33 proto dhcp metric 100 
192.168.23.0/24 dev ens33 proto kernel scope link src 192.168.23.141 metric 100 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 

9.ip检查arp缓存(显示网络令居的信息),检查MAC地址信息

复制代码
[root@localhost ~]# ip neighbour
192.168.23.1 dev ens33 lladdr 00:50:56:c0:00:08 DELAY
192.168.23.2 dev ens33 lladdr 00:50:56:f6:59:77 STALE
192.168.23.254 dev ens33 lladdr 00:50:56:ec:89:d5 STALE
[root@localhost ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.23.1             ether   00:50:56:c0:00:08   C                     ens33
gateway                  ether   00:50:56:f6:59:77   C                     ens33
192.168.23.254           ether   00:50:56:ec:89:d5   C                     ens33
[root@localhost ~]# arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.23.1             ether   00:50:56:c0:00:08   C                     ens33
192.168.23.2             ether   00:50:56:f6:59:77   C                     ens33
192.168.23.254           ether   00:50:56:ec:89:d5   C                     ens33
相关推荐
chlk1236 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑6 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件7 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号16 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash20 小时前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI1 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
木心月转码ing2 天前
WSL+Cpp开发环境配置
linux
崔小汤呀3 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端
何中应3 天前
vi编辑器使用
linux·后端·操作系统