0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenWrt 21.01 23.05 アクセスポイント Dumb ブリッジ

Last updated at Posted at 2023-07-06

こちらに統合しました

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • UCIとLuCi及びWinSCPにて比較しながら作業がおススメ

PowerShellSSHアクセス

ssh root@192.168.1.1
ssh root@192.168.1.1のショートカット作成(デスクトップ)
powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

  • 強制的に貼り付け
  • yes

SSHログイン出来ない場合:exclamation:

known_hostsクリア

  • C:\Users\yourusername\.ssh\known_hosts ※Windows隠しファイル
powershell
Clear-Content .ssh\known_hosts -Force


OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載

  • 機能の確認
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


前提条件

  • バージョン : 21.0.1 以降
  • 検証機器 : WTR-M2133HP(PR)/ WRS-6000AX8/ NCP-HG100
  • 要初期値設定
  • 要DHCPサーバー接続
  • 別途ワイヤレス設定

アクセスポイント設定

自動構成※要ONU直結

ワンコピペ自動スクリプト

/etc/config-software/dumb-config.sh
mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/dumb-config.sh https://raw.githubusercontent.com/site-u2023/config-software/main/dumb-config.sh; sh /etc/config-software/dumb-config.sh

※強制終了:Ctrl+c

  • 再起動後、設定時に指定したIPアドレスでログイン

自動構成の設定内容

#! /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"

改良された fping アプローチ

レストア

レストア

  • system
  • network
  • dhcp
  • firewall
  • dropbear
  • rc.local
  • crontabs
#cp /etc/config/system.dump.bak /etc/config/system
rm /etc/config/system.dump.bak
cp /etc/config/network.dump.bak /etc/config/network
rm /etc/config/network.dump.bak
cp /etc/config/dhcp.dump.bak /etc/config/dhcp
rm /etc/config/dhcp.dump.bak
cp /etc/config/firewall.dump.bak /etc/config/firewall
rm /etc/config/firewall.dump.bak
cp /etc/config/wireless.dump.bak /etc/config/wireless
rm /etc/config/wireless.dump.bak
cp /etc/config/dropbear.dump.bak /etc/config/dropbear
rm /etc/config/dropbear.dump.bak
/etc/init.d/odhcpd enable
/etc/init.d/odhcpd start
/etc/init.d/dnsmasq enable
/etc/init.d/dnsmasq start
/etc/init.d/firewall enable
/etc/init.d/firewall start
rm /etc/config-software/dumb.sh
sed -i "/fping -g 192.168.1.0/24/d" /etc/rc.local
sed -i "/fping -g 192.168.1.0/24/d" /etc/crontabs/root

reboot

あとがき

ブリッジ設定は毎度失敗するので、一発で完了するようにしてみた

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?