RHEL7/CentOS7 ip 命令常用用法,代替 ifconfg/route/ifup/ifdown

11 篇文章 0 订阅

注:从 RHEL7/CentOS7 开始,net-tools 包从系统中移除,ifconfg/route/ifup/ifdown 等命令均消失,转而以 ip 命令代替上述命令。因此本篇主要列举了如何使用 ip 命令代替上述命令的常用用法

一图说明

net-tools vs ip

参考链接

How to use IP Command in Linux with Examples
linux命令总结之ip命令

1. 查看 IP 地址和数据统计

ifconfig 版本

  • ifconfig:显示 up 状态的端口信息,包括 ip、mac、统计等。
  • ifconfig -a:显示所有状态的端口信息,包括 ip、mac、统计等。

ip 版本

  • ip addr(简写成 ip a):显示所有端口信息,包括 ip、mac、up/down 等。
  • ip -4 a:仅显示带 ipv4 地址的端口信息。
  • ip -s link:显示所有端口统计信息。
  • ip -s link ls eth0:显示 eth0 端口的统计信息。
  • ip -s -s link ls eth0:更详细地显示 error 信息。

2. 添加/删除端口的 ip 地址

ifconfig 版本

  • ifconfig eth0 192.168.120.56 netmask 255.255.255.0:临时添加 eth0ip 地址。

ip版本

  • ip addr add 192.168.2.199/24 dev eth0:临时添加 eth0ip 地址。
  • ip addr del 192.168.2.199/24 dev eth0:删除 eth0ip 地址。

3. UP/DOWN 端口

ifconfig 版本

  • ifconfig eth0 up:将端口 eth0 启动。
  • ifconfig eth0 down:将端口 eth0 关闭。

ifup/ifdown 版本

  • ifup ifcfg-eth0:将端口 eth0 启动。
  • ifdown ifcfg-eth0:将端口 eth0 关闭。

ip 版本

  • ip link set dev eth0 up:将端口 eth0 启动(无需 ifcfg-eth0 文件存在)。
  • ip link set dev eth0 down:将端口 eth0 启动(无需 ifcfg-eth0 文件存在)。

4. 路由配置

route 版本

  • route -n:查看路由信息
  • route add default gw 192.168.1.1 eth0:添加默认网关路由
  • route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0:添加到网络的路由
  • route add -host 10.20.30.148 gw 10.20.30.40:添加到主机的路由

ip 版本

  • ip route:查看路由信息
  • ip route add default via 192.168.1.1:添加默认网关路由
  • ip route add 192.168.0.0/24 via 192.168.1.2:添加到网络的路由
  • ip route add 192.168.1.3 via 172.16.0.1 dev eth0:添加到主机的路由
  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Deploy and manage today's essential services on an enterprise-class, open operating system About This Book * Configure and manage Linux servers in varying scenarios and for a range of business requirements * Explore the up-to-date features of CentOS using real-world scenarios * See practical and extensive recipes to deploy and manage CentOS Who This Book Is For This book is for Linux professionals with basic Unix/Linux functionality experience, perhaps even having set up a server before, who want to advance their knowledge in administering various services. What You Will Learn * See how to deploy CentOS easily and painlessly, even in multi-server environments * Configure various methods of remote access to the server so you don't always have to be in the data center * Make changes to the default configuration of many services to harden them and increase the security of the system * Learn to manage DNS, emails and web servers * Protect yourself from threats by monitoring and logging network intrusion and system intrusion attempts, rootkits, and viruses * Take advantage of today's powerful hardware by running multiple systems using virtualization In Detail CentOS is derived from Red Hat Enterprise Linux (RHEL) sources and is widely used as a Linux server. This book will help you to better configure and manage Linux servers in varying scenarios and business requirements. Starting with installing CentOS, this book will walk you through the networking aspects of CentOS. You will then learn how to manage users and their permissions, software installs, disks, filesystems, and so on. You'll then see how to secure connection to remotely access a desktop and work with databases. Toward the end, you will find out how to manage DNS, e-mails, web servers, and more. You will also learn to detect threats by monitoring network intrusion. Finally, the book will cover virtualization techniques that will help you make the most of CentOS. Style and approach This easy-to-read cookbook is filled with practical recipes. Hands-on, task-based exercises will present you with real-world solutions to deploy and manage CentOS in varying business scenarios.
网络服务器是提供网络服务的计算机系统,通过搭建、配置和管理网络服务器,可以实现对网络服务的稳定和可靠的支持。在搭建、配置和管理过程中,常用的操作系统是Linux,特别是RHEL8/CENTOS8微课版第4版。 搭建网络服务器的第一步是安装操作系统。在RHEL8/CENTOS8微课版第4版中,可以通过光盘或USB安装介质选择网络服务器安装选项进行安装。在安装过程中,需要设置主机名、IP地址、子网掩码等网络参数,以及选择网络服务器软件包组件。 配置网络服务器的第二步是设定网络服务。常见的网络服务包括Web服务器(如Apache、Nginx)、邮件服务器(如Postfix、Dovecot)、文件服务器(如Samba、NFS)、数据库服务器(如MySQL、PostgreSQL)等。在RHEL8/CENTOS8微课版第4版中,可以使用dnf命令进行软件包的安装和服务的启动、停止、重启。 管理网络服务器的第三步是监控和维护服务器。在RHEL8/CENTOS8微课版第4版中,可以使用各种工具和命令进行服务器的监控和维护,如top命令可以查看服务器的系统状态和资源利用情况,netstat命令可以查看网络连接状态,systemctl命令可以管理服务的启动和停止,journalctl命令可以查看系统日志等。 搭建、配置和管理网络服务器需要具备一定的Linux操作和网络知识,并且需要不断学习和更新技能。同时,网络服务器的安全性、性能和稳定性也是非常重要的,需要加强对安全策略的设置、配置防火墙、定期更新系统和软件补丁等措施。 总之,通过搭建、配置和管理网络服务器,可以实现对网络服务的稳定和可靠的支持,并为用户提供高质量的网络服务体验。同时,也需要不断学习和提高自己的技能,以适应快速发展和变化的网络环境。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值