环境:
Centos7.5
VMware16.0.0
问题描述:
CentOS7.5新装系统如何查看网络,配置网卡信息
解决方案:
1.查看ip信息
ipa
ipa1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNgroupdefaultqlen1000link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlovalid_lftforeverpreferred_lftforeverinet6::1/128scopehostvalid_lftforeverpreferred_lftforever2:ens33:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPgroupdefaultqlen1000link/ether00:50:56:25:19:1cbrdff:ff:ff:ff:ff:ffinet192.168.1.227/24brd192.168.1.255scopeglobalnoprefixrouteens33valid_lftforeverpreferred_lftforeverinet6fe80::36fd:c3d4:ea0a:5ab4/64scopelinknoprefixroutevalid_lftforeverpreferred_lftforever
2.查看编辑网卡信息
vim/etc/sysconfig/network-scripts/ifcfg-ens33(网卡名)
TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens33UUID=bf5bb7c5-da27-44a9-b4be-7f6e4138abfdDEVICE=ens33ONBOOT=yesIPADDR=192.168.1.227PREFIX=24GATEWAY=192.168.1.1
重启网络服务
systemctlrestartnetwork
查看ens33网卡信息
ifconfigens33
ens33:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu1500inet192.168.1.227netmask255.255.255.0broadcast192.168.1.255inet6fe80::36fd:c3d4:ea0a:5ab4prefixlen64scopeid0x20<link>ether00:50:56:25:19:1ctxqueuelen1000(Ethernet)RXpackets29155875bytes2426699185(2.2GiB)RXerrors0dropped108161overruns0frame0TXpackets32605674bytes12952561612(12.0GiB)TXerrors0dropped0overruns0carrier0collisions0
启用ens33网卡
ifconfigens33up
禁用ens33网卡
ifconfigens33down
查看ens33网卡其他参数
ethtoolens33
Settingsforens33:Supportedports:[TP]Supportedlinkmodes:10baseT/Half10baseT/Full100baseT/Half100baseT/Full1000baseT/FullSupportedpauseframeuse:NoSupportsauto-negotiation:YesSupportedFECmodes:NotreportedAdvertisedlinkmodes:10baseT/Half10baseT/Full100baseT/Half100baseT/Full1000baseT/FullAdvertisedpauseframeuse:NoAdvertisedauto-negotiation:YesAdvertisedFECmodes:NotreportedSpeed:1000Mb/sDuplex:FullPort:TwistedPairPHYAD:0Transceiver:internalAuto-negotiation:onMDI-X:off(auto)SupportsWake-on:dWake-on:dCurrentmessagelevel:0x00000007(7)drvprobelinkLinkdetected:yes
DNS设置
vim/etc/resolv.conf
nameserver192.168.1.1
关闭NetworkManager服务
systemctlstopNetworkManager.service
停止开机自启
systemctldisableNetworkManager.service
查看网络服务
systemctlstatusnetwork.service
●network.service-LSB:Bringup/downnetworkingLoaded:loaded(/etc/rc.d/init.d/network;bad;vendorpreset:disabled)Active:active(running)since四2022-03-1723:58:09CST;7hleftDocs:man:systemd-sysv-generator(8)Process:975ExecStart=/etc/rc.d/init.d/networkstart(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.pidens333月1723:58:06localhost.localdomainnetwork[975]:正在打开环回接口:[确定]3月1723:58:07localhost.localdomainnetwork[975]:正在打开接口ens33:3月1723:58:07localhost.localdomaindhclient[1193]:DHCPREQUESTonens33to255.255.255.255port67(xid=0x2c76a023)3月1723:58:07localhost.localdomaindhclient[1193]:DHCPACKfrom192.168.1.1(xid=0x2c76a023)3月1723:58:09localhost.localdomainNET[1300]:/usr/sbin/dhclient-script:updated/etc/resolv.conf3月1723:58:09localhost.localdomaindhclient[1193]:boundto192.168.1.227--renewalin10429seconds.3月1723:58:09localhost.localdomainnetwork[975]:正在确定ens33的IP信息...完成。3月1723:58:09localhost.localdomainNET[1350]:/etc/sysconfig/network-scripts/ifup-post:updated/etc/resolv.conf3月1723:58:09localhost.localdomainnetwork[975]:[确定]3月1723:58:09localhost.localdomainsystemd[1]:StartedLSB:Bringup/downnetworking.
查看网络服务日志
cat/var/log/messages|grepnetwork
ar1723:53:00localhostsystemd:StartedLSB:Bringup/downnetworking.Mar1723:54:11localhostsystemd:StoppingLSB:Bringup/downnetworking...Mar1723:54:12localhostNET[3314]:/etc/sysconfig/network-scripts/ifdown-post:updated/etc/resolv.confMar1723:54:12localhostnetwork:正在关闭接口ens33:[确定]Mar1723:54:12localhostnetwork:正在关闭环回接口:[确定]Mar1723:54:12localhostsystemd:StartingLSB:Bringup/downnetworking...Mar1723:54:12localhostNET[3516]:/etc/sysconfig/network-scripts/ifup-post:updated