summaryrefslogtreecommitdiffstats
path: root/src/arm/openwrt_demo/1_buildimage/resources/bin/setroutes
blob: 540a235a7bf81387db60c5d1c320eeaa18be801c (plain)
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
#!/bin/sh

nwfn='/etc/config/network'
gwPost=".1"
nwPost=".0"
maskPost="/16"
defaultgw="0.0.0.0/0"

ethname='eth0'
ipeth=$(ifconfig $ethname |grep "inet addr" | cut -d: -f2 | awk '{print $1}')
expGwPrefix=$(echo $ipeth | cut -d. -f 1,2,3)
expGw=$expGwPrefix$gwPost
expNetPrefix=$(echo $ipeth | cut -d. -f 1,2)
expNet=$expNetPrefix$nwPost$nwPost$maskPost
echo "$expNet, $expGw, $ethname"
ip route add $expNet via $expGw dev $ethname


ethname='net0'
ipeth=$(ifconfig $ethname |grep "inet addr" | cut -d: -f2 | awk '{print $1}')
expGwPrefix=$(echo $ipeth | cut -d. -f 1,2,3)
expGw=$expGwPrefix$gwPost
expNetPrefix=$(echo $ipeth | cut -d. -f 1,2)
expNet=$expNetPrefix$nwPost$nwPost$maskPost
ip route add $expNet via $expGw dev $ethname
ip route add $defaultgw via $expGw