linux用ifconfig查不到IP的解决办法

1、当输入ifconfig出现下面问题时:
[root@localhost xatu]# ifconfig
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 2 bytes 196 (196.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 196 (196.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:37:a6:13 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2、查看配置文件是否正确,如果正确,执行3.
[root@localhost xatu]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg ifdown-ipv6 ifup-aliases ifup-ppp
ifcfg-eno16777736 ifdown-isdn ifup-bnep ifup-routes
ifcfg-eno16777736.bak ifdown-post ifup-eth ifup-sit
ifcfg-ens33 ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
[root@localhost network-scripts]# vi ifcfg-lo
ifcfg-lo 当中的配置文件如下:
VICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0

If you’re having problems with gated making 127.0.0.0/8 a martian,

you can change this to something else (255.255.255.255, for example)

BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
3、使用[root@localhost xatu]# dhclient -v
[root@localhost xatu]# dhclient -v
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/virbr0-nic/52:54:00:37:a6:13
Sending on LPF/virbr0-nic/52:54:00:37:a6:13
Listening on LPF/virbr0/52:54:00:37:a6:13
Sending on LPF/virbr0/52:54:00:37:a6:13
Listening on LPF/eno16777736/00:0c:29:69:5c:67
Sending on LPF/eno16777736/00:0c:29:69:5c:67
Sending on Socket/fallback
DHCPDISCOVER on virbr0-nic to 255.255.255.255 port 67 interval 6 (xid=0x55848ad8)
DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 3 (xid=0x63f448c9)
DHCPDISCOVER on eno16777736 to 255.255.255.255 port 67 interval 8 (xid=0x533d032c)
DHCPREQUEST on eno16777736 to 255.255.255.255 port 67 (xid=0x533d032c)
DHCPOFFER from 192.168.110.254
DHCPACK from 192.168.110.254 (xid=0x533d032c)
bound to 192.168.110.128 – renewal in 858 seconds.
[root@localhost xatu]#
[root@localhost xatu]#
[root@localhost xatu]#
[root@localhost xatu]#
[root@localhost xatu]#
[root@localhost xatu]#
[root@localhost xatu]# ifconfig
eno16777736: flags=4163 mtu 1500
inet 192.168.110.128 netmask 255.255.255.0 broadcast 192.168.110.255
inet6 fe80::20c:29ff:fe69:5c67 prefixlen 64 scopeid 0x20
ether 00:0c:29:69:5c:67 txqueuelen 1000 (Ethernet)
RX packets 11 bytes 1291 (1.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27 bytes 4552 (4.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 2 bytes 196 (196.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 196 (196.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:37:a6:13 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0-nic: flags=4099 mtu 1500
ether 52:54:00:37:a6:13 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions
至此,便已解决!

你可能感兴趣的:(linux用ifconfig查不到IP的解决办法)