飞凌小课堂丨5G不只是无线---5G流量到有线的转发

今年是 5G 大规模使用的元年,也是 5G 时代的元年, 5G 的大幕拉开,飞凌先后发布 5G 网关 FCU2301 和 FCU2302。随着网关的发布,越来越多的人开始关注如何让电脑的有线分享到 5G 的流量,下面我就来给大家展示一下,5G流量的转发给有线的流程。

第一步 设置自动 dhcpd

root@localhost:~# systemctl enable isc-dhcp-server.service
Synchronizing state of isc-dhcp-server.service with SysV service script with
/lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable isc-dhcp-server

第二步 设置静态 IP :(设置的 IP 网口为连接电脑的网口)

root@localhost:~# vi /etc/systemd/network/fm1-mac6.network
[Match]
Name=fm1-mac6
KernelCommandLine=!root=/dev/nfs
[Network]
Address=192.168.2.1/24

第三步 设置 NAT 打开转发:

root@localhost:~# vi /etc/sysctl.conf
5G不只是无线---5G流量到有线的转发

第四步设置转发:

root@localhost:~# iptables -t nat -A POSTROUTING -o enx001e101f0000 -j MASQUERADE

保存 iptables 配置:

root@localhost:~# netfilter-persistent save
run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables save
run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables save
root@localhost:~# netfilter-persistent reload
run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables start
run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables start

第五步 重启 开发板,配置使 5G 模块可以正常上网

以插入移动 SIM 卡测试 5G 上网为例,测试是否连接外网:

root@localhost:~# /root/ok104x_MH5000.sh
5G Complite !!!
root@localhost:~# ping www.baidu.com -I enx001e101f0000 -c 5
PING www.a.shifen.com (39.156.66.14) from 10.109.32.164 enx001e101f0000: 56(84)
bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=51 time=242 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=51 time=60.4 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=3 ttl=51 time=49.9 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=4 ttl=51 time=57.9 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=5 ttl=51 time=47.9 ms
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 47.926/91.744/242.484/75.516 ms

测试ping百度,发送接收5包数据,丢包率为0,5G 可上外网。如果 5G 模块不能连接外网,请检查 5G 拨号设置或 SIM卡是否欠费。

查看 5G 拨号脚本为:

root@localhost:~# cat ok104x_MH5000.sh
#!/bin/sh
while true
do
if [ -c /dev/ttyUSB1 ]
then
sleep 4
echo "ATE0" > /dev/ttyUSB1
echo "AT^NDISDUP=1,1,\"cmnet\""> /dev/ttyUSB1
ifconfig enx001e101f0000 up
dhclient enx001e101f0000
echo "5G Complite !!!"
exit 0
fi
sleep 1
echo "waiting ttyUSB1 device ..."
done

如需测试其他网络环境,可以修改此脚本进行 5G 模块的拨号上网设置。

注: echo “AT^NDISDUP=1,1,“cmnet””> /dev/ttyUSB2 为移动 APN
echo “AT^NDISDUP=1,1,“3gnet””> /dev/ttyUSB2 为联通
echo “AT^NDISDUP=1,1,“ctnet””> /dev/ttyUSB2 为电信

第六步

网线一端接控制单元的 mac6 (设置静态 IP 的网口) 另一端接电脑网口,电脑端设置为 DHCP ,电脑会自动获取到 IP ,此时可以正常上网。

相关产品:
https://www.forlinx.com/product/113.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值