Firefly开源社区

打印 上一主题 下一主题

OpenWrt下将lan口变为wan方法

98

积分

9

威望

6

贡献

注册会员

Rank: 8Rank: 8

积分
98

OpenWrt下将lan口变为wan方法

发表于 2015-3-25 09:45:02      浏览:15772 | 回复:3        打印     [复制链接] 楼主
想要改变你的路由器wan口和lan口配置或者添加wan口等就需要用到vlan配置

openwrt中的配置文件为/etc/config/network

如下将port0设置为wan口
  1.     config switch_vlan  
  2.               option device eth0  
  3.               option vlan 0  
  4.               option ports "1 2 3 4 5*"            #port1、2、3、4和cpu 5属于vlan 0  
  5.       
  6.     config switch_vlan  
  7.               option device eth0  
  8.               option vlan 1  
  9.               option ports "0 5*"                    #port0和cpu 5属于vlan 1  
  10.       
  11.     config interface lan  
  12.               option type     bridge  
  13.               option ifname   eth0.0               #把vlan 0配置成lan口,即port1、2、3、4都是lan口了。  
  14.               option proto    static  
  15.               option ipaddr   192.168.0.168  
  16.               option netmask  255.255.255.0  
  17.               option gateway 192.168.0.1  
  18.               option dns 192.168.0.1  
  19.               option nat      1  
  20.       
  21.     config interface wan  
  22.               option ifname eth0.1                  #把vlan 1配置成wan口,即port0就是wan口了。  
  23.               option proto dhcp  
复制代码

上面的配置文件只有一个wan口

如果想要增加一个wan口,需要再增加一个config switch_vlan,如下
  1.     config switch_vlan  
  2.               option device eth0  
  3.               option vlan 0  
  4.               option ports "1 2 3 5*"               #port1、2、3和cpu 5属于vlan 0  
  5.       
  6.     config switch_vlan  
  7.               option device eth0  
  8.               option vlan 1  
  9.               option ports "0 5*"                    #port0和cpu 5属于vlan 1  
  10.       
  11.     config switch_vlan  
  12.               option device eth0  
  13.               option vlan 2  
  14.               option ports "4 5*"                    #port4和cpu 5属于vlan 2  
  15.       
  16.     config interface wan2  
  17.               option ifname eth0.2                 #把vlan 2配置成wan2口,即port4就是wan2了  
  18.               option proto dhcp  
复制代码

当然wan口增加了一个,lan口就要减少一个。配置这个的方法也可以看luci页面的额配置,更加直观。
回复

使用道具 举报

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

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表