www.centos.org Forum Index CentOS 6 - General Support iptables blocks dns
|
Bottom Previous Topic Next Topic |
|
| |
|
|
|---|
| Poster | Thread |
|---|
|
Re: iptables blocks dns | #2 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
Quote:
If these rules are on a DNS server then they are the wrong way round (your INPUT rule should be your OUTPUT rule and vice versa). |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 20:31
|
|||
|
Re: iptables blocks dns | #3 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
Yes, I have these rules in iptables. Are those wrong rules? DNS Server -- where can i check it? ![]() |
||
Posted on: 2011/12/8 20:49
|
|||
|
Re: iptables blocks dns | #4 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
If you have a DNS server then it is accepting UDP packets on port 53 so the destination (--dport) needs to be 53 on the INPUT chain.
|
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 21:01
|
|||
|
Re: iptables blocks dns | #5 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
I am not much sure about dns server.
![]() It is just a simple website. nslookup site.com is giving me the error when i start iptables. also, who.is dns search is not displaying any info about the site. But if i stop iptables, it is working normally. who.is is displaying result.s Do i need any rules to allow name server via iptables? |
||
Posted on: 2011/12/8 21:10
|
|||
|
Re: iptables blocks dns | #6 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
It'll really help if you give examples, preferably with cut'n'paste output of the commands you ran and the results you got vs the results you expected.
Whois is not DNS and does not use port 53 but 43 - `grep whois /etc/services` would show you some clues about that. |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 21:20
|
|||
|
Re: iptables blocks dns | #7 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
This is what i run when iptables status is "start" Now i truned of iptables "service iptables stop" |
||
Posted on: 2011/12/8 21:28
|
|||
|
Re: iptables blocks dns | #8 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
|
||
Posted on: 2011/12/8 21:30
|
|||
|
Re: iptables blocks dns | #9 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
First, your OUTPUT policy is ACCEPT so you can delete all of the rules you have there now as none of them are required.
Can you post the output from `iptables-save` as that's much easier to read than the version you posted. |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 21:46
|
|||
|
Re: iptables blocks dns | #10 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
I had the output policy to deny. But i was having problems with wget, curl and yum
Temporarily i have changed the deny to accept. Before finding a solution, i got problem with name server. When i turn on iptables, site is not loading. This is the output of iptables-save 1234 is my ssh 10000 is webmin control panel |
||
Posted on: 2011/12/8 21:52
|
|||
|
Re: iptables blocks dns | #11 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
I think you are making this way too complicated. If you want to set your OUTPUT policy to DENY then I would set up a bare minimum of rules, for example
That's simple and needs the last rule repeated per output port that you want to allow connections through to. It also allows all outgoing requests in response to packets that have already been allowed. The INPUT side of that is now handled by You don't need separate input rules for accepting the replies to things that have been allowed out as they're allowed by the 2nd rule above. The things you want on your INPUT chain are for services that you have running on the machine - so, yes, port 1234 wants one like This allows the initial connection (optionally from -s my.source.ip.addresses ) and subsequent traffic is allowed in and out by the RELATED,ESTABLISHED rules on input and output chains. |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 22:18
|
|||
|
Re: iptables blocks dns | #12 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
Is this correct? When i add drop to default, will i lost my ssh immediately or will it execute the shell script till the end? |
||
Posted on: 2011/12/8 22:32
|
|||
|
Re: iptables blocks dns | #13 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
Quote:
If you have doubts about that then you need to take steps to make sure that it doesn't happen - you could run it under `screen` for example so if you lose your connection then you haven't lost your session, or you could run a script using `nohup scriptname &`. Whichever way you do it you need to know that you are not about to lock yourself out permanently! If you have services running on this machine that are listening on particular ports then you need an INPUT rule for each one. Your rules only allow for port 1234 at the moment - didn't you say you had webmin on port 10000 too? You seem to have added that to the output rules instead. Unless you are making outbound connection attempts to other servers that are running ssh on port 1234 then the output rule you have for that is useless too. |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 22:43
|
|||
|
Re: iptables blocks dns | #14 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
Yes, I have the following service running in server httpd, sendmail, webmin, https, mysqld Now i have made changes in input settings. Do i need to create new state for every output port? will the above settings allow curl other sites with port 80, yum and wget? |
||
Posted on: 2011/12/8 22:53
|
|||
|
Re: iptables blocks dns | #15 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
Quote:
Yes. Quote:
If you set the output policy to DROP then you need to explicitly allow the ports to which you want to make outbound connections. Other ports opened by the same connection or related to it will be allowed too by virtue of the RELATED,ESTABLISHED rules. With the rules you have at the moment, you'll be able to connect to other web sites and SMTP servers from this machine. It also allows you to connect to your webmin port on other servers but I suspect you just didn't get around to removing that yet. You're also allowing traffic to your server from others on http[s], SMTP, relocated ssh and Webmin ports. Any traffic related to those connections is also allowed. Since you started this thread about DNS you will need to allow outbound traffic on destination port 53, both UDP and TCP. Whois traffic is on port 43. |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 23:17
|
|||
|
Re: iptables blocks dns | #16 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
Is it now correct rule? I am just running a simple website with curl usage. Suggest me if i am wrong. .. I was using this site to check the dns status http://who.is/dns/google.com |
||
Posted on: 2011/12/8 23:30
|
|||
|
Re: iptables blocks dns | #17 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
Quote:
Personally I would omit the --sport from the rules and you do not need ESTABLISHED at all as you already have a rule to handle that. You've also removed the output rules that let outbound SMTP traffic out of your machine which means that no emails will be sent out from this box. The same applies to port 443 outbound and this might be required as I believe some yum update mirrors are accessible over https (not 100% sure on that). |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 23:40
|
|||
|
Re: iptables blocks dns | #18 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
Is that correct rule? I got it for output now ![]() Thanks for teaching me. Do i need this above rule in the input side? Server is not going to receive any mails. It is just going to send mails. Thanks again! |
||
Posted on: 2011/12/8 23:46
|
|||
|
Re: iptables blocks dns | #19 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2009/9/24
From Brighton, UK
Posts: 6334
|
Quote:
Yes, that looks fine. Quote:
If you are not running an email server accepting mails from outside then there is no reason to have this rule and every reason to delete it! |
||
|
_________________
Linux/VoIP Systems Administrator |
|||
Posted on: 2011/12/8 23:52
|
|||
|
Re: iptables blocks dns | #20 |
|
|---|---|---|---|
|
Regular Board Member
![]()
Joined: 2011/11/19
From
Posts: 81
|
![]() Thanks for you help. I will run add those rules in iptables and i will update the status! |
||
Posted on: 2011/12/8 23:54
|
|||
Top Previous Topic Next Topic |
|
|



Topic options
Print Topic
Threaded
Newest First
agriz



-- where can i check it? 



You cannot start a new topic.
You can view topic.