环境:
Centos 7.5
VMware 16.0.0
问题描述:
CentOS7.5 新装系统如何查看网络,配置网卡信息
解决方案:
1.查看ip信息
ip a
ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:50:56:25:19:1c brd ff:ff:ff:ff:ff:ff inet 192.168.1.227/24 brd 192.168.1.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::36fd:c3d4:ea0a:5ab4/64 scope link noprefixroute valid_lft forever preferred_lft forever
2.查看编辑网卡信息
vim /etc/sysconfig/network-scripts/ifcfg-ens33(网卡名)
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none 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=bf5bb7c5-da27-44a9-b4be-7f6e4138abfd DEVICE=ens33 ONBOOT=yes IPADDR=192.168.1.227 PREFIX=24 GATEWAY=192.168.1.1
重启网络服务
systemctl restart network
查看ens33网卡信息
ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.227 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::36fd:c3d4:ea0a:5ab4 prefixlen 64 scopeid 0x20<link> ether 00:50:56:25:19:1c txqueuelen 1000 (Ethernet) RX packets 29155875 bytes 2426699185 (2.2 GiB) RX errors 0 dropped 108161 overruns 0 frame 0 TX packets 32605674 bytes 12952561612 (12.0 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
启用ens33网卡
ifconfig ens33 up
禁用ens33网卡
ifconfig ens33 down
查看ens33网卡其他参数
ethtool ens33
Settings for ens33: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes
DNS设置
vim /etc/resolv.conf
nameserver 192.168.1.1
关闭NetworkManager服务
systemctl stop NetworkManager.service
停止开机自启
systemctl disable NetworkManager.service
查看网络服务
systemctl status network.service
● network.service - LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled) Active: active (running) since 四 2022-03-17 23:58:09 CST; 7h left Docs: man:systemd-sysv-generator(8) Process: 975 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS) CGroup: /system.slice/network.service └─1304 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-f5774ec4-da78-4594-859b-a17bb015e929-ens33.lease -pf /var/run/dhclient-ens33.pid ens33 3月 17 23:58:06 localhost.localdomain network[975]: 正在打开环回接口: [ 确定 ] 3月 17 23:58:07 localhost.localdomain network[975]: 正在打开接口 ens33: 3月 17 23:58:07 localhost.localdomain dhclient[1193]: DHCPREQUEST on ens33 to 255.255.255.255 port 67 (xid=0x2c76a023) 3月 17 23:58:07 localhost.localdomain dhclient[1193]: DHCPACK from 192.168.1.1 (xid=0x2c76a023) 3月 17 23:58:09 localhost.localdomain NET[1300]: /usr/sbin/dhclient-script : updated /etc/resolv.conf 3月 17 23:58:09 localhost.localdomain dhclient[1193]: bound to 192.168.1.227 -- renewal in 10429 seconds. 3月 17 23:58:09 localhost.localdomain network[975]: 正在确定 ens33 的 IP 信息... 完成。 3月 17 23:58:09 localhost.localdomain NET[1350]: /etc/sysconfig/network-scripts/ifup-post : updated /etc/resolv.conf 3月 17 23:58:09 localhost.localdomain network[975]: [ 确定 ] 3月 17 23:58:09 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.
查看网络服务日志
cat /var/log/messages | grep network
ar 17 23:53:00 localhost systemd: Started LSB: Bring up/down networking. Mar 17 23:54:11 localhost systemd: Stopping LSB: Bring up/down networking... Mar 17 23:54:12 localhost NET[3314]: /etc/sysconfig/network-scripts/ifdown-post : updated /etc/resolv.conf Mar 17 23:54:12 localhost network: 正在关闭接口 ens33: [ 确定 ] Mar 17 23:54:12 localhost network: 正在关闭环回接口: [ 确定 ] Mar 17 23:54:12 localhost systemd: Starting LSB: Bring up/down networking... Mar 17 23:54:12 localhost NET[3516]: /etc/sysconfig/network-scripts/ifup-post : updated