What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

How to get the gateway of a route inside a jffs script

pat.ibulaire

Occasional Visitor
Hello Everybody, here is a simple question about scripts :

My ip route list output is :

74.131.173.17 via 192.168.0.1 dev eth0
192.168.0.1 dev eth0 scope link
74.131.168.128/27 dev tap11 proto kernel scope link src 74.131.162.132
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.10
192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.1
127.0.0.0/8 dev lo scope link lo scope link
0.0.0.0/1 via 74.131.169.129 dev tap11
128.0.0.0/1 via 74.131.169.129 dev tap11
default via 192.168.0.1 dev eth0

I would like to find out how a jffs script could extract the ip gateway (currently 74.131.169.129) from the line 8 and have it as a variable available for the script.

Thank you in advance
 
Hello Everybody, here is a simple question about scripts :

My ip route list output is :

74.131.173.17 via 192.168.0.1 dev eth0
192.168.0.1 dev eth0 scope link
74.131.168.128/27 dev tap11 proto kernel scope link src 74.131.162.132
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.10
192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.1
127.0.0.0/8 dev lo scope link lo scope link
0.0.0.0/1 via 74.131.169.129 dev tap11
128.0.0.0/1 via 74.131.169.129 dev tap11
default via 192.168.0.1 dev eth0

I would like to find out how a jffs script could extract the ip gateway (currently 74.131.169.129) from the line 8 and have it as a variable available for the script.

Thank you in advance

Does this work?

Code:
IP_GW=`ip route show   |   grep   '128.0.0.0'   |   cut   -d   ' '   -f   3`
 
Does this work?

Code:
IP_GW=`ip route show   |   grep   '128.0.0.0'   |   cut   -d   ' '   -f   3`

It works, Fantastic thank you!
Then I can solve my problem with the selective routing, killing the route pushed by the server and replace them with the good gateway value...
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top