1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
| function init_em() {
cat>/etc/sysconfig/network-scripts/ifcfg-em1<<EOF
DEVICE=em1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
EOF
cat>/etc/sysconfig/network-scripts/ifcfg-em2<<EOF
DEVICE=em2
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
EOF
cat>/etc/sysconfig/network-scripts/ifcfg-em3<<EOF
DEVICE=em3
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
EOF
cat>/etc/sysconfig/network-scripts/ifcfg-em4<<EOF
DEVICE=em4
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
EOF
}
function init_bond() {
cat>/etc/sysconfig/network-scripts/ifcfg-bond0<<EOF
DEVICE=bond0
TYPE=Ethernet
BOOTPROTO=static
ONBOOT=yes
IPADDR=$1
NETMASK=255.255.255.224
GATEWAY=27.111.176.33
USERCTL=no
EOF
cat>/etc/sysconfig/network-scripts/ifcfg-bond1<<EOF
DEVICE=bond1
TYPE=Ethernet
BOOTPROTO=static
ONBOOT=yes
IPADDR=$2
NETMASK=255.255.252.0
USERCTL=no
EOF
}
function init_other() {
cat>>/etc/modprobe.d/dist.conf<<EOF
# active bonding configuration
alias bond0 bonding
alias bond1 bonding
options bond0 mode=1 miimon=100 fail_over_mac=1
options bond1 mode=1 miimon=100 fail_over_mac=1
EOF
}
function init_dns() {
cat>/etc/resolv.conf<<EOF
; generated by /sbin/dhclient-script
nameserver 8.8.8.8
nameserver 4.4.4.4
options attempts:1 timeout:1
search localhost
EOF
}
if [ $# -ne 3 ]
then
echo "args: sh a.sh Publick_IP Native_IP HOSTNAME"
exit 1
fi
init_bond $1 $2
init_em
init_other
init_dns
|