🔒 Closed Help networking please

Status
Not open for further replies.

HotKaelyn

Honorary Poster
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
 
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.

About this Thread

  • 3
    Replies
  • 560
    Views
  • 3
    Participants
Last reply from:
nnivx

Trending Topics

Online now

Members online
1,239
Guests online
1,659
Total visitors
2,898

Forum statistics

Threads
2,286,357
Posts
29,037,321
Members
1,217,900
Latest member
Johnnynattsville
Back
Top