1.ifconfig:查看网卡信息
如果centos7 最小化安装没有ifconfig这个命令,可以使用yum install net-tools 来安装。
centos7 网卡命名规则:
en: ethernet以太网卡
o:主板集成网卡
p:PCI独立网卡
s:热插拔网卡
nnn数字:MAC+主板信息(生产唯一序号)
如:ifcfg-ens33 (以太热插拔)
[root@centos ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.10.64.77 netmask 255.255.248.0 broadcast 10.10.71.255 inet6 fe80::db93:c1b1:674d:47e8 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:77:ea:f1 txqueuelen 1000 (Ethernet) RX packets 1712270 bytes 1140094109 (1.0 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 212453 bytes 15689873 (14.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
UP:网卡开启状态
RUNNING:网线连接状态
MULTICAST:支持组播
mut 1500:最大传输单元1500字节
inet:IP地址
netmask:子网掩码
broadcast:广播地址
ether:MAC地址
RX packets:发送包信息
RX error:发送错误信息
TX packets:接收包信息
TX error:接收错误信息
systemctl restart network:重启网络服务
systemctl status network/network.serivce:查看网络服务
[root@centos ~]# systemctl status network ● network.service - LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled) Active: active (exited) since Fri 2020-08-28 13:27:00 CST; 1min 56s ago Docs: man:systemd-sysv-generator(8) Process: 39958 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS) Process: 40123 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS) Aug 28 13:27:00 centos systemd[1]: Starting LSB: Bring up/down networking... Aug 28 13:27:00 centos network[40123]: Bringing up loopback interface: [ OK ] Aug 28 13:27:00 centos network[40123]: Bringing up interface ens33: Connection successfully.../5) Aug 28 13:27:00 centos network[40123]: [ OK ] Aug 28 13:27:00 centos systemd[1]: Started LSB: Bring up/down networking. Hint: Some lines were ellipsized, use -l to show in full.
网络服务守护进程: NetworkManager
systemctl status NetworkManager:查看网络守护进程状态:
网卡配置文件:/etc/sysconfig/network-scripts/ifcfg-ens33
DNS配置文件:/etc/resolv.conf
2.配置或修改IP的两种方式
1)使用命令nmtui,菜单方式修改
2)修改网卡配置文件
[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=9780a5a8-a7e8-4a17-86b1-cf68aab1ca87 DEVICE=ens33 ONBOOT=yes IPADDR=192.168.137.133 NETMASK=255.255.255.0 GATEWAY=192.168.137.1 DNS1=192.168.137.1 ZONE=external
看看天上,于是我去了满是风雪的地方