iptables and one interface

iptables and one interface

Post by DustyDat » Thu, 22 Aug 2002 00:51:04



Hi All,

I am having a bit of a problem with setting up an iptables firewall on
a machine with one interface. I have set up a few successfully with
two but this one has me stumped.

I have a server (192.169.0.x) which sits on a private network. eth0 is
set to the above address. All I want to do is to allow a few services
to be accessed on this server by the internal network and allow
everything in the OUTPUT chain. I have set the OUTPUT chain default
policy to ACCEPT, and the INPUT chain has a default policy of DROP and
a few rules set up.

The INPUT chain works fine, but from the server itself I cannot telnet
to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
The mailserver is also on the 192,168.0.x network.

Does anyone have any ideas as I am baffled? My guess is that it must
be to do with just the one interface card, but I cannot work out why.
All help gratefully received.....

Many thanks,

Steve Westrip

 
 
 

iptables and one interface

Post by Dragan Cola » Thu, 22 Aug 2002 03:04:23



> [...]
> I have a server (192.169.0.x) which sits on a private network. eth0 is
> set to the above address. All I want to do is to allow a few services
> to be accessed on this server by the internal network and allow
> everything in the OUTPUT chain. I have set the OUTPUT chain default
> policy to ACCEPT, and the INPUT chain has a default policy of DROP and
> a few rules set up.

> The INPUT chain works fine, but from the server itself I cannot telnet
> to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
> The mailserver is also on the 192,168.0.x network.
> [...]

Did you tell your INPUT chain to accept incoming traffic from a locally
initiated connection? Something like

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

It should come last, after the rules for opening local daemon ports.

Dragan

 
 
 

iptables and one interface

Post by crawdo » Thu, 22 Aug 2002 14:00:23



> Hi All,

> I am having a bit of a problem with setting up an iptables firewall on
> a machine with one interface. I have set up a few successfully with
> two but this one has me stumped.

> I have a server (192.169.0.x) which sits on a private network. eth0 is
> set to the above address. All I want to do is to allow a few services
> to be accessed on this server by the internal network and allow
> everything in the OUTPUT chain. I have set the OUTPUT chain default
> policy to ACCEPT, and the INPUT chain has a default policy of DROP and
> a few rules set up.

> The INPUT chain works fine, but from the server itself I cannot telnet
> to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
> The mailserver is also on the 192,168.0.x network.

> Does anyone have any ideas as I am baffled? My guess is that it must
> be to do with just the one interface card, but I cannot work out why.
> All help gratefully received.....

> Many thanks,

> Steve Westrip


Your problem is very likely *not* related to having a single interface.
Your problem is likely to be related to problems with your INPUT rules.
Use something like

iptables -A INPUT -i eth0 -p tcp ! --syn \
--sport $SERVRPORT -d 192.169.0.x --dport 1024:65535 -j ACCEPT

where SERVPORT is defined to by the server's port number (e.g.,
telnet=23, or, egads!, 0:1023). Also be aware that some services require
authentication (113).

The ! --syn means that you initiated the connection.

Clyde

 
 
 

iptables and one interface

Post by DustyDat » Thu, 22 Aug 2002 19:27:12




> > [...]
> > I have a server (192.169.0.x) which sits on a private network. eth0 is
> > set to the above address. All I want to do is to allow a few services
> > to be accessed on this server by the internal network and allow
> > everything in the OUTPUT chain. I have set the OUTPUT chain default
> > policy to ACCEPT, and the INPUT chain has a default policy of DROP and
> > a few rules set up.

> > The INPUT chain works fine, but from the server itself I cannot telnet
> > to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
> > The mailserver is also on the 192,168.0.x network.
> > [...]

> Did you tell your INPUT chain to accept incoming traffic from a locally
> initiated connection? Something like

> iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

> It should come last, after the rules for opening local daemon ports.

> Dragan

Thanks for that. Problem sorted.
 
 
 

iptables and one interface

Post by DustyDat » Thu, 22 Aug 2002 23:13:13




> > Hi All,

> > I am having a bit of a problem with setting up an iptables firewall on
> > a machine with one interface. I have set up a few successfully with
> > two but this one has me stumped.

> > I have a server (192.169.0.x) which sits on a private network. eth0 is
> > set to the above address. All I want to do is to allow a few services
> > to be accessed on this server by the internal network and allow
> > everything in the OUTPUT chain. I have set the OUTPUT chain default
> > policy to ACCEPT, and the INPUT chain has a default policy of DROP and
> > a few rules set up.

> > The INPUT chain works fine, but from the server itself I cannot telnet
> > to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
> > The mailserver is also on the 192,168.0.x network.

> > Does anyone have any ideas as I am baffled? My guess is that it must
> > be to do with just the one interface card, but I cannot work out why.
> > All help gratefully received.....

> > Many thanks,

> > Steve Westrip

> Your problem is very likely *not* related to having a single interface.
> Your problem is likely to be related to problems with your INPUT rules.
> Use something like

> iptables -A INPUT -i eth0 -p tcp ! --syn \
> --sport $SERVRPORT -d 192.169.0.x --dport 1024:65535 -j ACCEPT

> where SERVPORT is defined to by the server's port number (e.g.,
> telnet=23, or, egads!, 0:1023). Also be aware that some services require
> authentication (113).

> The ! --syn means that you initiated the connection.

> Clyde

I entered the command from the other poster (yours hadn't arrived by
then!!) and it now connects,, but it takes about 15-30 seconds to
connect to an internal mailserver (or any other internal machine) via
telnet and get a login prompt. This server has no access to a DNS
server but the entry for mailserver is in the hosts file. It is worth
noting that with iptables 'turned off' the connection is immediate.

Any ideas?

 
 
 

iptables and one interface

Post by Chris Patc » Sun, 25 Aug 2002 19:38:16


try adding these lines at after you flush your tables and set your policies.
(right from Linux Firewalls, 2nd ed.)

#allow unlimited loopback traffic
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT




> > > Hi All,

> > > I am having a bit of a problem with setting up an iptables firewall on
> > > a machine with one interface. I have set up a few successfully with
> > > two but this one has me stumped.

> > > I have a server (192.169.0.x) which sits on a private network. eth0 is
> > > set to the above address. All I want to do is to allow a few services
> > > to be accessed on this server by the internal network and allow
> > > everything in the OUTPUT chain. I have set the OUTPUT chain default
> > > policy to ACCEPT, and the INPUT chain has a default policy of DROP and
> > > a few rules set up.

> > > The INPUT chain works fine, but from the server itself I cannot telnet
> > > to our mailserver on port 23, 25 or 110 but if I stop iptables I can.
> > > The mailserver is also on the 192,168.0.x network.

> > > Does anyone have any ideas as I am baffled? My guess is that it must
> > > be to do with just the one interface card, but I cannot work out why.
> > > All help gratefully received.....

> > > Many thanks,

> > > Steve Westrip

> > Your problem is very likely *not* related to having a single interface.
> > Your problem is likely to be related to problems with your INPUT rules.
> > Use something like

> > iptables -A INPUT -i eth0 -p tcp ! --syn \
> > --sport $SERVRPORT -d 192.169.0.x --dport 1024:65535 -j ACCEPT

> > where SERVPORT is defined to by the server's port number (e.g.,
> > telnet=23, or, egads!, 0:1023). Also be aware that some services require
> > authentication (113).

> > The ! --syn means that you initiated the connection.

> > Clyde

> I entered the command from the other poster (yours hadn't arrived by
> then!!) and it now connects,, but it takes about 15-30 seconds to
> connect to an internal mailserver (or any other internal machine) via
> telnet and get a login prompt. This server has no access to a DNS
> server but the entry for mailserver is in the hosts file. It is worth
> noting that with iptables 'turned off' the connection is immediate.

> Any ideas?

 
 
 

1. one-to-one mapping using IPTABLES with LOG.

Hello,
I want to implement one-to-one mapping of ip addresses using
iptables with logging.

Network is as follows:

-----192.168.1.0/24-----FIREWALL(IPTABLES)-----192.168.4.0/24
(Net-I)[eth0]                                   (Net-II)[eth1]

I want each ip in Net-I when goes out through the firewall takes a
IP from Net-II. I think for it the following rule is sufficient.

Rule -I
###iptables -t nat -A POSTROUTING  -o eth1 -s 192.168.1.1/32 -SNAT -to
192.168.4.1
Note: I want it to be static mapping.

Now, I also want to enable logging for the net-I(192.168.1.0/24)i.e.
keep track of who is doing what.

Will the following rule set work if I put instead of Rule-I?

#iptables -t nat -N LOG-TCP
#iptables -t nat -A POSTROUTING -p tcp -s 192.168.1.1/32
-m state --state NEW -j LOG-TCP
#iptables -t -A LOG-TCP -j LOG --log-tcp-options
--log-ip-options  --log-prefix "[OUT-TCP-CONNECTIONS]:"
#iptables -t nat -A LOG-TCP -o eth1 -j SNAT -to 192.168.1.4
Any suggestions ?

thanks and regards
baruah

2. network programming question

3. routing issue and maximum sub interfaces on one physical interface question

4. Dumb MSN login question

5. Interface names for a UNIX machine with more than one interface.

6. One problem, two solutions (spaces in file names)

7. dhcpd on for one interface on two interface system ?

8. Read MAC address

9. one physical interface, 3 virtual interfaces, and inetd

10. How to have more than one IP addresses on one interface card?

11. More than one IP-Adress on one Interface

12. setup one interface for 'up' and another one for 'down'

13. more than one ip address to one interface eth0