Network Configuration Guide for Router Based on NXP 104x Platform

Configuring a Bridge for LAN Ports

1. Create/etc/systemd/network/br0.netdev

[NetDev]     //A section identifier indicating that the following configuration information belongs to a network device definition.

Name=br0     //Specifies the name of the network device to be "br0".

Kind=bridge     //# Specifies the device type as a bridge, used to connect multiple network devices for network communication.

2. Create/etc/systemd/network/br0.network

[Match]     //Indicates that the following content is for matching device conditions.

Name=br0     //Specifies the device name to match as "br0". The following configuration will apply to the device named "br0".

KernelCommandLine=!root=/dev/nfs
    //Specifies the kernel command line condition for the device, preventing accidental boot to an NFS root file system.

[Network]

Address=192.168.3.1/24

3. Create the Port Configuration Files:

touch /etc/systemd/network/fm1-mac2.network

touch /etc/systemd/network/fm1-mac4.network

touch /etc/systemd/network/fm1-mac5.network

touch /etc/systemd/network/fm1-mac6.network

touch /etc/systemd/network/fm1-mac9.network

touch /etc/systemd/network/fm1-mac10.network

Enter the following content, taking fm1-mac2.network as an example:

Name=fm1-mac2 The attribute differs, must correspond to the filename.

[Match]

Name=fm1-mac2

KernelCommandLine=!root=/dev/nfs


[Network]

Bridge=br0

Enable 5G Dial-Up on Boot

1. Add 5G Autostart:

At the end of the /root/.forlinx file, add the following content:

sleep 10 //Prevents this service from starting before some dependent services.
/root/Net_Tools/quectel-CM

Possible Reasons for Dial-Up Failure:

SIM card inserted incorrectly, SIM card is out of credit.

IoT card is locked, need to add APN (cmnet: Mobile; 3gnet: Unicom; ctnet: Telecom).

The board has a 4/5G switching dial switch.

Install and Configure udhcpd Service

1. Install udhcpd Service:

apt-get update //May fail due to reasons: the board itself has no network, DNS not set, RTC clock not updated.
apt-get install udhcpd

Other Solutions for Source Update Failure:

(1) https://blog.csdn.net/Chaowanq/article/details/121559709 apt command certificate error.

(2) https://blog.csdn.net/zhushixia1989/article/details/104550890 GLib-CRITICAL **: g_strchomp: assertion ‘string != NULL’ failed

(3) https://blog.csdn.net/downanddusk/article/details/126334776 kali-rolling InRelease‘ is not signed

2. Configure udhcpd Service:

Open /etc/udhcpd.conf

and modify the /etc/udhcpd.conf configuration file to customize the IP pool, gateway, DNS, interface, etc.

Here, I allocate IP range 192.168.3.20 — 192.168.3.254, interface as br0.

Modify /etc/default/udhcpd to enable it.

DHCPD_ENABLED=“yes”.

After configuration, start the service: systemctl start udhcpd.service.

Restart the service: systemctl restart udhcpd.service.

Enable the service at boot: systemctl enable udhcpd.service.

Check the service status: systemctl status udhcpd.service.

Set Network Node usb0 Forwarding Rules

1. Set Forwarding Rules:

iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE(Ensure the -o parameter interface is confirmed correctly.)

2. Save Forwarding Rules:

netfilter-persistent save

netfilter-persistent reload

-t nat: Specifies the table to operate on as the nat table. The nat table is used for network address convert.

-A POSTROUTING: -A indicates that a rule is being appended to the end of the chain, and in this case, the chain being appended is the POSTROUTING chain. Rules in the POSTROUTING chain are handled when a packet is about to leave a network interface.

-o usb0: The -o option specifies which network interface the packets will be sent out from. In this example, usb0 is the designated network interface (usually a USB network adapter).

-j MASQUERADE: The -j jump to target action, here is MASQUERADE, which means enabling IP masquerading, replacing the source address with the IP address of the interface sending the packets, useful especially for dynamically assigned IP addresses.