4
rated 0 times
[
4]
[
0]
/ answers: 1 / hits: 2480
/ 3 Years ago, tue, june 1, 2021, 2:16:51
I'm writing a shell script which needs information on the state of the network connection - the basic stuff like ip address, subnet, netmask and so on.
I could just use ifconfig
and sed/grep for the information, but I was hoping there was a cleaner way to do this - possibly using the ip
command, or similar utilities.
I'm looking for something which could give the following results:
$ (magic command) ip
192.168.1.1
$ (magic command) netmask
255.255.255.0
$ (magic command) subnet
192.168.0.0
and possibly similar things for network gateway/dns servers.
Does such a command exist? Perhaps there's an --unformatted
flag for ip
or ifconfig
? Am I too hopeful/naive?
Thanks :)
More From » command-line