On my Ubuntu server I have some custom software running, that connects to its vendor server to search for updates. While this is useful in general, the software is not supposed to update itself for security reasons. I found out that, if there's no internet connection, the software is unable to update, but will still start. But I obviously can't close the connection. The hosts file is not an alternative either, as the software needs to connect to the vendor for license checks.

So my question is: How can I redirct or block outgoing HTTP traffic for a specific URL.

tl;dr: http://www.vendor.com/license should be allowed, but http://www.vendor.com/update should be blocked for outgoing traffic.

  • I know, that I can put up some custom proxy, but I want to be the most efficient as possible and looking for other possibilities. Maybe iptables is what I'm looking for? – buschtoens Mar 31 '13 at 1:30
  • nope. Definitely not IPtables unless you want to compile with additional module that perform analysis on a top layer of OSI/ISO. I guess the easiest would be a setting on a router - some security policy. I think Linksys routers have such option. Linksys WAG320n has such option: i.imgur.com/3d6UmEw.jpg – mnmnc Mar 31 '13 at 1:39
  • additionally - if the software updates itself I think there might be a config setting that says to do it. Maybe you are able to change the config ? – mnmnc Mar 31 '13 at 1:43
  • 1
    iptables -A OUTPUT -p tcp -m string --string "URL_HERE" --algo kmp -j DROP Great thing that HTTP Headers are sent in cleartext. :D – buschtoens Mar 31 '13 at 3:11
  • 1
    Right, the problem is that you're "rejecting" the connection after it has already been established. Use -j REJECT --reject-with tcp-reset. This will alert the application that the connection has been reset. – Dennis Mar 31 '13 at 3:34

Good thing, that HTTP and its headers are sent in cleartext! We can search for the URL in the HTTP Header with the -m string filter.


We want to block: http://www.example.com/I/am/some/distinguishable/URL

iptables -A OUTPUT -p tcp -m string --string "/I/am/some/distinguishable/URL" --algo kmp -j REJECT --reject-with tcp-reset

Thanks to Dennis for his tip on --reject-with tcp-reset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.