Wifiで受信したネットワークにLANで接続する機器も自動IP割り振りするような感じ
記載内容は参考サイトを自分用メモにしたのと、最後の箇所は、動作しなかったを解消調べ
1. /etc/network/interfacesの編集
###1.1.追加内容
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
###1.2.全体ソース
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
##2./etc/wpa_supplicant/wpa_supplicant.confの編集
Wifi接続情報を保持を複数を記述できるようです
###2.1.追加内容
network={
ssid="SSID"
psk="パスワード"
key_mgmt=WPA-PSK
scan_ssid=1
}
###2.2.全体ソース
/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP
network={
ssid="SSID"
psk="パスワード"
key_mgmt=WPA-PSK
scan_ssid=1
}
##3./etc/rc.localでIP forwardの設定
###3.1.追加内容
echo 1 > /proc/sys/net/ipv4/ip_forward
###3.2.全体ソース
/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
exit 0
##4.DHCPリレーエージェントのインストールと設定の編集
###4.1.インストール
sudo apt-get install dhcp-helper
##4.2./etc/default/dhcp-helperでDHCPリレーエージェントの設定を編集
###4.2.1.追加内容
DHCPHELPER_OPTS="-b wlan1"
###4.2.2.全体ソース
/etc/default/dhcp-helper
# Option flags used to start dhcp-helper.
#
# You will need at least "-s <DHCP server>" or
# "-b <interface> so that dhcp-helper knows where
# to relay DHCP requests.
#
# See "man 8 dhcp-helper" for more details.
DHCPHELPER_OPTS="-b wlan1"
##5.Proxy ARPブリッジのインストールと設定編集
###5.1.インストール
sudo apt-get install parprouted
##5.2./etc/rc.localでProxyでARPブリッジ設定を編集
###5.2.1.追加内容
ip addr add 192.168.1.203 dev eth0
parprouted wlan1 eth0
###5.2.2.全体ソース
/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
ip addr add 192.168.1.203 dev eth0
parprouted wlan1 eth0
exit 0
参考サイトはここまでで、動作しなかったので、追記した箇所は以下
##6.動作しないを解消
###6.1./etc/network/interfacesを編集
####6.1.1.追記内容
post-up /sbin/ip addr add $(/sbin/ip addr show wlan1 | perl -wne 'm|^\s+inet (.*)/| && print $1')/32 dev eth0
post-up /sbin/ifup eth0
post-up /usr/sbin/parprouted wlan1 eth0
post-up /etc/init.d/dhcp-helper start
post-down /usr/bin/killall /usr/sbin/parprouted
post-down /etc/init.d/dhcp-helper stop
post-down /sbin/ifdown eth0
####6.1.2.全体ソースコード
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
post-up /sbin/ip addr add $(/sbin/ip addr show wlan1 | perl -wne 'm|^\s+inet (.*)/| && print $1')/32 dev eth0
post-up /sbin/ifup eth0
post-up /usr/sbin/parprouted wlan1 eth0
post-up /etc/init.d/dhcp-helper start
post-down /usr/bin/killall /usr/sbin/parprouted
post-down /etc/init.d/dhcp-helper stop
post-down /sbin/ifdown eth0
##7.本体のWifiをOFF
OFF
sudo iwconfig wlan0 txpower off
ON
sudo iwconfig wlan0 txpower auto
##参考サイト
Raspberry Pi3を無線LANコンバータにする
http://rufas.manyoldmoon.com/blog/1604
Bridging Wireless & Ethernet networks with a Raspberry Pi
https://www.yergler.net/tag/network/