GProot@vps:/jails/bin # HP@qlHPsHP3  HP!: RCS equipment.rb mkserver readme.txt shcommand.rb bridge.rb jail.rb nwdiag2jail.rb router.rb unjail.rb data mkrouter operator.rb server.rb web.rb HP*; root@vps:/jails/bin # IP3-eIP~ mIPӷ aIPcsJP& JP jJPx aKPil.rb KP~ KP7[?47h[?25h=KPKPf[?25l-=--:----F1 *scratch*  All L1 (Fundamental) ---------------------------  [?25h[?25hKPhI a[?25lFor information about GNU Emacs and the GNU system, type C-h C-a. [?25h[?25hKP [?25lFor information about GNU Emacs and the GNU system, type C-h C-a.File Edit Options Buffers Tools Help  KP<  #!/usr/local/bin/ruby   # Internet Builder   # $Id: jail.rb,v 1.26 2012/12/08 23:39:47 root Exp $   # T.Suzuki   #  KP|  # before run this script   # make router0-9 , bridge0-3 , server1-3   # by using mkrouter and mkserver   # ex. mkrouter router0 ; mkrouter bridge0   KP;  require 'shell' require File.expand_path(File.dirname(__FILE__) + '/shcommand') require File.expand_path(File.dirname(__FILE__) + '/operator') require File.expand_path(File.dirname(__FILE__) + '/equipment') require File.expand_path(File.dirname(__FILE__) + '/router')KP i require File.expand_path(File.dirname(__FILE__) + '/bridge') require File.expand_path(File.dirname(__FILE__) + '/server')  # jails path   $jails="/jails"KP6  -=--:%%--F1 jail.rb  Top L1 RCS-1.26 (Ruby) -------------------------  [?25h[?25hLP-  [?25l$jails="/jails"  ###############################################################Main  ###############################################################  ###############################################################Setup Backborn realsever-epair0b-(epair0a-router0-epair1a-epair1b-bridge0) ################################################################   # tomocha as a manager of epairs  tomocha=Operator.new  # create router and connect to realserver  # * bin/mkrouter router0 before run this script  outer0=Router.new("router0") tomocha.createpair ifconfig("epair0a inet 192.168.1.1LPG netmask 255.255.255.0") ifconfig("epair0a up") router0.connect("epair0b")13% L20 [?25h[?25hNPm[?25lifconfig("epair0a up") router0.connect("epair0b") router0.assignip("epair0b","192.168.1.254","255.255.255.0") tomocha.register("router0","epair0b","192.168.1.254","255.255.255.0") # you nee\ d this if you did not use $tomocha.assignip .  router0.up("epair0b") router0.start("quagga") connect gateway to inner segment bridge (IX)   * bin/mkrouter bridge0 before run this script  bridge0=Bridge.new("bridge0") bridge0.on .createpair router0.connect("epair1a") router0.assignip("epair1a","192.168.0.254","255.255.255.0") tomocha.register("epair1a","router0","192.168.0.254","255.255.NP255.0") bridge0.connect("epair1b") register("epair1b","bridge0","","") bridge0.up("epair1b") #  # create root server and connect to gateway  25% L39 [?25h[?25hPP }t[?25l#  # create root server and connect to gateway  # * bin/mkrouter server0 before run this script  server0=Server.new("server0") tomocha.createpairPP} server0.connect("epair2a") server0.assignip("epair2a","192.168.255.1","255.255.255.0") tomocha.register("epair2a","server0","192.168.255.1","255.255.255.0") server0.up("epair2a") router0.connect("epair2b") router0.assignip("epair2b","192.168.255.2","255.255.255.0") tomocha.register("epair2b","router0","192.168.255.2","255.255.255.0") router0.up("epair2b") server0.assigngw("192.168.255.2") server0.start("nsd")  ##########################################################################  # Your own network  ##########################################################################   ## Setup ISP ### PP}L 37% L57 [?25h[?25hQPAY [?25l## Setup ISP ###  0.upto(2) do |gnum| #  ## Setup ISP BGP Router  #  rname0 = "router" + (1+gnum*3).to_s ip = gnum + 1 tomocha.setuprouter(rname0) # connect to bridge0  QP^ n=tomocha.createpair tomocha.connect(rname0,"epair#{n}a") tomocha.assignip(rname0,"epair#{n}a","192.168.0.#{ip}",'255.255.255.0') tomocha.up(rname0,"epair#{n}a bridge0.connect("epair#{n}b")QP)bridge0.up("epair#{n}b") tomocha.register("epair#{n}b","bridge0","","") tomocha.start(rname0,"quagga") #  ## setup customer bgp router   [2@ 51% L76 [?25h[?25hSP )SP [?25l## setup customer bgp router  rname1="router" + (2+gnum*3).to_s seg=gnum+2tomocha.setuprouter(rname1)SPc connect to ispn=tomocha.createpairtomocha.connect(rname1,"epair#{n}a")ip="192.168.#{seg}.2"tomocha.assignip(rname1,"epair#{n}a","#{ip}",'255.255.255.0')tomocha.up(rname1,"epair#{n}a") bip="192.168.#{seg}.1"assignip(rname0,"epair#{n}b","#{ip}",'255.255.255.0')tomocha.up(rname[2@0,SP |tomocha.start(rname1,"quagga")#  ## setup customer ospf router  assign /20 rname2="router" + (3+gnum*3).to_s60% L95 [?25h[?25hUP'7B[?25l rname2="router" + (3+gnum*3).to_stomocha.setuprouter(rname2) tomocha.connect(rname2,"epair#{n}a") seg=gnum*16ip="172.16.#{seg}.2"tomocha.assignip(rname2,"epair#{n}a","#{ip}",'255.255.255.0')up(rname2,"epair#{n}a")UPZ7connect(rname1,"epair#{n}b")ip="172.16.#{seg}.1"tomocha.assignip(rname1,"epair#{n}b","#{ip}",'255.255.255.0')up(rname1,"epair#{n}b")start(rname2,"quagga")#  # setup customer server segment bridge="bridge" + (gnum+1).to_s tomocha.setupbridge(bridge)n=tomocha.createpair71% L114 [?25h[?25hWP*WPJ[?25ltomocha.setupbridge(bridge)+154"WP_ tomocha.connect(bridge,"epair#{n}b") tomocha.up(bridge,"epair#{n}b") #  ## setup servers  servername="server" + (1+gnum).to_s ip="172.16.#{seg}.1" gw="172.16.#{seg}.254" tomocha.setupserver(servername) connect to bridge n=tomocha.createpairtomocha.connect(servername,"epair#{n}a")assignip(servername,"epair#{n}a","#{ip}",'255.255.255.0')tomocha.assigngw(servername,gw) 82% L133 [?25h[?WP25hYPHYPH[?25lassignip(servername,"epair#{n}a","#{ip}",'255.255.255.0')tomocha.assigngw(servername,gw)up(servernameYPI end  tomocha.start("server1","nsd") tomocha.start("server1","unbound") YPdI|  make nwdiag [2@  puts "Now I'm drawing network diagram!" f=open("./data/net.diag","w")f.puts tomocha.gendiag f.close system('nwdiag -o ./data/net.png ./data/net.diag')  puts "Finish!"   Bot L152 [?25h[?25h[P+V[?25l(No files need saving) [?25h[?25h>[?25h[?47l8 [PDroot@vps:/jails/bin # \P:.\P4W /\Pj]PVa]P{il.rb ]P  ]P: Hi, I'll do your job. `Prouter1 done! aPԯ!epair3a is connected to router1 aP3epair3a of router1 has 192.168.0.1/255.255.255.0. aP epair3a up. aPL start quagga on router1. bPkrouter2 done! bPc!epair4a is connected to router2 bPqa3epair4a of router2 has 192.168.2.2/255.255.255.0. bPI` epair4a up. bP^!epair4b is connected to router1 bPW 3epair4b of router1 has 192.168.2.1/255.255.255.0. bPR epair4b up. bP>K start quagga on router2. cPhrouter3 done! cPa!epair5a is connected to router3 cP2epair5a of router3 has 172.16.0.2/255.255.255.0. cPt epair5a up. cP !epair5b is connected to router2 cP 2epair5b of router2 has 172.16.0.1/255.255.255.0. cP epair5b up. cP start quagga on router3. dPbridge1 done! dP8 !epair6a is connected to router3 dP]| 4epair6a of router3 has 172.16.1.254/255.255.255.0. dPs epair6a up. eP2!epair6b is connected to bridge1 eP1 epair6b up. ePserver1 done! eP !epair7a is connected to server1 eP9 2epair7a of server1 has 172.16.1.1/255.255.255.0. eP ,assign 172.16.1.254 as gateway of server1. eP epair7a up. fP#!epair7b is connected to bridge1 fP epair7b up. fProuter4 done! fP\ !epair8a is connected to router4 fP 3epair8a of router4 has 192.168.0.2/255.255.255.0. fPo epair8a up. gP`start quagga on router4. gPI router5 done! gPL!epair9a is connected to router5 hPq3epair9a of router5 has 192.168.3.2/255.255.255.0. hP  epair9a up. hP!epair9b is connected to router4 hPi3epair9b of router4 has 192.168.3.1/255.255.255.0. hPZ epair9b up. hPstart quagga on router5. hP3 router6 done! iP"epair10a is connected to router6 iP4epair10a of router6 has 172.16.16.2/255.255.255.0. iPepair10a up. iP"epair10b is connected to router5 iPɉ4epair10b of router5 has 172.16.16.1/255.255.255.0. iPepair10b up. iPstart quagga on router6. jP9bridge2 done! jP9"epair11a is connected to router6 jP=6epair11a of router6 has 172.16.17.254/255.255.255.0. jP@epair11a up. jPD "epair11b is connected to bridge2 jPF epair11b up. kPPserver2 done! kP"epair12a is connected to server2 kP~ 4epair12a of server2 has 172.16.17.1/255.255.255.0. kP -assign 172.16.17.254 as gateway of server2. kP epair12a up. kPT "epair12b is connected to bridge2 kP epair12b up. lProuter7 done! lPz"epair13a is connected to router7 lP4epair13a of router7 has 192.168.0.3/255.255.255.0. lPepair13a up. lP start quagga on router7. mProuter8 done! mPB"epair14a is connected to router8 mP 4epair14a of router8 has 192.168.4.2/255.255.255.0. mP̄ epair14a up. mP "epair14b is connected to router7 mPM 4epair14b of router7 has 192.168.4.1/255.255.255.0. mP epair14b up. mP@start quagga on router8. nPv:router9 done! nP6 "epair15a is connected to router9 nP@2 4epair15a of router9 has 172.16.32.2/255.255.255.0. nP?/ epair15a up. nP2 "epair15b is connected to router8 nP*4epair15b of router8 has 172.16.32.1/255.255.255.0. nP'epair15b up. oPstart quagga on router9. oP* bridge3 done! pP"epair16a is connected to router9 pP6epair16a of router9 has 172.16.33.254/255.255.255.0. pPepair16a up. pP"epair16b is connected to bridge3 pPepair16b up. pP݊ server3 done! qPr?"epair17a is connected to server3 qP=4epair17a of server3 has 172.16.33.1/255.255.255.0. qP7-assign 172.16.33.254 as gateway of server3. qPD6epair17a up. qP0"epair17b is connected to bridge3 qP 0epair17b up. qPi0start nsd on server1. qP2=start unbound on server1. Now I'm drawing network diagram! zPv Finish! zP<root@vps:/jails/bin # |P -j}Pl}PI s~PP ~P]< JID IP Address Hostname Path ~PP 19 - router0 /usr/local/jails/router0 ~PP 20 - bridge0 /usr/local/jails/bridge0 ~PTP 21 - server0 /usr/local/jails/server0 ~PP 22 - router1 /usr/local/jails/router1 ~PP 23 - router2 /usr/local/jails/router2 ~PP 24 - router3 /usr/local/jails/router3 ~PVP 25 - bridge1 /usr/local/jails/bridge1 ~PP 26 - server1 /usr/local/jails/server1 ~PP 27 - router4 /usr/local/jails/router4 ~P5P 28 - router5 /usr/local/jails/router5 ~P]P 29 - router6 /usr/local/jails/router6 ~PP 30 - bridge2 /usr/local/jails/bridge2 ~PP 31 - server2 /usr/local/jails/server2 ~PP 32 - router7 /usr/local/jails/router7 ~PhP 33 - router8 /usr/local/jails/router8 ~PP 34 - router9 /usr/local/jails/router9 ~P P 35 - bridge3 /usr/local/jails/bridge3 ~P3P 36 - server3 /usr/local/jails/server3 ~Proot@vps:/jails/bin # P<jPVePxec P sP ePrP& P PRP rP̃ oPJb uPtPՖeP0rP2P  P tPcP'TsPd(hP P router2# P'lPy9sP P .cshrc boot media root var PAf.profile dev mnt sbin COPYRIGHT etc pkg sys basejail lib proc tmp bin libexec rescue usr P router2# PiPfP$qcPooP nP fP6 iP6gP  P {lo0: flags=8049 metric 0 mtu 16384 options=600003 P  inet6 ::1 prefixlen 128 Pe! . inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 P! % inet 127.0.0.1 netmask 0xffffff00 P%" , nd6 options=21 P[ Oepair4a: flags=8843 metric 0 mtu 1500 P[ n options=8 ether 02:c0:e4:00:04:0a inet 192.168.2.2 netmask 0xffffff00 broadcast 192.168.2.255 Pj\ inet6 fe80::c0:e4ff:fe00:40a%epair4a prefixlen 64 scopeid 0x2 nd6 options=21 media: Ethernet 10Gbase-T (10Gbase-T ) status: active P\ epair5b: flags=8843 metric 0 mtu 1500 options=8 ether 02:c0:e4:00:05:0b inet 172.16.0.1 netmask 0xffffff00 broadcast 172.16.0.255 inet6 fe80::c0:e4ff:fe00:50b%epair5b prefixlen 64 scopeid 0x3 PS] s nd6 options=21 media: Ethernet 10Gbase-T (10Gbase-T ) status: active P_ router2# PJJtP eP* lPL nPePUtP# PN9lPb oP cPR aPlPihPooP0_sP"ptP< P> bP! gP-!pPeNdP PdTrying ::1... PfConnected to localhost. PfEscape character is '^]'. Pj{ Hello, this is Quagga (version 0.99.20). Copyright 1996-2005 Kunihiro Ishiguro, et al. User Access Verification PKk Password: P/  bgpd> P6ePnPi bgpd# P/GsPvhPh P|iPnpPE  P? bPgPpP2XW BGP table version is 0, local router ID is 192.168.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, R Removed Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 0.0.0.0 192.168.2.1 0 65001 65000 ? *> 172.16.0.0/20 0.0.0.0 0 32768 i *> 192.168.1.0 192.168.2.1 0 65001 65000 i *> 192.168.2.0 192.168.2.1 0 0 65001 i *> 192.168.3.0 192.168.2.1 0 65001 65002 i *> 192.168.4.0 192.168.2.1 0 65001 65003 i *> 192.168.255.0 192.168.2.1 0 65001 65000 i Total number of prefixes 7 bgpd# PsPuhPz P; rP uPnPX Current configuration: ! hostname bgpd password zebra log stdout ! router bgp 65004 bgp router-id 192.168.2.2 network 172.16.0.0/20 neighbor 192.168.2.1 remote-as 65001 ! line vty ! end bgpd# PY eP}xPA7iPtPi  P $Connection closed by foreign host. P router2# P+telnet localhost bgpdPWP P P PȊP)_oPF sP9 pPfP-"dPW PTrying ::1... Pu4Connected to localhost. Escape character is '^]'. PU{ Hello, this is Quagga (version 0.99.20). Copyright 1996-2005 Kunihiro Ishiguro, et al. User Access Verification P Password: P ospfd> PePnP ospfd# P sPS hP   P iPypP P(i oPsP۹pPfP PՋ rP/ oPw uP*tPeP| ============ OSPF network routing table ============ N 172.16.0.0/24 [10] area: 0.0.0.0 directly attached to epair5b N 172.16.1.0/24 [20] area: 0.0.0.0 via 172.16.0.2, epair5b ============ OSPF router routing table ============= ============ OSPF external routing table =========== ospfd# P9sPChP P~BrPuP5nPN' 4 Current configuration: ! hostname ospfd password zebra log stdout ! ! ! interface epair2b ! interface epair4a ! interface epair5b ! interface lo0 ! router ospf redistribute bgp passive-interface epair2b network 172.16.0.0/24 area 0.0.0.0 default-information originate --More-- P : ! line vty ! end ospfd# PePxP{ iP5tPh Pj$Connection closed by foreign host. Pn router2# P&HePmxP iPZa tP ^  P"_ exit Pxa root@vps:/jails/bin # P jexec router2 tcshP* P2 P6 Pz Py P PEaPZPUPPUPP4P  P7:PWPP_PPL P PJc sPū eP rP+ vP[ ePO rP 1P{  P* server1# P iPa fPF0cPoPnPfPiP;!gP P9Clo0: flags=8049 metric 0 mtu 16384 PQ8 options=600003 P inet6 ::1 prefixlen 128 P. inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 P#% inet 127.0.0.1 netmask 0xffffff00 PG, nd6 options=21 PQOepair7a: flags=8843 metric 0 mtu 1500 Pll options=8 ether 02:c0:e4:00:07:0a inet 172.16.1.1 netmask 0xffffff00 broadcast 172.16.1.255 PA inet6 fe80::c0:e4ff:fe00:70a%epair7a prefixlen 64 scopeid 0x2 P, nd6 options=21 P6 media: Ethernet 10Gbase-T (10Gbase-T ) P status: active P server1# PN{ iP8LP pPiPnPVgP  P1PE7PW2P'.P 1P}6Pr.P8S3PqF 3P.PK 1P`? P/PING 172.16.33.1 (172.16.33.1): 56 data bytes P<64 bytes from 172.16.33.1: icmp_seq=0 ttl=58 time=0.277 ms PR<64 bytes from 172.16.33.1: icmp_seq=1 ttl=58 time=0.171 ms Pr<64 bytes from 172.16.33.1: icmp_seq=2 ttl=58 time=0.162 ms PF<64 bytes from 172.16.33.1: icmp_seq=3 ttl=58 time=0.172 ms P̪ ^CPX --- 172.16.33.1 ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.162/0.196/0.277/0.047 ms P server1# P dPr iP5gP\8 P0YaP>f  PGMwPwPwPk.PwPiP9k nP eP1$.P nP(3oPǜ mP:S P D ; <<>> DiG 9.8.3-P2 <<>> a www.wine.nom ;; global options: +cmd P ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50525 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 P ;; QUESTION SECTION: ;www.wine.nom. IN A ;; ANSWER SECTION: www.wine.nom. 1800 IN A 172.16.1.1 ;; AUTHORITY SECTION: P {wine.nom. 1800 IN NS ns.wine.nom. ;; ADDITIONAL SECTION: ns.wine.nom. 1800 IN A 172.16.1.1 ;; Query time: 3 msec P $;; SERVER: 127.0.0.1#53(127.0.0.1) P :;; WHEN: Sun Dec 9 08:53:07 2012 ;; MSG SIZE rcvd: 79 P  P server1# P+3eP/+xPiPtP6w  Pw exit P root@vps:/jails/bin # PJeP! xP iP6tP#\ P4]exit