Network card IP configuration method


Redhat, Qilin, Ningsi, Aix, Solaris

Meditate

Please add image description

1. Obtain IP information

(1) ifconfig (ifcfg) command
Insert image description here
(2) ip addr (ip a) command
Insert image description here

Field illustrate
lo In fact, it is a local loopback address. You should also see 127.0.0.1.
eno16777736 is the name of the network card
inet network

Then the IP address of our network card is 192.168.100.3/24 24 represents a class C address.

(3) Ping command
tests the connectivity of the network and checks whether it is connected to the host. Command format ping + ip address
Note: The Linux ping command will always return a value. Remember to hold down the Ctrl + C keys to stop.

Insert image description here

2. 3 network card configuration methods

1. Graphical interface

Insert image description here

2. nmtui: Open the text graphical interface in the shell terminal

Insert image description here

  1. Click edit a connection

edit a connection: Add, edit and delete a network connection.
activate a connection: enable or disable a network connection
Insert image description here

  1. Click en1677736 (network card name)

Insert image description here
Profile name: network card name
Device: means device, here refers to the mac address

  1. Click IPv4 and enter your desired IP address

Automatic: automatic

Addresses: IP addresses

Gateway: gateway

DNS server: DNS server, optional or not.

Insert image description here

  1. Find the following ok, just quit.

  2. Enter the nmtui command again to enable the network

Insert image description here
Insert image description here
Insert image description here

3. How to configure files

Then our Linux network configuration file path: /etc/sysconfig/network-scripts/
(remember to enter the administrator su root at the beginning and I forgot to elevate the rights)

Detailed explanation of commands

[xwn@localhost 桌面]$ cd /etc/sysconfig/network-scripts/(进入网卡的配置文件)
[xwn@localhost network-scripts]$ ls(显示文件下面的内容)
ifcfg-eno16777736  ifdown-ppp       ifup-eth     ifup-sit
ifcfg-lo           ifdown-routes    ifup-ippp    ifup-Team
ifdown             ifdown-sit       ifup-ipv6    ifup-TeamPort
ifdown-bnep        ifdown-Team      ifup-isdn    ifup-tunnel
ifdown-eth         ifdown-TeamPort  ifup-plip    ifup-wireless
ifdown-ippp        ifdown-tunnel    ifup-plusb   init.ipv6-global
ifdown-ipv6        ifup             ifup-post    network-functions
ifdown-isdn        ifup-aliases     ifup-ppp     network-functions-ipv6
ifdown-post        ifup-bnep        ifup-routes  route-eno16777736
[xwn@localhost network-scripts]$ ip a (找到需要配置的网卡 eno1677736)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f7:c6:cf brd ff:ff:ff:ff:ff:ff
    inet 192.168.20.10/24 brd 192.168.20.255 scope global eno16777736
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fef7:c6cf/64 scope link 
       valid_lft forever preferred_lft forever
[xwn@localhost network-scripts]$ vi ifcfg-eno16777736   (编辑配置文件 ifcfg-eno16777736)
 
BOOTPROTO=static(静态网卡)
在最下面添加
IPADDR=(输入你自己的IP地址)
NETMASK= (子网掩码)
GATEWAY=(网关)
DNS=(dns服务器)
 
保存退出:wq
 
重启网卡即可(任选一种命令)
[xwn@localhost 桌面]$systemctl  restart network
 
[xwn@localhost 桌面]$service  network restart

Command diagram

# 进入网卡的配置文件
cd /etc/sysconfig/network-scripts/

Insert image description here
Open the configuration file of the configured network card.
Insert image description here
After entering, popularize the concept of vi command.

i:编辑

Esc:退出编辑

q:退出不保存

q!:强行退出不保存

wq:保存并退出

wq!:强行保存并退出

Insert image description here
After entering, I write to change dhcp to static/none ONBOOT=yes and enter what I entered below.

dhcp:自动获取

static/none :静态ip地址 

IPADDR:ip地址

NETMASK:子网掩码

GATEWAY:网关地址

DNS:dns服务器地址 

ONBOOT=yes  可启动

编写好后按 ESC    在按 :  输入 :wq或者wq!    

Insert image description here
Finally, remember to restart the network card command:

systemctl  restart  network /service network restart

Guess you like

Origin blog.csdn.net/QQ657205470/article/details/128940130