68 lines
1.5 KiB
Bash
68 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
bash /home/rnp/2/103.sh
|
|
clear
|
|
echo "************************************************************"
|
|
bash /home/rnp/checkip.sh
|
|
echo "************************************************************"
|
|
echo "201" > /home/rnp/2/201.txt
|
|
del_vlan(){
|
|
local dev=$1
|
|
local eth_v=$2
|
|
local eth_p=$3
|
|
local ip=$4
|
|
ssh $dev "ip link delete $eth_v"
|
|
ssh $dev "ip link set dev $eth_p up"
|
|
ssh $dev "ip addr add $ip dev $eth_p"
|
|
}
|
|
|
|
del_vlan "router4" "eth1.100" "eth1" "10.5.1.4/24"
|
|
del_vlan "pc1" "eth1.200" "eth1" "10.5.1.1/24"
|
|
del_vlan "pc2" "eth1.200" "eth1" "10.5.1.2/24"
|
|
del_vlan "pc3" "eth1.100" "eth1" "10.5.1.3/24"
|
|
|
|
|
|
assign_ip(){
|
|
local dev=$1
|
|
local eth=$2
|
|
local ip=$3
|
|
ssh $dev "ip addr add $ip dev $eth"
|
|
}
|
|
|
|
echo "============================================================"
|
|
bash /home/rnp/checkip.sh
|
|
echo "============================================================"
|
|
|
|
|
|
echo "pc1 neigh"
|
|
ssh pc1 "ip neigh"
|
|
echo "pc2 neigh"
|
|
ssh pc2 "ip neigh"
|
|
|
|
echo "pc1 neigh" >> /home/rnp/2/201.txt
|
|
ssh pc1 "ip neigh" >> /home/rnp/2/201.txt
|
|
echo "pc2 neigh" >> /home/rnp/2/201.txt
|
|
ssh pc2 "ip neigh" >> /home/rnp/2/201.txt
|
|
|
|
ping_dev(){
|
|
local dev=$1
|
|
local ip=$2
|
|
local eth_n=$3
|
|
ssh $dev "ping -c 5 -W 2 -I eth$eth_n $ip"
|
|
}
|
|
|
|
ping_dev "pc1" "10.5.1.2" 1
|
|
ping_dev "pc1" "10.5.1.3" 1
|
|
ping_dev "pc1" "10.5.1.4" 1
|
|
|
|
ping_dev "pc2" "10.5.1.1" 1
|
|
ping_dev "pc2" "10.5.1.3" 1
|
|
ping_dev "pc2" "10.5.1.4" 1
|
|
|
|
echo "pc1 neigh-2" >> /home/rnp/2/201.txt
|
|
ssh pc1 "ip neigh" >> /home/rnp/2/201.txt
|
|
echo "pc2 neigh-2" >> /home/rnp/2/201.txt
|
|
ssh pc2 "ip neigh" >> /home/rnp/2/201.txt
|
|
|
|
|