cat "/etc/modules.conf" 中加上
alias bond0 bonding
options bond0 miimon=100 mode=0
其中mode=0为负载平衡,
mode=1为备份时。。我试过把网线拨掉一根也完全正常。。因为另外一台一直在ping
[root@shlinux root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.7.112
[root@shlinux root]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.7.112
[root@shlinux root]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
IPADDR=192.168.7.112
NETMASK=255.255.255.0
NETWORK=192.168.7.0
BROADCAST=192.168.7.255
ONBOOT=yes
在"/etc/rc.d/rc.local"中加如下两句
ifenslave bond0 eth0 eth1
service network restart别忘了这句,否则eth1就会启动不了,兄弟们可能会发现在启动的时候会有eth1失败的提示,不过有了这句之後会发现後OK了。
取决于你的程序怎么写的,默认会每次启动用缺省的配置(头文件里的定义)覆盖RAM上的数据,具体地址要看你头文件里的定义。通常应该判断启动模式,如果是冷启动才会执行上述的覆盖 *** 作,否则使用RAM中的配置。具体文件名应该是config.h, 不过启动模式的分支需要要你自己来加。
不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI@echo off
rem 添加一个额外网段的ip但不改变/保留最后一段的ip数字
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
set "NetConnectionID="
set "MACAddress="
set "IPAddress="
for /f "delims=" %%a in ('wmic nic where "NetEnabled=TRUE and PhysicalAdapter=TRUE" get NetConnectionID^,MACAddress /value^|find "="') do set %%a
if not defined NetConnectionID (echoFailed to get NetConnectionID&pause&exit)
for /f "delims=" %%a in ('wmic nicconfig where "MACAddress='%MACAddress%'" get IPAddress^,DHCPEnabled /value^|find "="') do set %%a
if not defined IPAddress (echoFailed to get IPAddress&pause&exit)
if /i "%DHCPEnabled%" equ "TRUE" (echoDHCP is Enabled&pause&exit)
set IPAddress=%IPAddress:{=}%
set IPAddress=%IPAddress:}=%
set IPAddress=%IPAddress:"=%
for /f "delims=," %%a in ("%IPAddress%") do (
set oldip=%%a
for /f "tokens=1-4 delims=." %%b in ("%%a") do (
set #1=%%b
set #2=%%c
set #3=%%d
set #4=%%e
)
)
set newip=192.168.20.%#4%
set newipsubnet=255.255.255.0
echonetconnection=%NetConnectionID%
echooldip=%oldip%
echomac=%MACAddress%
echo--------------------------
echonewip=%newip%
echonewipsubnet=%newipsubnet%
netsh interface ip add address "%NetConnectionID%" %newip% %newipsubnet%
echo%#% +%$%%$%/%@% %z%
pause
exit
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)