/
dumb.sh
85 lines (78 loc) · 2.67 KB
/
dumb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh
IPADDR='192.168.1.2'
GATEWAY='192.168.1.1'
LAN_DEVICE=`uci get network.lan.device`
# ネットワークを変更する
cp /etc/config/system /etc/config/system.dump.bak
cp /etc/config/network /etc/config/network.dump.bak
cp /etc/config/dhcp /etc/config/dhcp.dump.bak
cp /etc/config/firewall /etc/config/firewall.dump.bak
cp /etc/config/wireless /etc/config/wireless.dump.bak
cp /etc/config/dropbear /etc/config/dropbear.dump.bak
uci delete network.wan
uci delete network.wan6
uci delete network.lan
uci delete system.ntp.server
uci -q delete network.globals.ula_prefix
# IPV4
uci add_list network.@device[0].ports='wan'
BRIDGE='bridge'
uci set network.${BRIDGE}=interface
uci set network.${BRIDGE}.proto='static'
uci set network.${BRIDGE}.device=${LAN_DEVICE}
uci set network.${BRIDGE}.ipaddr=${IPADDR}
uci set network.${BRIDGE}.netmask='255.255.255.0'
uci set network.${BRIDGE}.gateway=${GATEWAY}
uci set network.${BRIDGE}.dns=${GATEWAY}
uci set network.${BRIDGE}.delegate='0'
# IPV6
BRIDGE6='bridge6'
uci set network.${BRIDGE6}=interface
uci set network.${BRIDGE6}.proto='dhcpv6'
uci set network.${BRIDGE6}.device=@${BRIDGE}
uci set network.${BRIDGE6}.reqaddress='try'
uci set network.${BRIDGE6}.reqprefix='no'
uci set network.${BRIDGE6}.type='bridge'
# 既存のワイヤレスネットワークを変更する
uci set wireless.default_radio0.network=${BRIDGE}
uci set wireless.default_radio1.network=${BRIDGE}
# NTPサーバー
uci set system.ntp=timeserver
uci set system.ntp.enable_server='0'
uci set system.ntp.use_dhcp='1'
uci set system.ntp.server=${GATEWAY}
# マルチキャスト
uci set network.globals.packet_steering='1'
uci set network.globals.igmp_snooping='1'
#
uci set dropbear.@dropbear[0].Interface=${BRIDGE}
uci commit
# DHCPサーバーを無効にする
/etc/init.d/odhcpd disable
/etc/init.d/odhcpd stop
# DNSを無効にする
/etc/init.d/dnsmasq disable
/etc/init.d/dnsmasq stop
# ファイアウォールを無効にする
/etc/init.d/firewall disable
/etc/init.d/firewall stop
# wpa_supplicantを無効にする
rm /usr/sbin/wpa_supplicant
# {
# デーモンを永続的に無効にする
# for i in firewall dnsmasq odhcpd; do
# if /etc/init.d/"$i" enabled; then
# /etc/init.d/"$i" disable
# /etc/init.d/"$i" stop
# fi
# done
# }
# 複数の AP にわたってホスト名を表示できるようにする
opkg update
opkg install fping
opkg install arp-scan
sed -i "/exit 0/d" /etc/rc.local
echo "arp-scan -qxlN -I br-lan | awk '{print $1}' | xargs fping -q -c1" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
echo "0 */1 * * * arp-scan -qxlN -I br-lan | awk '{print $1}' | xargs fping -q -c1" >> /etc/crontabs/root
echo -e "\033[1;35m ${BRIDGE} device: br-lan\033[0;39m"