RN/Blatt02/scripts/204.sh

76 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2024-11-15 22:00:09 +01:00
#!/bin/bash
bash /home/rnp/2/203.sh
get_v6(){
local output=$1
local eth_n=$2
echo "$output" | grep -A 1 "^[0-9]: eth$eth_n" | awk '/inet6/ {split($2, parts, "/"); print parts[1]}'
}
pc1_ip6=$(ssh "pc1" "ip -6 addr show")
pc1_ip6=$(ssh "pc1" "ip link set dev eth1 down")
pc1_ip6=$(ssh "pc1" "ip link set dev eth1 up")
pc1_ip6=$(ssh "pc1" "ip -6 addr show")
echo $pc1_ip6
pc1_6=$(get_v6 "$pc1_ip6" 1)
echo $pc1_6
pc2_ip6=$(ssh "pc2" "ip -6 addr show")
pc2_ip6=$(ssh "pc2" "ip link set dev eth1 down")
pc2_ip6=$(ssh "pc2" "ip link set dev eth1 up")
pc2_ip6=$(ssh "pc2" "ip -6 addr show")
echo $pc2_ip6
pc2_6=$(get_v6 "$pc2_ip6" 1)
echo $pc2_6
echo "using ping"
echo "using ping" > /home/rnp/2/204.txt
ping_dev(){
local dev=$1
local ip=$2
local eth_n=$3
local output=$(ssh $dev "ping -c 5 -W 2 -I eth$eth_n $ip")
echo $output
}
ping6_dev(){
local dev=$1
local ip=$2
local eth_n=$3
local output=$(ssh $dev "ping6 -c 5 -W 2 -I eth$eth_n $ip")
echo $output
}
output=$(ping_dev "pc1" "10.5.1.2" 1)
echo "pc1 ping pc2"
echo "pc1 ping pc2">> /home/rnp/2/204.txt
echo "ping -c 5 -W 2 -I eth1 10.5.1.2"
echo "ping -c 5 -W 2 -I eth1 10.5.1.2">> /home/rnp/2/204.txt
echo "$output"
echo "$output" >> /home/rnp/2/204.txt
output=$(ping_dev "pc2" "10.5.1.1" 1)
echo "pc2 ping pc1"
echo "pc2 ping pc1">> /home/rnp/2/204.txt
echo "ping -c 5 -W 2 -I eth1 10.5.1.1"
echo "ping -c 5 -W 2 -I eth1 10.5.1.1">> /home/rnp/2/204.txt
echo "$output"
echo "$output" >> /home/rnp/2/204.txt
output=$(ping6_dev "pc1" "$pc2_6" 1)
echo "pc1 ping6 pc2"
echo "pc1 ping6 pc2">> /home/rnp/2/204.txt
echo "ping6 -c 5 -W 2 -I eth1 $pc2_6"
echo "ping6 -c 5 -W 2 -I eth1 $pc2_6">> /home/rnp/2/204.txt
echo "$output"
echo "$output" >> /home/rnp/2/204.txt
output=$(ping6_dev "pc2" "$pc1_6" 1)
echo "pc2 ping6 pc1"
echo "pc2 ping6 pc1">> /home/rnp/2/204.txt
echo "ping6 -c 5 -W 2 -I eth1 $pc1_6"
echo "ping6 -c 5 -W 2 -I eth1 $pc1_6">> /home/rnp/2/204.txt
echo "$output"
echo "$output" >> /home/rnp/2/204.txt