Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is a firewall/gateway machine with eth0 Public and eth1 Private network (

I would like to block all OUTPUT connections for private users (eth1) except couple of networks like:, etc. as they are in our city network.

There are a lot of questions here about iptables but I couldn't find a way to resolve this issue.

It might also happen that some user, say, would not be restricted to those networks.

If I do:

...that would make me adding rules per user multiplied by number of networks

So is there any way to GROUP those city networks as well?

share|improve this question
up vote 1 down vote accepted

Sounds to me that what you want is ipsets. Here is link that human beings can read. For installation, if you are on Fedora take a look at this And if on Ubuntu look at this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.