找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 6083|回复: 9

请教各位大牛OpenWRT配置成路由的方法及相关配置文件

[复制链接]
各位老司机好,小弟现在手头有一块板子,4个lan口,1个wan口。
现在想要将4个lan口组成一个内部局域网,每个都配置IP。wan口作为对外通信口。这样的实现应该就是一个路由器吧?跪求各位大牛network配置文件。。。如果要保证内外部数据通信,是不是还要对iptables进行设置?也求一份配置文件。。。谢谢啦。。。



PS.小弟登录到后台看到如下:

那个显示CPU的接口应该也是Port 0吧?(我现在网线插在wan口上)

领导催的急,小弟没接触过这块,求各位大牛帮帮忙,再次跪谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
 楼主| | 显示全部楼层
每个lan口都要配IP,是不是要每个lan口做成vlan?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
  1. config interface 'loopback'
  2.         option ifname 'lo'
  3.         option proto 'static'
  4.         option ipaddr '127.0.0.1'
  5.         option netmask '255.0.0.0'

  6. config switch_vlan  
  7.     option device eth1  
  8.     option vlan 0  
  9.     option ports "0t 0"
  10.         
  11. config switch_vlan  
  12.     option device eth1  
  13.     option vlan 1  
  14.     option ports "0t 1"

  15. config switch_vlan  
  16.     option device eth1  
  17.     option vlan 2  
  18.     option ports "0t 2"
  19.         
  20. config switch_vlan  
  21.     option device eth1  
  22.     option vlan 3  
  23.     option ports "0t 3"

  24. config interface 'lan1'
  25.         option ifname 'eth1.0'
  26.         option type 'bridge'
  27.         option proto 'static'
  28.         option ipaddr '192.168.10.1'
  29.         option netmask '255.255.255.0'
  30.         
  31. config interface 'lan2'
  32.         option ifname 'eth1.1'
  33.         option type 'bridge'
  34.         option proto 'static'
  35.         option ipaddr '192.168.10.2'
  36.         option netmask '255.255.255.0'
  37.         
  38. config interface 'lan3'
  39.         option ifname 'eth1.2'
  40.         option type 'bridge'
  41.         option proto 'static'
  42.         option ipaddr '192.168.10.3'
  43.         option netmask '255.255.255.0'
  44.         
  45. config interface 'lan4'
  46.         option ifname 'eth1.3'
  47.         option type 'bridge'
  48.         option proto 'static'
  49.         option ipaddr '192.168.10.4'
  50.         option netmask '255.255.255.0'

  51. config interface 'wan'
  52.         option ifname 'eth0'
  53.         option proto 'static'
  54.         option ipaddr '192.168.51.170'
  55.         option netmask '255.255.255.0'
复制代码

按上面的方式做了之后,生成了4个接口
  1. root@OpenWrt:~# ifconfig
  2. br-lan1   Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  3.           inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
  4.           inet6 addr: fe80::1e40:e8ff:feff:2/64 Scope:Link
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  6.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  7.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  8.           collisions:0 txqueuelen:0
  9.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  10. br-lan2   Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  11.           inet addr:192.168.10.2  Bcast:192.168.10.255  Mask:255.255.255.0
  12.           inet6 addr: fe80::1e40:e8ff:feff:2/64 Scope:Link
  13.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  14.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  15.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  16.           collisions:0 txqueuelen:0
  17.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  18. br-lan3   Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  19.           inet addr:192.168.10.3  Bcast:192.168.10.255  Mask:255.255.255.0
  20.           inet6 addr: fe80::1e40:e8ff:feff:2/64 Scope:Link
  21.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  22.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  23.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  24.           collisions:0 txqueuelen:0
  25.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  26. br-lan4   Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  27.           inet addr:192.168.10.4  Bcast:192.168.10.255  Mask:255.255.255.0
  28.           inet6 addr: fe80::1e40:e8ff:feff:2/64 Scope:Link
  29.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  30.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  31.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  32.           collisions:0 txqueuelen:0
  33.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  34. eth0      Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:01  
  35.           inet addr:192.168.51.170  Bcast:192.168.51.255  Mask:255.255.255.0
  36.           inet6 addr: fe80::1e40:e8ff:feff:1/64 Scope:Link
  37.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  38.           RX packets:2583 errors:0 dropped:12 overruns:0 frame:0
  39.           TX packets:702 errors:0 dropped:0 overruns:0 carrier:0
  40.           collisions:0 txqueuelen:1000
  41.           RX bytes:321023 (313.4 KiB)  TX bytes:251470 (245.5 KiB)

  42. eth1      Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  43.           inet6 addr: fe80::1e40:e8ff:feff:2/64 Scope:Link
  44.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  45.           RX packets:452 errors:0 dropped:0 overruns:0 frame:0
  46.           TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
  47.           collisions:0 txqueuelen:1000
  48.           RX bytes:85332 (83.3 KiB)  TX bytes:3770 (3.6 KiB)

  49. eth1.0    Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  50.           UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
  51.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  52.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  53.           collisions:0 txqueuelen:0
  54.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  55. eth1.1    Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  56.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  57.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  58.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  59.           collisions:0 txqueuelen:0
  60.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  61. eth1.2    Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  62.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  63.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  64.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  65.           collisions:0 txqueuelen:0
  66.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  67. eth1.3    Link encap:Ethernet  HWaddr 1C:40:E8:FF:00:02  
  68.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  69.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  70.           TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
  71.           collisions:0 txqueuelen:0
  72.           RX bytes:0 (0.0 B)  TX bytes:738 (738.0 B)

  73. lo        Link encap:Local Loopback  
  74.           inet addr:127.0.0.1  Mask:255.0.0.0
  75.           inet6 addr: ::1/128 Scope:Host
  76.           UP LOOPBACK RUNNING  MTU:65536  Metric:1
  77.           RX packets:3989 errors:0 dropped:0 overruns:0 frame:0
  78.           TX packets:3989 errors:0 dropped:0 overruns:0 carrier:0
  79.           collisions:0 txqueuelen:0
  80.           RX bytes:271252 (264.8 KiB)  TX bytes:271252 (264.8 KiB)
复制代码



但是,lan口一直ping不通,我用的电脑直连网线,wan口直连可以ping通。


求教一下各位大大这是什么情况
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

最好贴出此版的型号参数,运行的系统等等,估计才能对症下药!
这路由配置,原理差不多,实现途径千奇百怪!

点评

[attachimg]143219[/attachimg] 这样的信息够吗?运行的系统不知道你指的是什么  详情 回复 发表于 2016-11-3 17:30
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报


1 内网IP
2 外网IP

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

你好,我的页面上面找不到你这个配置的地方,不知道出了什么问题,能否共享下你的network配置文件?谢谢啦  详情 回复 发表于 2016-11-3 17:33
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
netsnake 发表于 2016-11-3 16:44
最好贴出此版的型号参数,运行的系统等等,估计才能对症下药!
这路由配置,原理差不多,实现途径千奇百怪 ...



这样的信息够吗?运行的系统不知道你指的是什么

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
wuzhang 发表于 2016-11-3 16:57
1 内网IP
2 外网IP

你好,我的页面上面找不到你这个配置的地方,不知道出了什么问题,能否共享下你的network配置文件?谢谢啦

点评

config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config globals 'globals' option ula_prefix 'fdcd:f22f:4181::/48  详情 回复 发表于 2016-11-3 22:44
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

说明使用的openwrt固件种类及版本才好!是吧!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

本帖最后由 wuzhang 于 2016-11-3 22:46 编辑
Int_Null 发表于 2016-11-3 17:33
你好,我的页面上面找不到你这个配置的地方,不知道出了什么问题,能否共享下你的network配置文件?谢谢 ...

我这个配置的地方就是 你那张图啊


config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdcd:f22f:4181::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option macaddr '20:76:93:00:30:8c'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config device 'lan_dev'
        option name 'eth0.1'
        option macaddr '20:76:93:00:30:8c'

config interface 'wan'
        option macaddr '20:76:93:00:30:8d'
        option proto 'dhcp'
        option type 'bridge'
        option _orig_ifname 'eth0.2'
        option _orig_bridge 'true'
        option ifname 'eth0.2'

config device 'wan_dev'
        option name 'eth0.2'
        option macaddr '20:76:93:00:30:8d'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option vid '1'
        option ports '6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option vid '2'
        option ports '0 5 6t'

config switch_vlan
        option device 'switch0'
        option vlan '3'
        option vid '3'


我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

正在学习,收藏下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 00:58

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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