PC Machine Installation Linux Network Card Driver Problem Resolution Case

Work needs, temporarily set up a Linux system in the office environment, using CentOS 6.5, the system installation is smooth, and finally stuck on the network, found that the network is not available.This case records the links in the positioning and processing of problem discovery for brothers who experience the same problem.

Problem Discovery and Location

ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:96 errors:0 dropped:0 overruns:0 frame:0
          TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:7672 (7.4 KiB)  TX bytes:7672 (7.4 KiB)

cd /etc/sysconfig/network-scripts
cat ifcfg-eth0
DEVICE=eth0
HWADDR=00:00:00:00:00:00
TYPE=Ethernet
UUID=146c8871-1435-41e1-a3a4-xxxxxxx
ONBOOT=no
NM_CONTROLLED=yes
BOOTTROTO="dhcp"
IPV6INIT=no
USERCTL=no
    
lspci -v
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)

Solution Try One:

Configure network card through setup (detailed steps omitted, Baidu Search has a lot of guidance)
When the configuration is complete, the configuration file

cat ifcfg-eth0
DEVICE=eth0
HWADDR=00:00:00:00:00:00
TYPE=Ethernet
UUID=146c8871-1435-41e1-a3a4-xxxxxxx
ONBOOT=yes
NM_CONTROLLED=yes
IPADDR=192.168.1.X
NETMASK=255.255.252.0
GATEWAY=192.168.1.1
DNS1=XX.XX.XX.XX
IPV6INIT=no
USERCTL=no

boot adapter

service network restart

eth0: Device eth0 does not seem to be present, delaying initializa [FAILED]

From the fact that the physical location is not available in the configuration and that lspci is viewing the network card information, it is likely that this is a driver problem.

Solution attempt two:

Get Drivers by Multi-party Find
Problem one: Lack of development core, compilation error.Install Development Core
Continue compiling

/home/software/r8168-8.048.00/src/r8168.h:102:1: warning: "netif_info" redefined
In file included from /home/software/r8168-8.048.00/src/r8168_n.c:45:
include/linux/netdevice.h:2648:1: warning: this is the location of the previous definition
/home/software/r8168-8.048.00/src/r8168_n.c:526: error: redefinition of 'mii_adv_to_ethtool_adv_t'
include/linux/mii.h:287: note: previous definition of 'mii_adv_to_ethtool_adv_t' was here
/home/software/r8168-8.048.00/src/r8168_n.c:546: error: redefinition of 'mii_lpa_to_ethtool_lpa_t'
include/linux/mii.h:355: note: previous definition of 'mii_lpa_to_ethtool_lpa_t' was here
/home/software/r8168-8.048.00/src/r8168_n.c:556: error: redefinition of 'mii_stat1000_to_ethtool_lpa_t'
include/linux/mii.h:373: note: previous definition of 'mii_stat1000_to_ethtool_lpa_t' was here
/home/software/r8168-8.048.00/src/r8168_n.c:571: error: redefinition of 'eth_hw_addr_random'
include/linux/etherdevice.h:210: note: previous definition of 'eth_hw_addr_random' was here

For non-C++ people, encountering this error is more obscure, is it too new for the official network driver
Find the problem that responds to on the web, and have similar but corresponding old installation packages that are difficult to obtain.There were hours of fruitless attempts to find resources.

Final solution

Almost despaired, go back to the starting point of the problem and try to solve the compilation problem.
Looking at compilation information seems to mean redefining existing methods and estimating problems with corresponding versions of different operating systems
Find the corresponding source code and try to comment out the method. There are some minor problems in it, which have nothing to do with the overall situation.Finally, after commenting out a few methods, magical compilation succeeded.

View network card information, a lot more [omit a lot of network card information, show the last one]

02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
	Subsystem: Gigabyte Technology Co., Ltd Motherboard
	Flags: bus master, fast devsel, latency 0, IRQ 34
	I/O ports at e000 [size=256]
	Memory at f7c00000 (64-bit, non-prefetchable) [size=4K]
	Memory at f0000000 (64-bit, prefetchable) [size=16K]
	Capabilities: [40] Power Management version 3
	Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [70] Express Endpoint, MSI 01
	Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
	Capabilities: [d0] Vital Product Data
	Capabilities: [100] Advanced Error Reporting
	Capabilities: [140] Virtual Channel
	Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
	Capabilities: [170] Latency Tolerance Reporting
	Kernel driver in use: r8168
	Kernel modules: r8168

Feel reliable, reconfigure, start, succeed.

Drive r8168-8.048.00.tar.bz2 with the latest official website (official website also has a tortoise speed, it's really difficult to visit foreign websites now, let alone the Bay)
Move in and download https://download.csdn.net/download/kaiheye/12151597 directly from the website

Source comment location [515-576]

/*
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)

#ifndef LPA_1000FULL
#define LPA_1000FULL            0x0800
#endif

#ifndef LPA_1000HALF
#define LPA_1000HALF            0x0400
#endif

static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
{

[Omit rows]

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
static inline void eth_hw_addr_random(struct net_device *dev)
{
        random_ether_addr(dev->dev_addr);
}
#endif
*/
Published an original article. Praise 0. Visits 2
Private letter follow

Tags: network Linux CentOS

Posted on Tue, 11 Feb 2020 23:04:03 -0500 by rxero