【Linux 网络】网络工具ifconfig和iproute/iproute2工具详解

【Linux 网络】网络工具ifconfig和iproute/iproute2工具详解

前言

本篇文章主要介绍Linux下网络工具ifconfig/iproute(iproute2)的安装、使用示例和场景。操作系统Ubuntu 18.04。

1、安装

使用apt-get install 命令安装ifconfig和iproute工具,我这里显示已安装,sudo提升管理员权限必不可少。

bash 复制代码
# 安装net-tools才能使用ifconfig命令
root@root:~$ sudo apt-get install net-tools 
[sudo] password for lijiangtao: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
net-tools is already the newest version (1.60+git20161116.90da8a0-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
lijiangtao@lijiangtao:~$ 

# 安装iproute工具才能使用ip命令
root@root:~$ sudo apt-get install iproute2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
iproute2 is already the newest version (4.15.0-2ubuntu1.3).
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
lijiangtao@lijiangtao:~$ 

2、常用命令

这里添加一个功能命令对照表,便于读者按图索骥。并在下一章节的小节中查看详细使用说明。

功能 nettools iproute
@3.1 查看指定/所有网络接口 ifconfig /ifconfig eth0/ifconfig -a ip link show/ip link show eth0
@3.2 启用/禁用网络接口 ifconfig eth0 up/ifconfig eth0 down ip link set eth0 up/down
@3.2 设置/取消ip地址和掩码 ifconfig eth0 192.168.1.1 netmask 255.255.255.0/ifconfig eth0 192.168.100.1 netmask 255.255.255.0 down ip addr add 192.168.1.1/24 dev eth0/ip addr delete 192.168.4.1/24 dev eth0
@3.3 设置mac地址 ifconfig eth0 hw ether 00:11:22:33:44:55 ip link set eth0 address 00:11:22:33:44:55
@3.4 设置最大传输单元MTU ifconfig eth0 mtu 1500 ip link set eth0 mtu 1500
@3.5 设置/网卡混杂模式 ifconfig eth0 promisc/ifconfig eth0 -promisc ip link set eth0 promisc on/off

3、命令使用详解

相关推荐
@insist1232 分钟前
信息安全工程师-工控安全产品体系与行业实践全解析
网络·安全·软考·信息安全工程师·软件水平考试
段一凡-华北理工大学19 分钟前
2026 高炉炼铁智能化技术全景与演进路径~系列文章03:高炉工业数据治理标准化与全生命周期血缘体系
网络·人工智能·高炉炼铁·工业智能体·炉温监测·高炉智能化
YL2004042623 分钟前
MySQL-运维篇-主从复制
运维·数据库·mysql
tedcloud12329 分钟前
wifi-densepose部署教程:构建无线人体感知系统
服务器·javascript·网络·typescript·ocr
AC赳赳老秦35 分钟前
OpenClaw碎片时间利用:设置轻量化自动化任务,高效利用职场碎片时间
java·大数据·运维·服务器·数据库·自动化·openclaw
sukioe42 分钟前
Linux RPM 方式安装 MySQL 8.0
linux·mysql·adb
worm小虫1 小时前
这场劫难,从一份等保报告开始——一件运维的小事SSH升级
运维
JAVA学习通1 小时前
《大营销平台系统设计实现》 - 营销服务 第8节:抽奖规则树模型结构设计
运维·决策树·docker·容器·责任链模式
Keano Reurink1 小时前
长尾关键词自动化扩展:从1个种子词到1000个长尾词
运维·windows·自动化
自由且自律1 小时前
cenph三大存储方式
运维·经验分享·ceph