| Linode Forum https://forum.linode.com/ |
|
| firewall setup https://forum.linode.com/viewtopic.php?f=19&t=8038 |
Page 1 of 1 |
| Author: | bboran [ Fri Nov 11, 2011 11:27 pm ] |
| Post subject: | firewall setup |
this is my iptables rules. i am a linux newbie and try to learn. do you think this is enough? Code: *filter also do i have to insall nginx before php and mysql? what is the order? thanks. |
|
| Author: | hoopycat [ Sat Nov 12, 2011 1:33 am ] |
| Post subject: | |
You're blocking most ICMP traffic with those rules; this can break things like Path MTU Discovery. Otherwise looks decent. You'll be allowing incoming TCP connections to ports 80, 443, and 54321, and will have no restrictions on outgoing connections. As for the order of installation... it doesn't really matter. If something needs to be installed before something else, almost all package managers will take care of it for you. Out of habit, I tend to do web server -> database server -> application, but that's totally arbitrary. The real answer, of course, is to do whatever the Linode Library says to do |
|
| Author: | bboran [ Sat Nov 12, 2011 1:47 am ] |
| Post subject: | |
Thank you for your answer hoopycat. One last thing if i look at my iptable rules i see that it adds some extra codes above my rules. what is this, is this normal? Code: nano /etc/iptables.up.rules these are the codes above my rules; Code: *security |
|
| Author: | hoopycat [ Sat Nov 12, 2011 11:37 am ] |
| Post subject: | |
That's the output from "iptables-save", which is formatted to let "iptables-restore" load everything in the right order. Most of the entries you pasted are the defaults for other tables. |
|
| Author: | bboran [ Sat Nov 12, 2011 6:07 pm ] |
| Post subject: | |
hoopycat you said "You're blocking most ICMP traffic with those rules; this can break things like Path MTU Discovery. Otherwise looks decent." can you share a decent firewall setup without break things like Path MTU Discovery. For example can you share your own setup? Thanks. |
|
| Author: | hoopycat [ Sun Nov 13, 2011 9:12 pm ] |
| Post subject: | |
bboran wrote: hoopycat you said "You're blocking most ICMP traffic with those rules; this can break things like Path MTU Discovery. Otherwise looks decent." can you share a decent firewall setup without break things like Path MTU Discovery. For example can you share your own setup? Thanks.
Certainly. I've got a few different ones, depending on the situation. None of them are probably what you're after, but it's all about ideas and thoughts. Worth noting is that every single one of these uses iptables "under the hood", although the front end is different. tremens: netbook. Connects to hostile networks on a myriad of interfaces (two ethernets, three wifis, and 3G). Attempts to bring up an OpenVPN connection to a Linode whenever it can. I use ufw to handle the firewalling. Allowed from anywhere: ssh, printing (?!!), multicast DNS (also ??!!), munin (which should probably only be allowed over OpenVPN). Allowed from my home IPv4 /24 on Ethernet only: Dropbox (not a 100% effective rule, but I think this was a bandwidth management thing). Summary: easy to add rules, also easy to add something then forget wtf you added it. Everything works fine, though. Code: rtucker@tremens:~$ sudo ufw status budweiser: router. Provides IPv4 NAT and IPv6 routing, with firewalling for both. For the IPv4 input side of things, ICMP and DHCP replies are explicitly allowed from the Internet side of things, but everything else (except for established connections) gets dropped. This is kind of implicit with NAT, of course, but it's nice to make things explicit. On the forward chain, I icmp-host-unreachable everything to hit-nxdomain.opendns.com, except TCP port 80. This is the IP that OpenDNS returns along with NXDOMAIN errors. This lets me at least error out quickly when I typo something that isn't HTTP! Code: [rtucker@budweiser.rochnyav] /ip firewall filter> export The IPv6 end of things is a little more interesting, since there is no NAT involved. The input chain is just for traffic to the router itself (established connections allowed, new outbound connections allowed, ICMPv6 allowed, all else rejected), but the forward chain protects all the hosts. Again, established connections, new outbound connections, and ICMPv6 connections are allowed. In addition: - Protocol 59, packets of size 40. I think this was something BitTorrent-related, but like a moron, I didn't use the "comment" field. - Ports 22, 53, 80, 514 (syslog-ng for off-site stuff logging to here), 631 (printing, from off-site servers), 4949 (munin, from off-site servers), 51413 (bittorrent) are allowed - Everything else -> drop Code: [rtucker@budweiser.rochnyav] /ipv6 firewall filter> export Summary: It doesn't look anything at all like iptables, but it's iptables under the hood. You'll find Linux in a lot of places, and where you find Linux, you find iptables. Also, remember to add comments when you do things so you remember why the heck you did them. Like printing on tremens, or... packet-size=40 protocol=59 on my home router (?!). framboise: a Linode handling HTTP, HTTPS, NTP, VPN and SIP traffic. You were waitin' for this one, I bet. There's a lot going on here. I'll take the tables in order: Code: # Generated by iptables-save v1.4.10 on Thu Jun 30 21:16:48 2011 In the 'raw' table, I'm disabling connection tracking for NTP traffic (UDP port 123). I can't just outright disable connection tracking, but with hundreds of NTP queries per second, things get bad if I don't do something. mnordhoff gets the credit for this trick. Code: # Generated by iptables-save v1.4.10 on Thu Jun 30 21:16:48 2011 In the 'nat' table, I'm doing NAT for my VPN connections. (Duh!). Only fancy thing here is the DNAT for port 53: no matter what my netbook thinks its DNS is, stuff will be directed to OpenDNS. This is easier than battling network-manager every time I connect to a new network. Code: # Generated by iptables-save v1.4.10 on Thu Jun 30 21:16:48 2011 A whole lot of stuff going on in the filter table, as you can guess. Those INPUT and OUTPUT rules with no actions on them are for counters, used by munin's ip_ plugin. There's reject rules for specific IP addresses that have caused problems, too. The rules for SIP (port 5060) are kinda cool... basically, rate-limiting VoIP signalling traffic. (It turns out there's no small number of idiots who set their VoIP phones to try to register to pool.ntp.org, and no small number of VoIP phones that didn't bother implementing the sleep() syscall. This has caused Problems.) On the FORWARD chain, we have the companions to the NAT rules. On the IPv6 side of things, all I have are a bunch of auto-generated rules with no action, like those on the IPv4 side. I'll omit them for brevity. Summary: You can have a lot of fun with iptables without denying much traffic. I do enough experimental stuff that keeping things open is the most flexible policy. This does mean that anything can bind to a port and accept connections from the Internet unimpeded, but that's kind of useful for experimentation. I could (and should) probably implement a policy similar to the IPv6 rules on budweiser, though, and only allow "known good" traffic. (This is a little tricky with SIP, though.) From the start, Linux has been fairly sane about network security. If there's nothing listening on a port, there's (assuming bug-free software) nothing a packet to that port can do to harm a system. But there's always a risk that a human will bung up the configuration and make something open to the Internet that shouldn't be, or that some bug will appear somewhere. So, explicitly allowing things and denying everything else is probably a good policy. |
|
| Page 1 of 1 | All times are UTC-04:00 |
| Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |
|