方案: imx6ul+ip175d ;
产品功能:实现4网口路由器(1wan+3lan)和交换机(4Lan)功能;port5 rmii与cpu rmii相连接;
具体实现技术关键点:vlan/lan/wan/vconfig/udhcpc/udhcpd/iptables
开发过程:
1. phy驱动开发;
配置phyid+phy addr(注意与实际硬件addr选择脚一致),phy reg(port0-port5)与IEEE 定义一样;这个难度不大,在此不再展开;
2.vlan订制;
Group 1: port 1, port 5 , VID = 1
Group 2: Port 2, 3, 4, port 5 , VID = 2
Port 1, 2, 3, 4 都是 untag ( Remove Tag)
Port 5 要 Add Tag.
● Register setting:
22.0=0x07FF (Tag based VLAN: Port0-5, PVID classification: Port0-4, VID classification: Port5)
22.5=0x0001 (Port1 PVID=1)
22.6=0x0002 (Port2 PVID=2)
22.7=0x0002 (Port3 PVID=2)
22.8=0x0002 (Port4 PVID=2)
22.10=0x0003 (Enable VLAN0 & VLAN1)
22.14=0x0001 (VLAN0 VID=1)
22.15=0x0002 (VLAN1 VID=2)
23.0=0x3C22 (VLAN0 member: Port1 & Port5, VLAN1 member: Port2-4 & Port5)
23.8=0x2020 (VLAN0 add tag: Port5, VLAN1 add tag: Port5)
23.16=0x1C02 (VLAN0 remove tag: Port1, VLAN1 remove tag: Port2-4)
3.基于802.1q(tag)vlan 网桥在系统层的配置:
vconfig add eth0 1
vconfig set_flag eth0.1 1 1
ifconfig eth0.1 up
#udhcpc -i eth0.1
4.路由转发功能实现:
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -d 192.168.3.1/24 -j ACCEPT
5. mac 转发表及mac过滤的设置:
1.打开mac过滤功能及配置相应端口的mac白名单;
2.回读mac;
3.删除mac;