Trying to extract the IP address of the default gateway
Hope you can help.
I am doing a FD in applied networking and having trouble with this line
DG= netstat -rn | grep 0.0.0.0 | awk '{print $2}' | grep -v "0.0.0.0"
ping -c 3 $DG
I am trying to extract the DG from netstat so I can ping to check it responds to ping command.
the result looks right when echo'd to the screen but when i try to ping the DG it errors, i can only think the the data in the $DG variable contains the wrong data, it there a way to clean this up?
Error message =
Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
[-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
[-w deadline] [-W timeout] [hop1 ...] destination
I must be doing something daft
Hope you can help
Regards
Stuart
Last edited by dixon464; 12-09-2014 at 12:05 PM.
|