在配置好一个分公司网络交换机路由器为模板,通过替换其中的主机名、密码、接口地址、网关、静态路由,生成其它分公司的网络配置。

name=sw_mode
passwd=aaa@123
ip192=122.170.1
ip193=123.170.1
ip10=20.170.1
int110=122.17.1.2
r110=122.17.1.1
int111=122.17.2.2
r111=122.17.2.1
int182=222.17.1.2
zt=222.17.1.1
sed -i "s/shongshanhu/$name/g" `grep shongshanhu -rl /drives/e/Router`
sed -i "s/ssh@27/$passwd/g" `grep ssh@27 -rl /drives/e/Router`
sed -i "s/192.168.27/$ip192/g" `grep '192.168.27' -rl /drives/e/Router`
sed -i "s/193.168.27/$ip193/g" `grep '193.168.27' -rl /drives/e/Router`
sed -i "s/10.20.27/$ip10/g" `grep '10.20.27' -rl /drives/e/Router`
sed -i "s/172.16.110.74/$int110/g" `grep '172.16.110.74' -rl /drives/e/Router`
sed -i "s/172.16.110.73/$r110/g" `grep '172.16.110.73' -rl /drives/e/Router`
sed -i "s/172.16.111.74/$int111/g" `grep '172.16.111.74' -rl /drives/e/Router`
sed -i "s/172.16.111.73/$r111/g" `grep '172.16.111.73' -rl /drives/e/Router`
sed -i "s/102.16.110.74/$int182/g" `grep '102.16.110.74' -rl /drives/e/Router`
sed -i "s/102.16.110.73/$zt/g" `grep '102.16.110.73' -rl /drives/e/Router`