Advertisement
hiro1357

IIJmio FiberAccess/NF 用DS-Liteルーターの構築

Jun 6th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.41 KB | None | 0 0
  1. #!/bin/bash
  2. # https://www.iij.ad.jp/dev/tech/techweek/pdf/141128_0.pdf を参考にした
  3. # ubuntu用
  4. # apt-get install firewalld されている前提
  5.  
  6. # DS-Liteでつなぐ
  7. modprobe ip6_tunnel
  8. ip -6 tunnel add ip6tnl1 mode ip4ip6 remote 2404:8e00::feed:100 local dead:beef:feed:100:dead:beef:feed:200 dev eth0
  9. ip link set dev ip6tnl1 up
  10.  
  11. # IP Forwardを有効にする
  12. sysctl net.ipv4.ip_forward=1
  13.  
  14. # ちからわざルーティング
  15. # 192.168.0.1はこのトンネル用マシン。含めてルーティングしてしまうとパケットがトンネルに流れてしまい、sshもつながらなくなる。
  16. # ちゃんと設定するなら、priorityを工夫してルーティングしてやるとよいのかもしれない。
  17. for ((ipcount=2; ipcount < 255; ipcount++)); do
  18.   ip rule add from 192.168.0.$ipcount table 10001 priority 32765
  19. done
  20. ip route add table 10001 dev ip6tnl1
  21. ip route add default dev ip6tnl1 metric 10001
  22. ip route flush cache
  23.  
  24. # ファイアウォールをてきとうに設定する
  25. firewall-cmd --permanent --zone=internal --add-masquerade
  26. firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o ip6tnl1 -j MASQUERADE
  27. firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i p1p1 -o ip6tnl1 -j ACCEPT
  28. firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ip6tnl1 -o p1p1 -m state --state RELATED,ESTABLISHED -j ACCEPT
  29. firewall-cmd --reload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement