Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PC_BからPC_A経由でモバイル無線ルータでWANに繋ぐ
- 構成:
- PC_A: wlan0 192.168.4.XXX/24 (DHCP,gateway 192.168.4.1) => ソフトバンクのモバイル無線ルータへ
- eth0 192.168.0.YYY/24 (DHCP,gateway 192.168.0.1) => 他の機器との接続用LAN
- eth0:2 192.168.5.1/24 (STATIC) => PC_Bとの接続用
- PC_B: eth0 192.168.0.ZZZ/24 (DHCP,gateway 192.168.0.1) => 他の機器との接続用LAN
- eth0:2 192.168.5.1/224 (STATIC,gateway 192.168.5.1) => PC_Bとの接続用
- PC_AとPC_Bのeth0はスイッチングハブ経由で接続されている
- 面倒なのでDHCPサーバとかDNSサーバは立てない.
- 名前解決は /etc/resolv.conf に
- nameserver 8.8.8.8 かルータのアドレスを入れる
- (1) PC_A の設定
- $ sudo ifconfig eth0:2 192.168.5.1/24
- $ sudo route del default gw 192.168.0.1
- これで
- $ route -n
- 0.0.0.0 192.168.4.1 0.0.0.0 UG 0 0 0 wlan0
- 192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
- 192.168.4.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0
- 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
- # ip masquerade の設定
- $ sudo sysctl -w net.ipv4.ip_forward=1
- $ sudo iptabels -P FORWARD ACCEPT
- $ sudo iptables -t nat -A POSTROUTING -s 192.168.5.0/24 -o wlan0 -j MASQUERADE
- (2) PC_B の設定
- $ sudo ifconfig eth0:2 192.168.5.2/24
- $ sudo route del default gw 192.168.0.1
- $ sudo route add default gw 192.168.5.1
- これで
- $ route -n
- 0.0.0.0 192.168.5.1 0.0.0.0 UG 0 0 0 eth0
- 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
- 192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
- 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
- となる.この状態でPC_Bで
- $ curl ifconfig.me/host
- すればちゃんとモバイル無線ルータでWAN接続できてるのが確認できる
Advertisement
Add Comment
Please, Sign In to add comment