Networking Forums

Networking Forums > Computer Networking > Linux Networking > Using hostnames in iptables

Reply
Thread Tools Display Modes

Using hostnames in iptables

 
 
David Brown
Guest
Posts: n/a

 
      03-16-2008, 06:40 PM
If I write an iptables rule with a hostname, when is the hostname
resolved? For example:

iptables -A INPUT -p tcp --src remoteoffice.company.com --dport 25 -j ACCEPT


I believe that "remoteoffice.company.com" is resolved at the time the
"iptables" statement is executed, rather than being stored in the chain
as a hostname and resolved when packets are checked. Can anyone confirm
that?

If I wanted to have such a rule for a hostname whose address changed
(say, a dynamic ADSL address), is there any way to do it?

mvh.,

David
 
Reply With Quote
 
 
 
 
D. Stussy
Guest
Posts: n/a

 
      03-16-2008, 09:55 PM
"David Brown" <(E-Mail Removed)> wrote in message
news:47dd77b4$0$8159$(E-Mail Removed)...
> If I write an iptables rule with a hostname, when is the hostname
> resolved? For example:
>
> iptables -A INPUT -p tcp --src remoteoffice.company.com --dport 25 -j

ACCEPT
>
>
> I believe that "remoteoffice.company.com" is resolved at the time the
> "iptables" statement is executed, rather than being stored in the chain
> as a hostname and resolved when packets are checked. Can anyone confirm
> that?


Correct. Resolved when the command is loaded.

Watch out for names that resolve to more than one address.


 
Reply With Quote
 
David Brown
Guest
Posts: n/a

 
      03-16-2008, 11:05 PM
D. Stussy wrote:
> "David Brown" <(E-Mail Removed)> wrote in message
> news:47dd77b4$0$8159$(E-Mail Removed)...
>> If I write an iptables rule with a hostname, when is the hostname
>> resolved? For example:
>>
>> iptables -A INPUT -p tcp --src remoteoffice.company.com --dport 25 -j

> ACCEPT
>>
>> I believe that "remoteoffice.company.com" is resolved at the time the
>> "iptables" statement is executed, rather than being stored in the chain
>> as a hostname and resolved when packets are checked. Can anyone confirm
>> that?

>
> Correct. Resolved when the command is loaded.
>
> Watch out for names that resolve to more than one address.
>


Thanks for confirming that for me. I'll only be using it for names that
I have control over and which will resolve to a single address. I
suppose that the most convenient way to update such rules when the ip
address changed would be to put them into a separate chain, which could
then be flushed and re-loaded without affecting other rules in the tables.

mvh.,

David


 
Reply With Quote
 
D. Stussy
Guest
Posts: n/a

 
      03-17-2008, 12:37 AM
"David Brown" <(E-Mail Removed)> wrote in message
news:47ddb5ae$0$8161$(E-Mail Removed)...
> D. Stussy wrote:
> > "David Brown" <(E-Mail Removed)> wrote in message
> > news:47dd77b4$0$8159$(E-Mail Removed)...
> >> If I write an iptables rule with a hostname, when is the hostname
> >> resolved? For example:
> >>
> >> iptables -A INPUT -p tcp --src remoteoffice.company.com --dport 25 -j

ACCEPT
> >>
> >> I believe that "remoteoffice.company.com" is resolved at the time the
> >> "iptables" statement is executed, rather than being stored in the chain
> >> as a hostname and resolved when packets are checked. Can anyone

confirm
> >> that?

> >
> > Correct. Resolved when the command is loaded.
> >
> > Watch out for names that resolve to more than one address.

>
> Thanks for confirming that for me. I'll only be using it for names that
> I have control over and which will resolve to a single address. I
> suppose that the most convenient way to update such rules when the ip
> address changed would be to put them into a separate chain, which could
> then be flushed and re-loaded without affecting other rules in the tables.


If you're using a script to set up multiple rules for your own server, it's
better to use iptables-restore than individual iptables lines.



 
Reply With Quote
 
Andrew Gideon
Guest
Posts: n/a

 
      03-18-2008, 03:59 PM
On Sun, 16 Mar 2008 17:37:54 -0800, D. Stussy wrote:

> If you're using a script to set up multiple rules for your own server,
> it's better to use iptables-restore than individual iptables lines.


Even where the actual change is a relatively small part of the set of all
rulesets? Is there some crossover point at which this isn't true, or is
it true regardless of how large the entire set and how small the changes?

- Andrew
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: hostnames Meinolf Weber [MVP-DS] Windows Networking 1 03-15-2010 05:25 AM
Re: hostnames Meinolf Weber [MVP-DS] Windows Networking 0 03-14-2010 06:51 PM
Can I use hostnames with only DHCP, no DNS? Brian Kendig Linux Networking 4 11-23-2007 03:11 PM
Use dhclient with two hostnames zushi Linux Networking 1 06-07-2005 01:20 PM
can I have 1 box with 2 NICs and 2 hostnames? Kev Linux Networking 7 10-24-2003 12:27 PM



1 2 3 4 5 6 7 8 9 10 11