[Reprinted with the source: Qian guozheng's column http://blog.csdn.net/qianguozheng/article/details/38322705]
In implementing any large project, we will encounter various problems. Of course, if we perform sufficient tests, we will be much more convenient.
Preface
MAC address cloning is mainly used to solve the problem of binding a MAC address to a carrier.
Okay, let's go back to the topic. How can I clone this MAC address.
The LAN port in openwrt is used to clone MAC addresses, so the related settings for MAC address cloning also exist. What we need to do is move to pppoe.
However, the problem arises. After copying it, the MAC address of the WAN port is the MAC address set for programming, but it cannot be dial-up.
Analysis
First, we need to capture packets and analyze the connection process of pppoe.
The Connection established by pppoe is divided into two processes: 1. pppoe discovery process. 2. PPP link creation process.
However, during the establishment of the PPP link, the MAC address before the router (not the cloned MAC address) will appear, and then the cloned address will appear. The connection is repeated and the number cannot be dialed.
Later, by reading the source code of pppd, we found that
The dynamic link library of rp-pppoe.so realizes pppoe discovery process.
The pppd process establishes PPP links. During the LCP process, it is found that the write function is used to send data packets, and the MAC address is automatically filled in by the system. Here, we need to carefully study the socket establishment process, how to modify the MAC address of eth0 is not allowed in my current time. I can only take the discount method and modify the MAC address of eth0.
Summary
In this case, the problem is solved, but this is not the end point. Bugs need to be fixed in various situations, such as when the Mac is empty, when the system is restarted, and when the network is restarted.
In all these cases, we need to keep eth0.2 (the vlan I divide varies with different systems, and the three VLANs in my system are so complicated) consistent with the MAC address of eth0.
[Reprinted with the source: Qian guozheng's column http://blog.csdn.net/qianguozheng/article/details/38322705]