0

I am setting up Postfix to relay mail for our internal devices that do not support authentication. We will have a number of devices. Is there an easier way to list out devices vs. just listing them separated by a comma? This list may become rather long over time with different subnets. Any suggestions on how to better manage this list would be helpful.

mynetworks = 192.168.1.5, 192.168.1.62, 192.168.1.64

Thanks! Eric

3 Answers 3

3

Depending on your requirements, the easiest way might be to simply list the entire ranges, for example all the IP's you given are RFC1918 (non routable) space, so you could get away with something like

mynetworks = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12 (If you are unfamiliar with it, the /XX at the end of each IP range tells how big the range is - /24 is a class C)

If you only have IP addresses in those ranges, ie you could have a host as 192.168.1.3 another as 192.168.20.44 and both would be covered as they are part of the bigger non-routed block. (Just don't do this with IP addresses which are routable).

Another way to make life easier might be to use a hash table, mysql table or regex list (as you might do for other options) to put this information into a separately parsed file. See DATABASE_README.html#types for a list of lookup table types

1
  • I forgot about using a hash table. I'll need to refresh my memory :) Thanks! Oct 20, 2014 at 19:22
1

I created a file called auth_mailers:

#HQ Wired
172.16.2.2   any_value

#HQ Wireless
172.16.3.2   any_value

Created the hash table:

postmap auth_mailers

Edited my main.cf

mynetworks = hash:/etc/postfix/auth_mailers

Reloaded Postfix:

sudo /etc/init.d/postfix reload

This seems to work, but I will do more testing.

1
  • 1
    Why would you use hash-style for networks, instead of the special cidr-type?
    – Mikhail T.
    Aug 28, 2015 at 21:32
0

If you want to use network notations with mask values like 192.168.0.0/16 you should use the cidr type instead of the hash one. The format is the same

192.168.0.0/16          any_value
10.0.0.0/8              any_value
2
  • davidgo's answer already suggested using CIDR notation. I don't see that this answer adds any additional information.
    – doneal24
    Dec 23, 2022 at 17:35
  • the original question was trying to avoid a comma separated list (davidgo suggestion) and, although Mikhail T. has suggested this on his comment having the syntax explained might help others (like me) to find a quick answer to this problem.
    – iceburn_pt
    Jan 5, 2023 at 10:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .