-1

When loading a page, let's say facebook.com the page loads multiple resources from several other sites, like fbexternal-a.akamaihd.net or fbcdn-profile-a.akamaihd.net.

I need to create a script in PHP, Bash, Python or just any other language that can get all those addresses.

How can I do this? Is there a web service that does this?

A bit more of what I'm trying to achieve: There is a router that needs to block all access except a single page and its resources that may be on other servers. Since this ACL (Access Control List) is not DNS based I have to get all ip addresses to add them to the list.

I know that IP addresses change often, however this is the only workaround works right now (by getting ip addresses manually) given that the router does not have DNS based ACL.

adelriosantiago
  • 7,762
  • 7
  • 38
  • 71
  • IP addresses may change at any time. This is not a good idea. – SLaks Jan 30 '15 at 18:20
  • @SLaks I know that ip addresses change often, however the router does not provide a way to define ACL's with domain names. This is the only alternative it comes to my mind. – adelriosantiago Jan 30 '15 at 18:21
  • It's not a good idea to block all IP addresses related to the page. It'll fast block a lot of things you don't expect. For example pages often uses google fonts, akamai provides cdn networks where you can never be sure if more services are on the same IP address as well. If you want to block FB than best (for what is possible on your router) will be to just block just their own classes. It should prevent your users to use it even if it'll loads partially. – pawel7318 Jan 30 '15 at 18:33
  • @pawel7318 I understand your comment. If we would be blocking a single page it would also block resources for other websites. However we are *unblocking access*, everything is blocked except a single page and its resources. This may cause, of course, that some other webpages (like Google Fonts) will be accessible, but thats ok. – adelriosantiago Jan 30 '15 at 18:38
  • What kind of router it is ? – pawel7318 Jan 30 '15 at 18:39
  • @pawel7318 It is a CISCO 819HG or just CISCO 819 actually. – adelriosantiago Jan 30 '15 at 18:39
  • Should be no problem to do what I suggest in the answer on it. – pawel7318 Jan 30 '15 at 18:42
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/69919/discussion-between-pawel7318-and-alejandro-del-rio). – pawel7318 Jan 30 '15 at 18:51

1 Answers1

1

You will need to break this down into parts, but it should be doable. The steps I see you needing to do are:
1. Get the webpage source - http://php.net/manual/en/function.file-get-contents.php
2. Generate an array of domains - PHP: Regular Expression to get a URL from a string
3. Convert domain names into IP's - http://php.net/dns_get_record

Community
  • 1
  • 1
Nathan
  • 366
  • 1
  • 6