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?

More than 1 year has passed since last update.

無線LANルーターを構築してみた

Posted at

PCって無線LANも有線LANのインタフェースもついてるから、もしかして無線LANアクセスポイントを買わなくても、インターネットにつなげるシステムを構成できるのでは?というのがモチベーション。できた。

システム構成は下図のような感じ。

勉強2023.png

設定概要は下図のような感じ。

勉強2023 (1).png

dsl-providerは以下の通り。プロバイダに接続するための設定。

noipdefault
defaultroute
replacedefaultroute
hide-password
noauth
persist
plugin rp-pppoe.so eth0
userpeerdns
user “xxxxx@xxxxx”

dhcpd.confは以下の通り。10.0.0.200〜254まで動的にIPを割り当てている。

dhcpd.conf
subnet 10.0.0.0 netmask 255.255.255.0 {
  option routers 10.0.0.1;
  option subnet-mask 255.255.255.0;
  range dynamic-bootp 10.0.0.200 10.0.0.254;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  option broadcast-address 10.0.0.255;
}

hostapd.confは以下の通り。無線LANアクセスポイントデーモンを起動するための設定ファイル。SSIDとパスワードは適宜設定する。

hostapd.conf
interface=wlan0
driver=nl80211
ssid=xxxxx
hw_mode=g
channel=7
wpa=2
wpa_passphrase=xxxxx
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

rc.localは以下の通り。念の為ufwとPPP接続をやりなおしている。うまくつながったらセキュリティアップデートを実行する。

rc.local
/usr/sbin/ufw disable
/usr/sbin/ufw enable
/usr/bin/poff dsl-provider
/bin/sleep 5
/usr/bin/pon dsl-provider
/bin/sleep 5
/sbin/ip addr show dev ppp0
if [ $? -eq 1 ]; then
    exit 1
fi
DEBIAN_FRONTEND=noninteractive
(/usr/bin/apt update && /usr/bin/apt upgrade -y) >/tmp/apt_stdout.log 2>&1
exit 0

interfacesは以下の通り。インターネット側はppp0(eth0)、内部ネットワーク側はwlan0としている。

allow-hotplug eth0
iface eth0 inet manual
	pre-up /sbin/ifconfig eth0 up
	up ifup ppp0=dsl-provider
	down ifdown ppp0=dsl-provider
	post-down /sbin/ifconfig eth0 down
# The following is used internally only
iface dsl-provider inet ppp
	provider dsl-provider

allow-hotplug wlan0
iface wlan0 inet static
	address 10.0.0.1
	netmask 255.255.255.0

before.rulesは以下の通り。eth0、ppp0にIPマスカレードを行う。片方でもいいかも。

before.rules
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
-A POSTROUTING -s 10.0.0.0/24 -o ppp0 -j MASQUERADE
COMMIT

sysctl.confは以下の通り。ルーティングしたいので転送を有効化する。

sysctl.conf
 #net/ipv4/ip_forward=1
net/ipv4/ip_forward=1
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?