Extract IPV4 IP Addresses out of file

Extract IPV4 IP Addresses out of file

Here's a very helpful method we can use to extract all IPV4 addresses out of a file, such as httpd.conf for for example.

sed -n  's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/\nip&\n/gp' /pathtofilehere | sed 's/ip//'

Running it on my local resolv.conf file, here's what some output will look like. Apache or any other daemon will look quite similar.

E-Rodriguezs-MacBook-Pro:/ erodriguez$ sed -n  's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/\nip&\n/gp' /etc/resolv.conf | sed 's/ip//'
nameserver 
8.8.8.8

nameserver 
8.8.4.4

nameserver 
207.210.208.138

nameserver 
207.210.211.118
    • Related Articles

    • Dedicated IP with cPanel

      Unfortunately, with the depletion of IPv4 IP addresses globally, these really are not as readily available as they once used to be and each usage needs to be absolutely justified you can read more about IPv4 depletion here ...
    • Extract or backup a MSSQL database to a .sql file using EMS Sql Manager Lite

      How do I extract or restore an MSSQL database to a .sql file? If you don't have a SQL management program, go to http://sqlmanager.net/en/products/studio/mssql to download the freeware version and install to your local computer.   Start EMS Sql ...
    • Dedicated IP with Plesk Reseller Hosting

      Unfortunately, with the depletion of IPv4 IP addresses globally, these really are not as readily available as they once used to be and each usage needs to be absolutely justified you can read more about IPv4 depletion here ...
    • Using web.config to limit access by IP address

      Web.config ipSecurity The web.config file can be used to restrict website access, by the client IP address. Web.config can be used to restrict access to a single page, a directory and all sub directories, or even the entire web site. You can block ...
    • How to allow IP in RDP (Remote Desktop Rule) Windows Firewall

      To create an inbound firewall rule for a program or service Open the Group Policy Management Console to Windows Firewall with Advanced Security. In the navigation pane, click Inbound Rules. Click Action, and then click New rule. On the Rule Type page ...