ifconfig命令

ifconfig命令

  • ifconfig命令作用:用于显示或设置网络设备。

ifconfig使用示例

  • ifconfig显示网络设备信息

    root@ms:~# ifconfig        
    eth0   Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C 
         inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
         inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
         RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
         TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000 
         RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
         Interrupt:185 Base address:0x2024 
    
    lo    Link encap:Local Loopback 
         inet addr:127.0.0.1 Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING MTU:16436 Metric:1
         RX packets:2022 errors:0 dropped:0 overruns:0 frame:0
         TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0 
         RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
    
    
  • ifconfig配置IP地址

    root@ms:~# ifconfig eth0 192.168.1.56 //给eth0网卡配置IP地址
    root@ms:~# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 // 给eth0网卡配置IP地址,并加上子掩码
    root@ms:~# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255 // 给eth0网卡配置IP地址,加上子掩码,加上个广播地址
    
  • ifconfig启动关闭指定网卡

    root@ms:~# ifconfig eth0 down
    root@ms:~# ifconfig eth0 up
    
  • ifconfig修改MAC地址

    root@ms:~# ifconfig eth0 down //关闭网卡
    root@ms:~# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址
    root@ms:~# ifconfig eth0 up //启动网卡
    root@ms:~# ifconfig eth1 hw ether 00:1D:1C:1D:1E //关闭网卡并修改MAC地址 
    root@ms:~# ifconfig eth1 up //启动网卡
    
  • ifconfig启用和关闭ARP协议

    root@ms:~# ifconfig eth0 arp  //开启
    root@ms:~# ifconfig eth0 -arp  //关闭
    
  • ifconfig设置最大传输单元

    root@ms:~# ifconfig eth0 mtu 1500 //设置能通过的最大数据包大小为 1500 bytes
    
posted on 2023-11-02 21:30  WilliamMoa  阅读(39)  评论(0)    收藏  举报