Linux self-study journey-basic commands (check the ifconfig command of the IP address)

Linux self-study journey-basic commands (ifconfig command)


Preface

1. In the previous section, we described how to configure a static internal network IP address, and briefly explained the basic functions of the three network adapter modes under vmware and a simple understanding of the IP address. If you haven’t read it, you can click on the link below to watch: static configuration IP

2. In this section we describe a command mainly used to view the IP address


Tip: The following is the content of this article

1. Introduction to ifconfig command

The ifconfig command is generally used to view some configuration information of the IP address, just enter the command and press Enter.

  • Command name: ifconfig
  • The full name of the command: configure a network inteface
  • Location: /usr/sbin/ifconfig
  • Execution authority: super user
  • Function description: Used to configure the network interface of the resident kernel. It is used to set the network interface when the boot is successful.
    After that, it is only used when debugging and system adjustment are required.

Two, ifconfig view IP address

[root@dns ~]# ifconfig (直接输入命令回车即可)
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
(ens33为我的网卡名,flags为标志位,mtu是数据最大传输单元)
        inet 192.168.137.25  netmask 255.255.255.0  broadcast 192.168.137.255
(inet后面是我的内网IP地址,netmask是子网掩码,broadcast是广播地址)
        inet6 fe80::20c:29ff:fe98:5aa6  prefixlen 64  scopeid 0x20<link>
(inet6是IPv6地址)
        ether 00:0c:29:98:5a:a6  txqueuelen 1000  (Ethernet)
(ether是MAC地址--MAC地址是设备的唯一标识)
        RX packets 450  bytes 52101 (50.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 378  bytes 50128 (48.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
(上面四条为数据包的收发情况)


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
(lo等于loopback接口,本地回环网卡)
        inet 127.0.0.1  netmask 255.0.0.0
(127.0.0.1就等于你本机,每个主机与127.0.0.1通信都相当于与自己通信)
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 140 (140.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 140 (140.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

We usually use ifconfig directly to view the IP address. Of course, there is another way to view the IP address, which is also what I often use.

[root@dns ~]# ip addr show ens33 | grep inet
    inet 192.168.137.25/24 brd 192.168.137.255 scope global ens33
    inet6 fe80::20c:29ff:fe98:5aa6/64 scope link
[root@dns ~]#

(这句代码就是查看ens33这块网卡的IP地址信息,然后只过滤包含了inet的行的信息)

to sum up

In this section we talked about

{ ifconfig command: mainly used to view the IP address }

This is Jiehua, see you next time!

Guess you like

Origin blog.csdn.net/qq313088385/article/details/114915522