在windows系统中,ipconfig命令行工具被用来获取网络接口配置信息并对此进行修改。Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config)

    (1)用法:

    用法:  ifconfig [网络设备] [参数]

    (2)功能:

    功能:  ifconfig命令用来查看和配置网络设备,当网络环境发生改变时可通过此命令对网络进行相应的配置。

注意:  用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存在电脑里,那就要修改网卡的配置文件了。

    (3)选项参数:

1)  up            启动指定网络设备/网卡。

2)  down            关闭指定网络设备/网卡。该参数可以有效地阻止通过指定接口的IP信息流,如果想永久地关闭一个接口,我们还需要从核心路由表中将该接口的路由信息全部删除。

3) -a          无论是否激活,显示所有配置的网络接口。

4) add          给指定网卡配置IPv6地址

  5) del          删除指定网卡的IPv6地址

6) arp|-arp        打开或关闭支持ARP协议

7) mtu<字节数>      设置网卡的最大传输单元

8) netmask<子网掩码> 设置网卡的子网掩码

    (4)实例:

1)[sunjimeng@localhost ~]$ ifconfig        

[sunjimeng@localhost ~]$ ifconfig         //未联网时的参数
eno16777736: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (170.8 KiB)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (274.8 KiB)
RX errors dropped overruns frame
TX packets bytes (274.8 KiB)
TX errors dropped overruns carrier collisions
[sunjimeng@localhost ~]$ ifconfig                   //连接到有线网时的参数
eno16777736: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 //mtu表示最大传输单元
inet 192.168.117.128 netmask 255.255.255.0 broadcast 192.168.117.255
inet6 fe80::20c:29ff:fe4d:a3cc prefixlen 64 scopeid 0x20<link>
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (177.7 KiB)
RX errors dropped overruns frame
TX packets bytes (6.1 KiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (303.1 KiB)
RX errors dropped overruns frame
TX packets bytes (303.1 KiB)
TX errors dropped overruns carrier collisions

    说明:

  1)etn(Number)指的是网卡,可以看到目前这个网卡的物理地址(MAC地址)是 00:0c:29:4d:a3:cc。

2)inet后表示ip地址,此网卡的ip地址是192.168.117.128,广播地址是192.168.117.255,掩码地址为255.255.255.0。

3)lo是表示主机的回坏地址,这个一般是用来测试一个网络程序,但又不想让局域网或外网的用户能够查看,只能在此台主机上运行和查看所用的网络接口。

  比如把 http服务器指定到回环地址,在浏览器输入127.0.0.1就能看到你所架WEB网站了。但只是您能看得到,局域网的其它主机或用户无从知道。

2)[root@localhost sunjimeng]# ifconfig eno16777736 down    打开和关闭指定网卡

[sunjimeng@localhost ~]$ ifconfig eno16777736 down      //必须是root权限才可以
SIOCSIFFLAGS: 不允许的操作
[sunjimeng@localhost ~]$ su root
密码:
[root@localhost sunjimeng]# ifconfig eno16777736 down
[root@localhost sunjimeng]# ifconfig
lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (303.9 KiB)
RX errors dropped overruns frame
TX packets bytes (303.9 KiB)
TX errors dropped overruns carrier collisions
[root@localhost sunjimeng]# ifconfig eno16777736 up
[root@localhost sunjimeng]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (181.3 KiB)
RX errors dropped overruns frame
TX packets bytes (9.4 KiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (304.2 KiB)
RX errors dropped overruns frame
TX packets bytes (304.2 KiB)
TX errors dropped overruns carrier collisions

注意:ssh登陆linux服务器,关闭了网卡就不能开启了,除非你有多网卡。

3)[root@localhost sunjimeng]# ifconfig -a      无论是否激活,显示所有配置的网络接口,不带参数的只显示已激活的网络接口

[root@localhost sunjimeng]# ifconfig -a
eno16777736: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (181.6 KiB)
RX errors dropped overruns frame
TX packets bytes (9.4 KiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (304.2 KiB)
RX errors dropped overruns frame
TX packets bytes (304.2 KiB)
TX errors dropped overruns carrier collisions

4)启用或关闭支持ARP协议

[root@localhost sunjimeng]# ifconfig eno16777736 arp
[root@localhost sunjimeng]# ifconfig eno16777736 -arp

5)[root@localhost sunjimeng]# ifconfig eno16777736 mtu 2000    设置网络设备传输的最大单元

[root@localhost sunjimeng]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu 1500
inet 192.168.117.128 netmask 255.255.255.0 broadcast 192.168.117.255
inet6 fe80::20c:29ff:fe4d:a3cc prefixlen scopeid 0x20<link>
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (103.3 MiB)
RX errors dropped overruns frame
TX packets bytes (1.2 MiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (356.3 KiB)
RX errors dropped overruns frame
TX packets bytes (356.3 KiB)
TX errors dropped overruns carrier collisions [root@localhost sunjimeng]# ifconfig eno16777736 mtu
[root@localhost sunjimeng]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu
ether :0c::4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (138.3 MiB)
RX errors dropped overruns frame
TX packets bytes (1.2 MiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (414.3 KiB)
RX errors dropped overruns frame
TX packets bytes (414.3 KiB)
TX errors dropped overruns carrier collisions

6)[root@localhost sunjimeng]# ifconfig eno16777736 hw ether 00:0c:29:4d:a3:dd    设置网卡的mac地址

[root@localhost sunjimeng]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu
inet 0.0.0.64 netmask 0.0.0.0 broadcast 255.255.255.255
ether 00:0c:29:4d:a3:cc txqueuelen (Ethernet)
RX packets bytes (151.8 MiB)
RX errors dropped overruns frame
TX packets bytes (1.2 MiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (2.6 MiB)
RX errors dropped overruns frame
TX packets bytes (2.6 MiB)
TX errors dropped overruns carrier collisions [root@localhost sunjimeng]# ifconfig eno16777736 hw ether :0c::4d:a3:dd
[root@localhost sunjimeng]# ifconfig
eno16777736: flags=<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu
inet 0.0.0.64 netmask 0.0.0.0 broadcast 255.255.255.255
ether 00:0c:29:4d:a3:dd txqueuelen (Ethernet)
RX packets bytes (151.8 MiB)
RX errors dropped overruns frame
TX packets bytes (1.2 MiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (2.7 MiB)
RX errors dropped overruns frame
TX packets bytes (2.7 MiB)
TX errors dropped overruns carrier collisions

每天一个Linux命令(46)ifconfig命令的更多相关文章

  1. Linux故障:linux中使用ifconfig命令查看网卡信息时显示为eth1,但是在network-scripts中只有ifcfg-eth0的配置文件,并且里面的NAME="eth0"。

    linux中使用ifconfig命令查看网卡信息时显示为eth1,但是在network-scripts中只有ifcfg-eth0的配置文件,并且里面的NAME="eth0".   ...

  2. ip命令和ifconfig命令(转载)

    Linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...

  3. 每天一个linux命令(39)--ifconfig命令

    许多人非常熟悉Windows下的ipconfig 命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces  config ...

  4. 每天一个linux命令:ifconfig命令 临时修改重启后恢复原样

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  5. 如何解决Linux 系统下 ifconfig 命令无网络接口 ens33

    今天我在做Redis的哨兵集群模式的时候,以前都是好的,也不知道从什么时候开始就无法连接Redis服务器了,就是运行如下命令,没有效果:redis-server redis.conf,然后在通过命令查 ...

  6. LINUX网络之ifconfig命令与ping

    ifconfig命令 网络配置 ifconfig命令被用于配置和显示Linux内核中网络接口的网络参数.用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在.要想将上述的配置信息 ...

  7. linux常用命令:ifconfig 命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  8. linux 下ip命令对比ifconfig命令

    原文:https://linux.cn/article-3144-1.html ------------------------------------------------------------ ...

  9. Linux下利用ifconfig命令查看和操纵网络接口

    为了说明这个问题,首先我们需要解释一下在Linux系统下"网络接口"的含义.通俗来讲,Linux中的所谓网络接口就是指本机的网卡,它相当于计算机的一台负责对网络进行收发数据的外设. ...

  10. centos7 的Linux下ip命令替换ifconfig命令的用法

    linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...

随机推荐

  1. 当synchronized关键字和this关键字

    package cn.itcast_01_mythread.thread.testThread; public class MyThreadWithImpliment_Synch_method imp ...

  2. mysql 索引优化,索引建立原则和不走索引的原因

    第一:选择唯一性索引 唯一性索引的值是唯一的,可以更快捷的通过该索引来确定某条记录. 2.索引的列为where 后面经常作为条件的字段建立索引 如果某个字段经常作为查询条件,而且又有较少的重复列或者是 ...

  3. 【转】Silverlight全开源工作流设计器

    声明 此工作流是作者自行构思和设计的被动式数据触发模式的工作流.没有遵循各种现有的工作流设计标准(如WFMC或WSFL),也没有与其他工作流通用性的接口规范.这里体现更多的是作者对工作流的使用思想,及 ...

  4. Eclipse 生成jar包

    Eclipse 生成jar包 打开 Jar 文件向导 Jar 文件向导可用于将项目导出为可运行的 jar 包. 打开向导的步骤为: 在 Package Explorer 中选择你要导出的项目内容.如果 ...

  5. VC++通过API连接MySQL

    1.  首先安装MySQL数据库server,本文安装的是mysql-installer-community-5.6.10.1.msi这个版本号.至于各个版本号有什么不同,不在这里说明. 例如以下的默 ...

  6. Scala之模式匹配(Patterns Matching)

    前言 首先.我们要在一開始强调一件非常重要的事:Scala的模式匹配发生在但绝不仅限于发生在match case语句块中.这是Scala模式匹配之所以重要且实用的一个关键因素!我们会在文章的后半部分具 ...

  7. hdu5646(数学)

    小学数学,脑补 一开始看到这题,猜了个规律想写但是我是拒绝的. 因为我无法证明. 好吧,主要还是小学数学没学好吧. 要理解这题,首先得搞懂一个重要问题.假设C=A+B,怎样选择两个正整数使得A*B最大 ...

  8. SharePoint服务器端对象模型 之 序言

    对于刚刚开始接触SharePoint的开发人员,即使之前有较为丰富的ASP.NET开发经验,在面对SharePoint时候可能也很难找到入手的方向.对于任何一种开发平台而言,学习开发的过程大致会包括: ...

  9. js验证表单大全1

    附加:js验证radio是否选择 <script language="javascript"> function checkform(obj) { for(i=0;i& ...

  10. hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Ot ...