Guest User

Untitled

a guest
Apr 28th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. PC_BからPC_A経由でモバイル無線ルータでWANに繋ぐ
  2.  
  3. 構成:
  4. PC_A: wlan0 192.168.4.XXX/24 (DHCP,gateway 192.168.4.1) => ソフトバンクのモバイル無線ルータへ
  5. eth0 192.168.0.YYY/24 (DHCP,gateway 192.168.0.1) => 他の機器との接続用LAN
  6. eth0:2 192.168.5.1/24 (STATIC) => PC_Bとの接続用
  7. PC_B: eth0 192.168.0.ZZZ/24 (DHCP,gateway 192.168.0.1) => 他の機器との接続用LAN
  8. eth0:2 192.168.5.1/224 (STATIC,gateway 192.168.5.1) => PC_Bとの接続用
  9.  
  10. PC_AとPC_Bのeth0はスイッチングハブ経由で接続されている
  11.  
  12. 面倒なのでDHCPサーバとかDNSサーバは立てない.
  13. 名前解決は /etc/resolv.conf に
  14. nameserver 8.8.8.8 かルータのアドレスを入れる
  15.  
  16. (1) PC_A の設定
  17. $ sudo ifconfig eth0:2 192.168.5.1/24
  18. $ sudo route del default gw 192.168.0.1
  19. これで
  20. $ route -n
  21. 0.0.0.0 192.168.4.1 0.0.0.0 UG 0 0 0 wlan0
  22. 192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
  23. 192.168.4.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0
  24. 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
  25.  
  26. # ip masquerade の設定
  27. $ sudo sysctl -w net.ipv4.ip_forward=1
  28. $ sudo iptabels -P FORWARD ACCEPT
  29. $ sudo iptables -t nat -A POSTROUTING -s 192.168.5.0/24 -o wlan0 -j MASQUERADE
  30.  
  31. (2) PC_B の設定
  32. $ sudo ifconfig eth0:2 192.168.5.2/24
  33. $ sudo route del default gw 192.168.0.1
  34. $ sudo route add default gw 192.168.5.1
  35. これで
  36. $ route -n
  37. 0.0.0.0 192.168.5.1 0.0.0.0 UG 0 0 0 eth0
  38. 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
  39. 192.168.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
  40. 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
  41.  
  42. となる.この状態でPC_Bで
  43. $ curl ifconfig.me/host
  44. すればちゃんとモバイル無線ルータでWAN接続できてるのが確認できる
Advertisement
Add Comment
Please, Sign In to add comment