搜索
bottom↓
回复: 5

飞凌TE2440:嵌入式Linux简单路由实验

[复制链接]

出0入0汤圆

发表于 2010-5-14 13:09:21 | 显示全部楼层 |阅读模式
本实验所用硬件平台为飞凌(www.witech.com.cn)TE2440V2型开发板;该开发板上有两个网卡芯片,分别为CS8900和DM9000;在linux操作系统(采用2.6.12版本的内核)下两个网卡对应的设备名分别为eth0和eht1。
        本实验中TE2440V2开发板作为路由器连接两个局域网:192.168.0.*和192.168.1.*,对应网关分别为192.168.0.3和192.168.1.3。
1. 配置开发板上两个网卡的IP地址: # ifconfig eth0 192.168.0.3 up

# ifconfig eth0 192.168.1.3 up        
用ifconfig命令查看网卡信息如下:         # ifconfig

        eth0      Link encap:Ethernet  HWaddr 00:00:02:50:10:08

                  inet addr:192.168.0.3 Bcast:192.168.0.255

                  Mask:255.255.255.0

                  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

                  RX packets:33310 errors:0 dropped:0 overruns:0 frame:0

                  TX packets:5437 errors:55 dropped:0 overruns:25 carrier:5

                  collisions:798 txqueuelen:1000

                  RX bytes:6283109 (5.9 MiB)  TX bytes:3796550 (3.6 MiB)

                  Interrupt:53 Base address:0x300

        

        eth1      Link encap:Ethernet  HWaddr 00:12:34:56:80:49

                  inet addr:192.168.1.3 Bcast:192.168.1.255

                  Mask:255.255.255.0

                  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

                  RX packets:38618 errors:0 dropped:0 overruns:0 frame:0

                  TX packets:2997 errors:0 dropped:0 overruns:0 carrier:0

                  collisions:0 txqueuelen:1000

                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

                  Interrupt:51 Base address:0x8300

2. 开启Linux内核的路由转发功能(注意1后面有空格): #echo 1 >/proc/sys/net/ipv4/ip_forward        
可通过如下命令查看路由转发是否开启,1为开启,0为关闭。 # sysctl net.ipv4.ip_forward

net.ipv4.ip_forward = 1

# more /proc/sys/net/ipv4/ip_forward

1        
路由表不用配置,用自动生成的就可以: # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     *               255.255.255.0   U     0      0        0 eth1

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0        

3. 测试:用两个局域网内(192.168.0.*、192.168.1.*)的PC机,分别将其默认网关设置为192.168.0.3和192.168.1.3(这里对应路由器的IP地址),然后用ping命令测试。我用的两个客户机的IP分别为192.168.0.221和192.168.1.228,测试结果如下: C:\Documents and Settings\Administrator>ipconfig



Windows IP Configuration



Ethernet adapter 本地连接 5:



        Connection-specific DNS Suffix  . :

        IP Address. . . . . . . . . . . . : 192.168.1.228

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.1.3



C:\Documents and Settings\Administrator>ping 192.168.0.221 -l 65500



Pinging 192.168.0.221 with 65500 bytes of data:



Reply from 192.168.0.221: bytes=65500 time=298ms TTL=63

Reply from 192.168.0.221: bytes=65500 time=244ms TTL=63

Reply from 192.168.0.221: bytes=65500 time=230ms TTL=63

Reply from 192.168.0.221: bytes=65500 time=257ms TTL=63



Ping statistics for 192.168.0.221:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 230ms, Maximum = 298ms, Average = 257ms
C:\Documents and Settings\Administrator>ipconfig



Windows IP Configuration





Ethernet adapter 本地连接 3:



        Connection-specific DNS Suffix  . :

        IP Address. . . . . . . . . . . . : 192.168.0.221

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.0.3



C:\Documents and Settings\Administrator>ping 192.168.1.228 -l 65500



Pinging 192.168.1.228 with 65500 bytes of data:



Reply from 192.168.1.228: bytes=65500 time=240ms TTL=127

Reply from 192.168.1.228: bytes=65500 time=263ms TTL=127

Reply from 192.168.1.228: bytes=65500 time=226ms TTL=127

Reply from 192.168.1.228: bytes=65500 time=282ms TTL=127



Ping statistics for 192.168.1.228:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

        Minimum = 226ms, Maximum = 282ms, Average = 252ms

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

发表于 2010-5-14 21:59:53 | 显示全部楼层
路由器?这么强大?现在用的路由器就是这么实现的吗?新手学习,帮你顶起!

出0入0汤圆

发表于 2010-5-14 22:34:30 | 显示全部楼层
好帖

出0入0汤圆

发表于 2010-5-14 23:46:23 | 显示全部楼层
ft.... 还是广告贴啊…… 无任何本质的信息量……
连route命令怎么设置路由都没有写,也就是教了一个如何设置net.ipv4.ip_forward……
如何永久启用也没提……

我建议想了解这方面信息的网友们,先好好在PC机上玩玩看看吧。
一般笔记本都有双网卡(无线网卡和有线网卡),足够玩这些了,嵌入式上的网络管理与那个无异。

出0入0汤圆

发表于 2010-5-18 09:17:56 | 显示全部楼层
路过,不懂。

出0入0汤圆

发表于 2010-5-18 09:25:11 | 显示全部楼层
有完整版的吗?
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-20 12:51

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表