labunix's blog

labunixのラボUnix

EIGRPの負荷分散検証環境を追加する。

■EIGRPの負荷分散検証環境を追加する。
 スワップしない限り安定しているので、まだIOUを追加出来そう。

f:id:labunix:20180802234302p:plain

■KVMホスト全体で約28.7%のメモリ使用率。
 IOUを15台稼働させて合計のCPU使用率が17.9%、メモリ使用率が18.7%。

$ free -m | awk '/^[A-Z]/{a[$1]=$3/$2*100}END{for (n in a){print n,a[n]"%"}}'
Swap: 0%
Mem: 26.5915%

$ ps axo pid,pcpu,pmem,cmd | \
    awk 'BEGIN{l=0} /CPU|i86bi-linux-l/&&!/BEGIN/{cpu+=$2;mem+=$3;gsub("/.*/","",$0);print l,$0;l+=1} \
                END{print "Total "cpu,mem}'
0   PID %CPU %MEM CMD
1  2467  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 4
2  2468  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 5
3  2495  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 2
4  2516  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 6
5  2520  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 3
6  2539  1.1  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 1
7  2557  1.1  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 8
8  2560  2.1  0.5 i86bi-linux-l2-ipbasek9-15.1g.bin -e 8 -s 0 7
9 22033  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 10
10 22043  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 13
11 22063  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 9
12 22084  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 14
13 22086  1.2  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 12
14 22107  1.3  1.4 i86bi-linux-l3-adventerprisek9-15.5.2T.bin 11
Total 17.9 18.7

■まずは管理用のIPアドレスを振る。

$ echo "`seq 41 46`" | \
    awk '{print "[RR"$0%40"]\nconf t\n  int e1/0\n  ip address 192.168.0."$0" 255.255.255.0"} \
            {print "  no shut\n  end\nwrite mem"}'
[RR1]
conf t
  int e1/0
  ip address 192.168.0.41 255.255.255.0
  no shut
  end
write mem
[RR2]
conf t
  int e1/0
  ip address 192.168.0.42 255.255.255.0
  no shut
  end
write mem
[RR3]
conf t
  int e1/0
  ip address 192.168.0.43 255.255.255.0
  no shut
  end
write mem
[RR4]
conf t
  int e1/0
  ip address 192.168.0.44 255.255.255.0
  no shut
  end
write mem
[RR5]
conf t
  int e1/0
  ip address 192.168.0.45 255.255.255.0
  no shut
  end
write mem
[RR6]
conf t
  int e1/0
  ip address 192.168.0.46 255.255.255.0
  no shut
  end
write mem

■RR1~RR6までのtelnetの有効化

conf t
  enable password cisco
  line vty 0 4
    password cisco
    transport input telnet
  end
write mem

■RR1~RR6の待受ポートとしてsocatを起動

$ echo "`seq 41 46`" | awk '{print "socat tcp-listen:"$0"23,fork tcp-connect:192.168.0."$0":23 & "}' | sh

■mate-terminalで6つのタブとしてtelnetログイン

$ echo -e "`seq 41 46`" | \
    awk 'BEGIN{print "mate-terminal \\"} \
              {print "  -t 192.168.0."$0" --tab -e \042 ./mytel 172.31.31.92 "$0"23 \042 \\"} \
           END{print ""}' | sh

■サービス側のIPを振るスクリプトを作成

$ echo "$( \
  echo -e "1 2\n4 6" | \
    awk '{print "[RR"$1"]\nconf t"} \
         {print "int e0/0\n  no shut\n  ip address 192.168."$1$2"."$1" 255.255.255.0"} \
         {print "  end\nwrite mem"} \
         {print "[RR"$2"]\nconf t"} \
         {print "int e0/0\n  no shut\n  ip address 192.168."$1$2"."$2" 255.255.255.0"} \
         {print "  end\nwrite mem"}';
  echo -e "1 3\n5 6" | \
    awk '{print "[RR"$1"]\nconf t"} \
         {print "int e0/1\n  no shut\n  ip address 192.168."$1$2"."$1" 255.255.255.0"} \
         {print "  end\nwrite mem"} \
         {print "[RR"$2"]\nconf t"} \
         {print "int e0/1\n  no shut\n  ip address 192.168."$1$2"."$2" 255.255.255.0"} \
         {print "  end\nwrite mem"}';
  echo -e "2 4\n3 5" | \
    awk '{print "[RR"$1"]\nconf t"} \
         {print "int e0/"($0+1)%2"\n  no shut\n  ip address 192.168."$1$2"."$1" 255.255.255.0"} \
         {print "  end\nwrite mem"} \
         {print "[RR"$2"]\nconf t"} \
         {print "int e0/"($0+1)%2"\n  no shut\n  ip address 192.168."$1$2"."$2" 255.255.255.0"} \
         {print "  end\nwrite mem"}';
  )"
[RR1]
conf t
int e0/0
  no shut
  ip address 192.168.12.1 255.255.255.0
  end
write mem
[RR2]
conf t
int e0/0
  no shut
  ip address 192.168.12.2 255.255.255.0
  end
write mem
[RR4]
conf t
int e0/0
  no shut
  ip address 192.168.46.4 255.255.255.0
  end
write mem
[RR6]
conf t
int e0/0
  no shut
  ip address 192.168.46.6 255.255.255.0
  end
write mem
[RR1]
conf t
int e0/1
  no shut
  ip address 192.168.13.1 255.255.255.0
  end
write mem
[RR3]
conf t
int e0/1
  no shut
  ip address 192.168.13.3 255.255.255.0
  end
write mem
[RR5]
conf t
int e0/1
  no shut
  ip address 192.168.56.5 255.255.255.0
  end
write mem
[RR6]
conf t
int e0/1
  no shut
  ip address 192.168.56.6 255.255.255.0
  end
write mem
[RR2]
conf t
int e0/1
  no shut
  ip address 192.168.24.2 255.255.255.0
  end
write mem
[RR4]
conf t
int e0/1
  no shut
  ip address 192.168.24.4 255.255.255.0
  end
write mem
[RR3]
conf t
int e0/0
  no shut
  ip address 192.168.35.3 255.255.255.0
  end
write mem
[RR5]
conf t
int e0/0
  no shut
  ip address 192.168.35.5 255.255.255.0
  end
write mem


■IPアドレスの確認

RR1#show ip interface brief | inc 192
Ethernet0/0                192.168.12.1    YES manual up                    up      
Ethernet0/1                192.168.13.1    YES manual up                    up      
Ethernet1/0                192.168.0.41    YES manual up                    up  

RR2#show ip interface brief | inc 192
Ethernet0/0                192.168.12.2    YES manual up                    up      
Ethernet0/1                192.168.24.2    YES manual up                    up      
Ethernet1/0                192.168.0.42    YES manual up                    up  

RR3#show ip interface brief | inc 192
Ethernet0/0                192.168.35.3    YES manual up                    up      
Ethernet0/1                192.168.13.3    YES manual up                    up      
Ethernet1/0                192.168.0.43    YES manual up                    up      

RR4#sho ip eigrp neighbors 
EIGRP-IPv4 Neighbors for AS(65002)
RR4#show ip interface brief | inc 192
Ethernet0/0                192.168.46.4    YES manual up                    up      
Ethernet0/1                192.168.24.4    YES manual up                    up      
Ethernet1/0                192.168.0.44    YES manual up                    up 

RR5#show ip interface brief | inc 192
Ethernet0/0                192.168.35.5    YES manual up                    up      
Ethernet0/1                192.168.56.5    YES manual up                    up      
Ethernet1/0                192.168.0.45    YES manual up                    up  

RR6#show ip interface brief | inc 192
Ethernet0/0                192.168.46.6    YES manual up                    up      
Ethernet0/1                192.168.56.6    YES manual up                    up      
Ethernet1/0                192.168.0.46    YES manual up                    up  

■EIGRPを65002で構成

conf t
  router eigrp 65002
    network 192.168.0.0 255.255.0.0
    network 10.6.6.0 255.255.255.0
    passive-interface e1/0
    distribute-list 8 out e0/0
    distribute-list 8 out e0/1
  exit
  access-list 8 deny 192.168.0.0 0.0.0.255
  access-list 8 permit 10.6.6.0 0.0.0.255
  access-list 8 permit 192.168.0.0 0.0.255.255
  end
write mem

■疎通確認

RR1#traceroute 192.168.56.6
Type escape sequence to abort.
Tracing the route to 192.168.56.6
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.13.3 0 msec 0 msec 0 msec
  2 192.168.35.5 0 msec 1 msec 1 msec
  3 192.168.56.6 1 msec 0 msec 1 msec
RR1#traceroute 192.168.46.6
Type escape sequence to abort.
Tracing the route to 192.168.46.6
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 1 msec 0 msec 1 msec
  2 192.168.24.4 1 msec 1 msec 0 msec
  3 192.168.46.6 1 msec 1 msec 1 msec

■lo0にIPを振る。

$ echo "`seq 1 6`" | \
      awk '{print "[RR"$0"]\nconf t\n  int lo0\n  ip addr 10.6.6."$0" 255.255.255.255\n  end\nwrite mem"}'
[RR1]
conf t
  int lo0
  ip addr 10.6.6.1 255.255.255.255
  end
write mem
[RR2]
conf t
  int lo0
  ip addr 10.6.6.2 255.255.255.255
  end
write mem
[RR3]
conf t
  int lo0
  ip addr 10.6.6.3 255.255.255.255
  end
write mem
[RR4]
conf t
  int lo0
  ip addr 10.6.6.4 255.255.255.255
  end
write mem
[RR5]
conf t
  int lo0
  ip addr 10.6.6.5 255.255.255.255
  end
write mem
[RR6]
conf t
  int lo0
  ip addr 10.6.6.6 255.255.255.255
  end
write mem

■疎通確認

RR1#traceroute 10.6.6.6 
Type escape sequence to abort.
Tracing the route to 10.6.6.6
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.12.2 0 msec
    192.168.13.3 1 msec
    192.168.12.2 0 msec
  2 192.168.35.5 5 msec
    192.168.24.4 0 msec
    192.168.35.5 4 msec
  3 192.168.46.6 1 msec
    192.168.56.6 1 msec
    192.168.46.6 1 msec

RR1#show ip route 10.6.6.6      
Routing entry for 10.6.6.6/32
  Known via "eigrp 65002", distance 90, metric 460800, type internal
  Redistributing via eigrp 65002
  Last update from 192.168.13.3 on Ethernet0/1, 00:00:13 ago
  Routing Descriptor Blocks:
    192.168.13.3, from 192.168.13.3, 00:00:13 ago, via Ethernet0/1
      Route metric is 460800, traffic share count is 1
      Total delay is 8000 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 3
  * 192.168.12.2, from 192.168.12.2, 00:00:13 ago, via Ethernet0/0
      Route metric is 460800, traffic share count is 1
      Total delay is 8000 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 3

RR1#show ip route  | section 10.6.6.6
D        10.6.6.6 [90/460800] via 192.168.13.3, 00:04:52, Ethernet0/1
                  [90/460800] via 192.168.12.2, 00:04:52, Ethernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
RR1#show ip eigrp topology 10.6.6.6 255.255.255.255
EIGRP-IPv4 Topology Entry for AS(65002)/ID(192.168.13.1) for 10.6.6.6/32
  State is Passive, Query origin flag is 1, 2 Successor(s), FD is 460800
  Descriptor Blocks:
  192.168.12.2 (Ethernet0/0), from 192.168.12.2, Send flag is 0x0
      Composite metric is (460800/435200), route is Internal
      Vector metric:
        Minimum bandwidth is 10000 Kbit
        Total delay is 8000 microseconds
        Reliability is 255/255
        Load is 1/255
        Minimum MTU is 1500
        Hop count is 3
        Originating router is 192.168.56.6
  192.168.13.3 (Ethernet0/1), from 192.168.13.3, Send flag is 0x0
      Composite metric is (460800/435200), route is Internal
      Vector metric:
        Minimum bandwidth is 10000 Kbit
        Total delay is 8000 microseconds
        Reliability is 255/255
        Load is 1/255
        Minimum MTU is 1500
        Hop count is 3
        Originating router is 192.168.56.6

■RR1のe0/1側を不等コストロードバランスとなるように設定

conf t
  int e0/1
    delay 120
  router eigrp 65002
    variance 2
  end
write mem

■79:80の不等コストのロードバランスになった。

RR1#show ip route 10.6.6.6                         
Routing entry for 10.6.6.6/32
  Known via "eigrp 65002", distance 90, metric 460800, type internal
  Redistributing via eigrp 65002
  Last update from 192.168.13.3 on Ethernet0/1, 00:00:30 ago
  Routing Descriptor Blocks:
    192.168.13.3, from 192.168.13.3, 00:00:30 ago, via Ethernet0/1
      Route metric is 465920, traffic share count is 79
      Total delay is 8200 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 3
  * 192.168.12.2, from 192.168.12.2, 00:00:30 ago, via Ethernet0/0
      Route metric is 460800, traffic share count is 80
      Total delay is 8000 microseconds, minimum bandwidth is 10000 Kbit
      Reliability 255/255, minimum MTU 1500 bytes
      Loading 1/255, Hops 3