Koozali.org: home of the SME Server
Obsolete Releases => SME 9.x Contribs => Topic started by: mgb on December 31, 2014, 12:10:50 PM
-
Hello Question
I have a network with two access ports
Is there software that can change.
If one network disconnected then it transfers
The second port network.
Thank you.
(http://linux.makif.omer.k12.il/adsl.JPG)
-
The usual recommendation for this configuration is to install a dual-wan router on the network that provides auto failover (that is, replace your switch and two routers with one device like the Netgear FVS336Gv2 (http://www.cdw.com/shop/products/NETGEAR-ProSafe-Dual-WAN-Gigabit-Firewall-with-SSL-IPSec-VPN-FVS336Gv2/2161329.aspx?RecommendedForEDC=00000001&RecoType=RS&cm_sp=Search-_-Session&ProgramIdentifier=3) or the Cisco RV320 (https://www.cdw.com/shop/products/CISCo-GB-DUAL-WAN-VPN-RoUTER/3071586.aspx)
You could write a script that pings an internet host and swaps the gatewayip if the ping fails - I doubt that you'll find any existing WAN fail-over code for Centos that can be used safely on a SME server.
Here is some pseudocode that would do what you want - once you have the script written and tested you'd also want to configure it as a supervised service so it was always running:
while true
if (ping 4.2.2.1) && (ping 8.8.8.8)
sleep 30
else
if $(config get GatewayIP) eq 10.0.0.254
config set GatewayIP 10.0.0.253
signal-event remoteaccess-update
else
config set GatewayIP 10.0.0.254
signal-event remoteaccess-update
endif
endif
endwhile
-
/wgw: line 4: syntax error near unexpected token `else'
./wgw: line 4: ` else'
-
Sorry...
...
Here is some pseudocode...
That's just an outline showing the logic you could use to create a script to do what you want.
Problems I know about:
- I don't know if bash has a "while" loop
- I doubt that the ping commands I gave would work as written (you'd at least need an argument to limit the number of ping requests that get sent)
- the bash 'if', 'else', 'endif' structure does not work as I have shown it (so all if/else/endif structures need rewriting)
Things that I know would work:
sleep 30 (do nothing for 30 seconds)
$(config getprop GatewayIP) (returns the current value of GatewayIP -- test using echo $(config get GatewayIP))
config set GatewayIP 10.0.0.253; signal-event remoteaccess-update (should work; you should test this manually before sitting down to write and debug the rest of the script)
There is lots of actual coding you still need to do.
For example, after googling 'bash if' and reading the results, I can verify that this command successfully compares my current gateway and returns 'yes' for a match and 'no' for a non-match. Replace '192.168.200.1' with your gateway, then expand the 'echo yes' and 'echo no' commands to do what you want depending on if the gateway matches.
if [ $(config get GatewayIP) = 192.168.200.1 ];then echo yes; else echo no; fi
-
ping 192.168.183.1 -c 3 >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "192.168.183.1 dhcp1 is down"
cp -a /root/dhcpd.conf /dhcp/dhcpd.conf
service /etc/rc.d/init.d/dhcpd restart
# service network stop
# /sbin/ip route add default via 192.168.183.1
# ip route add 192.168.183.1 dev eth2
# service network restart
else
echo "192.168.0.1dhcp2 is up"
fi
exit 0
is ok config dhcpd.conf
-
cp -a /root/dhcpd.conf /dhcp/dhcpd.conf
service /etc/rc.d/init.d/dhcpd restart
is ok config dhcpd.conf
No !
DON'T use :
cp dhcpd.conf
This file, and many others, are generated automatically by the system. If you manually change them the changes can easily be lost if there are other changes on your server.
You really need to use the proper commands to do this sort of thing as has been suggested.
You are better to use the format suggested above :
config set GatewayIP 10.0.0.253; signal-event remoteaccess-update
(note this is not what you require, but gives the format using a CLI command)
You may find that something like "signal-event ip-change" is a better command to use.
However, you probably need to set other properties as well before doing this - have a look at these :
config show InternalInterface
config show ExternalInterface
config show ExternalNetmask
config show GatewayIP
config show LocalIP
config show LocalNetmask
Or to see them all try :
config show |less
You may need something like :
config set GatewayIP 10.0.0.253
config setprop ExternalInterface Name eth2 IPAddress x.x.x.x etc
signal-event ip-change
NB - this is JUST an example. you really need to read and understand the systems and the code first.
Have a look at some of this for more ideas :
http://wiki.contribs.org/Useful_Commands
http://wiki.contribs.org/DB_Variables_Configuration
B. Rgds
John
-
Right you're right.
Due to a serious change
So I prefer to do only the dhcpd.conf
I define an external DNS
And the exchange Then it's just for a limited time - to fix the problem
Then I will return the impulse DHCP
It is clear that the server will not be able to browse the web
-
ping walla.com -c 3 >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "wlan0 is down"
service network stop
cp /etc/sysconfig/network183 /etc/sysconfig/network
service network start
sleep 3
# cp /root/messaping1.txt
else
echo "wlan0 is up"
service network stop
cp /etc/sysconfig/network01 /etc/sysconfig/network
service network start
sleep 3
fi
exit 0