openwrt生成随机mac地址
来源:互联网 发布:淘宝模特余潇潇 编辑:程序博客网 时间:2024/05/17 07:40
某些场景下, 需要使用不同的MAC地址与外界通信,查询了部分资料, 现记录如下:
1.生成MAC地址命令如下:
dd if=/dev/urandom bs=1 count=32 2>/dev/null | md5sum | cut -b 0-12 | sed 's/\(..\)/\1:/g; s/.$//'
2.openwrt通过MACVLAN使用不同的MAC地址与WAN口设备通信:
(添加到/etc/rc.local文件中, 以便开机自动运行)
<pre name="code" class="plain"># set up virtual mac addresses as aliases on the main WAN i/f eth0.2 ip link add link eth0.2 eth2 type macvlanifconfig eth2 hw ether `<pre name="code" class="plain">dd if=/dev/urandom bs=1 count=32 2>/dev/null | md5sum | cut -b 0-12 | sed 's/\(..\)/\1:/g; s/.$//'` ip link add link eth0.2 eth3 type macvlanifconfig eth3 hw ether `dd if=/dev/urandom bs=1 count=32 2>/dev/null | md5sum | cut -b 0-12 | sed 's/\(..\)/\1:/g; s/.$//'` ip link add link eth0.2 eth4 type macvlanifconfig eth4 hw ether `dd if=/dev/urandom bs=1 count=32 2>/dev/null | md5sum | cut -b 0-12 | sed 's/\(..\)/\1:/g; s/.$//'` ip link add link eth0.2 eth5 type macvlanifconfig eth5 hw ether `dd if=/dev/urandom bs=1 count=32 2>/dev/null | md5sum | cut -b 0-12 | sed 's/\(..\)/\1:/g; s/.$//'`ifup eth2ifup eth3ifup eth4ifup eth5 # default routeroute add default gw 192.168.188.1 dev eth0.2
3.添加openwrt接口规则
在/etc/config/network中加入我们上面添加的interface:
config 'interface' 'wan2' option 'ifname' 'eth2' option 'proto' 'dhcp' option 'defaultroute' '0' option 'peerdns' '0' option 'gateway' '0.0.0.0
4.添加openwrt防火墙规则
在/etc/config/firewall中加入上面添加的interface
config zone option name wan1 option network 'wan1' option input REJECT option output ACCEPT option forward REJECT option masq 1 option mtu_fix 1 # forwards from 1st WAN i/f to SP2010 Web01config redirect option src wan1 option src_dport 3389 option proto tcp option dest_ip 192.168.188.94
5.如需访问路由器前端的modem或者其他设备
添加alias接口,以便openwrt的wan能够直接访问modem, 然后使用iptables规则, 将访问请求改写src ip为alias接口的IP
config 'alias' option 'interface' 'wan' option 'proto' 'static' option 'ipaddr' '192.168.0.2' option 'netmask' '255.255.255.0'
iptables -t nat -I postrouting_rule -s 192.168.188.0/24 -d 192.168.1.1 -j SNAT --to 192.168.1.99iptables -I zone_lan_forward -s 192.168.1.0/24 -d 192.168.1.99 -j ACCEPT或者
MODEMIP=192.168.0.1 MODEM_NET=`echo $MODEMIP | cut -d "." -f 1-3` ROUTER_WAN_PORT_IP=192.168.0.2 WAN_PORT=eth0.2ifconfig $WAN_PORT $ROUTER_WAN_PORT_IP netmask 255.255.255.0 broadcast $MODEM_NET.255
iptables -A forwarding_rule -d $MODEMIP -j ACCEPT iptables -t nat -A postrouting_rule -d $MODEMIP -o $WAN_PORT -j MASQUERADE
参考资料:
http://osxdaily.com/2010/11/10/random-mac-address-generator/
https://shuggill.wordpress.com/2012/08/22/configuring-multiple-public-dhcp-ip-addresses-on-a-linksys-wrt54g-with-openwrt/
-全文完-
0 0
- openwrt生成随机mac地址
- 随机MAC地址生成
- bash 随机生成mac地址及qemu指定随机mac
- uboot生成随机的MAC地址
- OpenWRT 修改MAC地址
- Openwrt 修改Mac地址
- Openwrt 修改Mac地址
- openwrt 随机 ssid 随机 mac 脚本
- Java随机生成Mac地址(GitHub源码下载)
- 随机设置MAC地址
- openWRT如何修改MAC地址
- 修改rt5350 openwrt的 mac地址
- Openwrt永久修改MAC地址源代码
- openwrt MT7620的无线MAC地址修改
- openwrt默认mac地址配置(MT7620a)
- 随机生成imei imsi mac
- 随机生成 imsi imei mac
- 如何将随机生成的安卓手机mac地址改为固定
- 杭电OJ 2039
- jquery给每个a标签添加点击事件
- 《大话数据结构》
- nbd挂载方式修改虚拟机镜像密码
- 击鼓传花
- openwrt生成随机mac地址
- 图片选择器, 支持多图选择和图片预览等功能
- 【原创】黑科技库(一):*max_element && *min_element 数组最值
- Python菜鸟--模块
- java正则表达式获取指定HTML标签的指定属性值且替换
- 《大话数据结构》
- Xml文件约束规则使用详解
- mybatis中foreach的使用
- 正则规则