What's new

Closed Help networking please

Status
Not open for further replies.

HotKaelyn

Eternal Poster
Joined
Feb 1, 2017
Posts
696
Reaction
553
Points
263
Mga master, patulong po.
Baguhan lang ako sa Linux scripting.Tulong po sana.

Gawa kasi ako ng auto routing script ng android.

Ang gusto ko mangyari
1. kunin ang value ng gateway IP ng eth0 - lagay sa variable like 'x'
Sample ipv = 192.168.1.2
Gateway = 192.168.1.1
X = 192.168.1.1

Then
2. Mag a add ako ng default route
IP route add default via %X dev eth0

Sorry newbie pa talaga
baka Alam nyo po pano gawin.
TIA
 
Last edited:
eth0 android? anyway pwedeng route -n
Code:
route -n | awk '{if ($4=="UG" && $8=="wlp2s0") print $2}'

route -n to display routing table, then pipe result to awk
$4 is flags, UG means UP and GATEWAY
$8 is iface, palitan mo nalang ng interface name wlp2s0 sakin
$2 is ip address

To assign the output of your command do: var=$(command), avoid whitespace around the assignment operator

IDK pano mag add ng default route lol i-SO mo nlng

Disclaimer: wala akong alam sa android, nakita ko lang linux and ito yung gumagana sakin
 
Status
Not open for further replies.

Similar threads

Back
Top