找回密码
 注册
查看: 1392|回复: 0

while循环语句失败告终

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-11-11 20:00:42 | 显示全部楼层 |阅读模式
#!/bin/bash, D" l3 D( `, W' p0 e# d, d; O; Q
####* d, h9 g1 @; A! f& n* r
ETH=`ip addr |grep eth |grep "state UP" |grep -v eth0 |awk -F ":" '{print $2}'|xargs`* w8 e2 G, i+ x- \) i
while [ "$ETH " != "eth0" ]
# `  o! s' s! Fdo
" a3 ^% T1 r. N! {$ O- r  if [ "$ETH" == "eth1" ];then
$ Z1 p5 m+ {# b8 v4 y/ [+ E& I/ ~" h     cat >/etc/sysctl.conf <<EOF' Y3 G1 Y+ S( i) {' A" q
    # sysctl settings are defined through files in2 _# ~* {9 X- g  ^" a
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.& g4 s% `% k5 H4 i6 |; Z* j5 W
#4 j& D4 N* `3 J3 ^5 A
# Vendors settings live in /usr/lib/sysctl.d/.
3 u+ _: B: J5 ]5 ^* t, h) x% s# To override a whole file, create a new file with the same in
, a# [1 c9 e; p1 r" Q) r: ~' Y# /etc/sysctl.d/ and put new settings there. To override
- B# ]0 y5 J+ b# only specific settings, add a file with a lexically later4 ^% B, [- {  G" Y* N4 c
# name in /etc/sysctl.d/ and put new settings there.: h0 Z+ Z" s: D( O
#! n& n  \$ ~: W9 u
# For more information, see sysctl.conf(5) and sysctl.d(5)./ a! S+ v: S# c9 B8 Q* D
net.ipv4.conf.all.rp_filter = 0, V; J" e9 m4 W; z* `
net.ipv4.conf.eth0.rp_filter = 0
3 \3 A2 f; C: W# z% jnet.ipv4.conf.$ETH.rp_filter = 0
- g: n! T3 C2 C1 x0 a: k# AEOF
2 u' u7 X1 I; e% \  else
7 C" p  p- r% H7 \0 U9 I" i( a) y+ R   cat >/etc/sysctl.conf <<EOF
, [( ]. b3 N) i& j/ b* h& L    # sysctl settings are defined through files in$ S& f! e6 S1 {
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
1 J1 [" k1 M& O' m, q#
  h8 x9 ]7 x& T; u# Vendors settings live in /usr/lib/sysctl.d/.
* U$ T! k* a. S# To override a whole file, create a new file with the same in) J7 j. i+ M+ @9 R
# /etc/sysctl.d/ and put new settings there. To override/ t8 G5 F" y, w' A8 b4 Q
# only specific settings, add a file with a lexically later
9 i1 v% k: t! I# name in /etc/sysctl.d/ and put new settings there.( U9 p, g: r1 ?+ R, k: S0 [- \( L. K
#
* _5 e$ b6 u4 r) A. g7 k- N8 `# For more information, see sysctl.conf(5) and sysctl.d(5).9 G2 V1 o  b! W. ~  g
net.ipv4.conf.all.rp_filter = 0
4 V2 t1 l* `, @4 wnet.ipv4.conf.eth0.rp_filter = 0
, n9 z8 H& q- Y. N, ]. bEOF
5 _  A. L- o3 N% @; N( ]# n4 xfi4 x% ~& O6 v9 |) [" W9 j) J
###kernel on
. z  y  A) o' }0 Msysctl -p
$ _6 [0 Z2 B8 @6 Usleep 300
* w5 P3 m) p6 l# ~) Bdone 5 q0 R$ O2 `; a3 w
exit 0: N+ U  T( a) a2 _! [. G' c
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:19 , Processed in 0.013106 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表