您的位置:首页 > 运维架构

OpenWRT(RT5350) 路由客户模式(Routed Client) ,设置防火墙开放UDP指定端口

2015-08-20 16:20 363 查看
/*

*功 能: 本文主要功能是设置OpenWRT(RT5350) 系统实现路由客户模式,无线连接上级路由,

*      无线释放AP客户端,实现伪装的中继(子网段与上级路由网段不同),同时更改防火墙,

*      开放UDP端口,实现本地应用程序UDP通信。

*实现原理: 1、利用wan接口以sta模式无线连接上级路由,dhcp服务请求上级路由分配ip;

*      2、lan端口以桥接模式,指定静态ip,再利用lan口以ap模式桥接出一个ap client

*      3、更改防火墙zone wan lan端口输入输出链属性

*     4、更改防火墙wan 与 lan 通信

*      5、防火墙添加udp开放端口规则

*注 意: 本文针对网络参数的设定是通过OpenWRT config 配置文件实现,iptables防火墙也是

*     (不是传统iptables ,当然iptables也可以),都是uci格式配置文件。

*/

[b]利用wan接口以sta模式无线连接上级路由,lan桥接端口做ap客户端:[/b]

  1、在/etc/config/wireless 添加 wan lan 接口(wan sta模式,lan ap模式):

    例如:连接上级路由"eSo",本地ap客户端ssid "OpenWrt"    

    config wifi-iface
        option device radio0
        option network wan
        option mode 'sta'
        option ssid 'eSo'
        option encryption 'psk2'
        option key '20130828'

    config wifi-iface
        option device radio0
        option network lan
        option mode ap
        option ssid OpenWrt
        option encryption 'psk2'
        option key '20130828'

[b]更改wan lan 网络属性(wan dhcp,lan 静态ip)[/b]

  1、在/etc/config/network 中更改wan lan 属性:(lan 网段更改为192.168.10.1,网关应该是192.168.1.1,这里可以省略)  

    config interface 'lan'
        option ifname 'eth0'
        option macaddr '02:0c:43:30:50:18'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.10.1'
        option netmask '255.255.255.0'

    config interface 'wan'
        option proto 'dhcp'
        option hostname 'wc'

[b]更改防火墙设定(/etc/config/firewall):[/b]

  1、更改防火墙zone wan lan端口输入输出链属性:   

    config zone
      option name lan
      list network 'lan'
      option input ACCEPT
      option output ACCEPT
      option forward ACCEPT

    config zone
      option name wan
      list network 'wan'
      list network 'wan6'
      option input ACCEPT
      option output ACCEPT
      option forward ACCEPT
      option masq 1
      option mtu_fix 1

   2、更改防火墙wan 与 lan 通信:   

    config forwarding
      option src lan
      option dest wan

    config forwarding
      option src wan
      option dest lan

[b]防火墙添加udp开放端口规则[/b]

  1、在/etc/firewall.user 文件中添加udp 开放端口(10000-10060)规则到防火墙  

    # This file is interpreted as shell script.
    # Put your custom iptables rules here, they will
    # be executed with each firewall (re-)start.

    # Internal uci firewall chains are flushed and recreated on reload, so
    # put custom rules into the root chains e.g. INPUT or FORWARD or into the
    # special user chains, e.g. input_wan_rule or postrouting_lan_rule.
    iptables -A FORWARD -j REJECT -p udp --dport 10000:10060
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: