![]() ![]() If i use the arp -a command I receive the correct mac address for all connected pcs but I cannot ping anything except the local address. I'm currently playing around with the bash pipe and the awk command. The query I'm running looks like this: lab-1:/var/ dig +answer +short 10.11.11.11 I'd like to be able to get just the IP address returned. Inet 192.168.201.1 netmask 255.255.255.0 broadcast 192.168.201.255 I have setup netowkring but am unable to ping any local network pcs or the default gateway. On Alpine Linux, I'd like to know how to extract just the IP address from a DNS / dig query. In fact the answer you marked as accepted does just that (just uses ip instead of ifconfig ). Inet 192.168.100.110 netmask 255.255.255.0 broadcast 192.168.100.255 1,920 5 21 34 2 Isn't ifconfig -a what you're looking for rusty at 7:43 1 rajcoumar I fail to see why using a private IP prohibits you from using the output of ifconfig -a. Note: The script is based on the output of ifconfig in Ubuntu 16.04. ifconfig | head -19 | sed 'wlan0|\eth0' | awk '' The format of an IPv4 address is a 32-but numeric address, grouped 8 bits at a time (called an octet), each separated by a dot. The grep command has the -E (extended regex) option to allow it to interpret a pattern as a extended regular expression. I've come so close, so far i have tried about a million possible combinations but I'm close to exhausted, this is some of what i have tried. In Linux you can use regular expressions with grep to extract an IP address from a file. Grep regexp for matching ip addresses in a file. The loop keeping counter of 4 iterations accounts for 4 sections of a valid IPv4 address, while acrobatics with named pipes account for need to further use sections of ip address within script as opposed to having variables stuck in a subshell of a loop.I'm trying to learn as much as possible about Linux, I'm currently stuck at trying to grab specific parts of my ifconfig text display so it looks exactly like this: eth0: you can then filter that output with subsequent greps to limit the IPs to a family or unique IP: from the shell you can use 'repeat the previous command with bang bang': grep 21. Here’s the solution muru alluded to: first=$"Īnd with ip changed to 109.*.*.* $. netstat.txt will give you all the ip addresses that start with 72. Your problem statement may be a bit more liberal than you intended. ifconfig -a grep 10.16 inet 10.16.x.xx netmask 0xffffff00 broadcast 10.16.x.xxx inet 10.16.x.xx netmask 0xffffff80 broadcast 10.16.x.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |