Changeset 10714 in genesis for tools


Ignore:
Timestamp:
May 7, 2012, 8:59:45 PM (13 years ago)
Author:
rick
Message:

Fill the content of the pf.hybrid.conf.local

rdr_rules is een array van de vorm:

  • [src_port, dest_ip, dest_port]

rdr_ip: is de external facing IP waar de rdr_rules (normaal op gelden). Dit is
voornamelijk administratief en moet dus het externe IP zijn voor het geval er

Let wel op dat een (eventuele) router die ertussen zit natuurlijk ook port
forwarding moet instellen.

Related-To: nodefactory#152

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10705 r10714  
    791791  """ Generate configuration file '/etc/pf.hybrid.conf.local' """
    792792  datadump['autogen_header'] = generate_header("#")
    793   datadump['rdr_rules' ] = ('8081', '172.16.4.46', 'http')
    794793  return Template("""\
    795794{{ autogen_header }}
    796795
    797796# Redirect some internal facing services outside (7)
    798 # rdr on $ext_if inet proto tcp from any to $ext_if port 8081 tag SRV -> 172.16.4.46 port http
    799 # XXX: Implement
     797# INFO: {{ rdr_rules|count }} rdr_rules (outside to internal redirect rules) defined.
     798{% for src_port,dest_ip,dest_port in rdr_rules -%}
     799rdr on $ext_if inet proto tcp from any to $ext_if port {{ src_port }} tag SRV -> {{ dest_ip }} port {{ dest_port }}
     800{% endfor -%}
    800801""").render(datadump)
    801802
     
    855856  iface_keys = [elem for elem in datadump.keys() if elem.startswith('iface_')]
    856857  for key in sorted(set(datadump.keys()) - set(iface_keys)):
    857     output += "%-10s: %s\n" % (key, format_yaml_value(datadump[key]))
     858    if key == 'rdr_rules':
     859      output += '%-10s:\n' % 'rdr_rules'
     860      for rdr_rule in datadump[key]:
     861        output += '- %s\n' % rdr_rule
     862    else:
     863      output += "%-10s: %s\n" % (key, format_yaml_value(datadump[key]))
    858864
    859865  output += "\n\n"
Note: See TracChangeset for help on using the changeset viewer.