zoukankan      html  css  js  c++  java
  • OpenWRT(RT5350) 路由客户模式(Routed Client) ,设置防火墙开放UDP指定端口

    /*

    *功     能: 本文主要功能是设置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格式配置文件。

    */

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

      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'

    更改wan lan 网络属性(wan dhcp,lan 静态ip)

      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'

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

      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

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

      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

  • 相关阅读:
    转 Java高级程序员面试题
    发个说说0.0
    SpringMvc和servlet对比
    java面试数据类型
    java面试 关键字
    Ajax与传统Web开发的区别
    ssm框架常见问题
    浅谈C++多态性
    [转载]构造函数、析构函数可否声明为虚函数
    为什么不要在构造函数和析构函数中调用虚函数?
  • 原文地址:https://www.cnblogs.com/general0878/p/4745559.html
Copyright © 2011-2022 走看看