IP Tables - Why doesn't this work?


Recommended Posts

I am trying to get to grips with IPTables on CentOS 6.3 and having difficulty in understand why this doesn't work. Basically this should allow incoming only connections on Port 22 (SSH) and both incoming and outgoing on Ports 80 and 443.


-p INPUT DROP
-p OUTPUT DROP
-p FORWARD DROP

#allow all traffic on loopback adapter
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT

# allow incoming ssh connections only
-A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INOUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

# port 80/443 - incoming
-A INPUT -i eth0 -p tcp -m multiport --dports 80,443 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -o eth0 -p tcp -m multiport --sports 80,443 -m state --state ESTABLISHED -j ACCEPT

# port 80/443 - outgoing
-A OUTPUT -o eth0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp --sport 80 -j ACCEPT

-A INPUT -j DROP
-A OUTPUT -j DROP
[/CODE]

Feel free to suggest alternatives but please explain things and not just post the solution.

Thanks

Link to comment
https://www.neowin.net/forum/topic/1094635-ip-tables-why-doesnt-this-work/
Share on other sites

The problem I had was that I couldn't get out on port 80 from the server i.e. I couldn't browse the web from there using the rules above, so I didn't put the 443 stuff in till I got the 80 stuff working.

I have since been reading articles etc and now have a script that builds the iptables config and it appears to be working as expected, I will post the script later if anyone is interested.

This topic is now closed to further replies.
  • Posts

    • Chrome is Google's commercial web browser product; it consists of their proprietary features (Googlified everything including profile sync) plus their chromium project barebones web browser. Google developers control the chromium project. The chromium project is the "core" for the web browser product from other vendors including Microsoft Edge (their own proprietary features), Opera (their own features), Brave (their own features), etc... The "downstream" teams at Microsoft, Opera, Brave, etc., can either integrate their original MV2-supporting code into future builds, or they can integrate chromium wholesale and simply add-on their own features/functionalities -- their 'current' build pipeline, so to speak. THIS is why changes at the chromium project affect so many products besides only Google's commercial Chrome browser. -- Edit to add: The chromium project is open-source, and is the piece that's Google's code contribution to the W3C and world wide web at large; there are no licensing fees for others to use the code in their own products... which is what they do. Other browser engines do exist (Firefox's for example) but it's nearly impossible to have both engines bundled into the same 1 browser product.
    • You're comparing settler colonies to colonized war torn nations. It's easy to become the richest by coming in and stealing other people's land, culture and resources.
    • ABP has become "old news" when MV3 started rolling out. They've gone downhill and is now simply irrelevant..... in my experience.
    • About two years ago, I switched to Brave and haven't looked back.
    • FWIW StatCounter has been trash for over 25+ years! Back in the day (circa 2000 and GeoCities pre-Blogger era), it was useful to paste a number on your webpage indicating how many visitors you had. In the ensuing 25+ years, they've grown in reputation and changed their ways... but their overall consumer value has remained abysmal. Serious marketing agencies only cite StatCounter when there's literally no other sources available to support any marketing claims! They are the absolute lowest threshold serious companies use to push any sort of narrative about this-or-that happening. Besides their credibility being what it is, they are forever subject to quality issues. They're so bad that my DNS-level ad-filter prevents me from even viewing their main website! HA!
  • Recent Achievements

    • Week One Done
      rubentuben8 earned a badge
      Week One Done
    • Week One Done
      ARaclen earned a badge
      Week One Done
    • One Year In
      jojodbn earned a badge
      One Year In
    • One Month Later
      jojodbn earned a badge
      One Month Later
    • Week One Done
      jojodbn earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      531
    2. 2
      PsYcHoKiLLa
      231
    3. 3
      +Edouard
      131
    4. 4
      ATLien_0
      88
    5. 5
      Steven P.
      81
  • Tell a friend

    Love Neowin? Tell a friend!