SoFunction
Updated on 2025-04-06

Dual-line policy routing and script backup switching

The dual-line policy routing of Telecom and Netcom is automatically switched to a single line after one of the lines is broken. After the line is restored, the policy routing will be restored.
Telecommunications Gateway 190.168.1.10
Netcom Gateway 192.168.1.9

1 First set up a telecommunications line to access the Internet.

2. Add Netcom's independent routing table.
CODE / ip policy-routing table test1
add dst-address=0.0.0.0/0 gateway=192.168.1.9 preferred-source=0.0.0.0 comment="" disabled=no
3 Add policy routing rules in rule
CODE / ip policy-routing rule
add src-address=0.0.0.0/0 dst-address=59.80.0.0/14 flow="" interface=all action=lookup table=test1 \
   comment="" disabled=no
..
..
omitted here
Remember to move main to the end
4. Configure automatic switching scripts
CODE / system script
add name="test1down" source="/ ip policy-routing table test1
\nset \[/ ip policy-routing table test1 find \
   dst-address=0.0.0.0\] gateway 190.168.1.10
\n" policy=ftp,reboot,read,write,policy,test
add name="test1up" source="/ ip policy-routing table test1
\nset \[/ ip policy-routing table test1 find \
   dst-address=0.0.0.0\] gateway 192.168.1.9
\n" policy=ftp,reboot,read,write,policy,test
add name="maindown" source="/ ip policy-routing table main
\nset \[/ ip policy-routing table main find \
   dst-address=0.0.0.0\] gateway 192.168.1.9" policy=ftp,reboot,read,write,policy,test
add name="mainup" source="/ ip policy-routing table main
\nset \[/ ip policy-routing table main find \
   dst-address=0.0.0.0\] gateway 190.168.1.10" policy=ftp,reboot,read,write,policy,test

5 Configure NETWATCH to monitor network on and off conditions
CODE / tool netwatch
add host=190.168.1.10 timeout=1s interval=20s up-script=mainup down-script=maindown comment="" disabled=no
add host=192.168.1.9 timeout=1s interval=20s up-script=test1up down-script=test1down comment="" disabled=noArticle entry: csh     Editor in charge: csh