LinuxSecurity.com
Share your story
The central voice for Linux and Open Source security news
Home News Topics Advisories HOWTOs Features Newsletters About Register

Welcome!
Sign up!
EnGarde Community
Login
Polls
What is the most important Linux security technology?
 
Advisories
Community
Linux Events
Linux User Groups
Link to Us
Security Center
Book Reviews
Security Dictionary
Security Tips
SELinux
White Papers
Featured Blogs
All About Linux
DanWalsh LiveJournal
Securitydistro
Latest Newsletters
Linux Security Week: October 20th, 2014
Linux Advisory Watch: October 17th, 2014
Subscribe
LinuxSecurity Newsletters
E-mail:
Choose Lists:
About our Newsletters
RSS Feeds
Get the LinuxSecurity news you want faster with RSS
Powered By

  
IP Masquerading multiple internal networks

6.5. IP Masquerading multiple internal networks

Masquerading more than one internal network is fairly simple. You need to first make sure that all of your networks are running correctly (both internal and external). You then need to enable traffic to pass to both the other internal interfaces and to be MASQed to the Internet.

Next, you need to enable Masquerading on the INTERNAL interfaces. This example uses a total of THREE interfaces: EXTIF stands for the eth0 interface which is the EXTERNAL connection to the Internet. INTIF stands for the eth1 interface and is the 192.168.0.0 network. Finally, INTIF2 stands for the eth2 interface and is the 192.168.1.0 network. Both INTIF and INTIF2 will be MASQed out of interface eth0 or EXTIF. In your rc.firewall-* ruleset next to the existing MASQ at the very end of the ruleset, add the following:

6.5.1. iptables support for multiple internal lans

  • # 2.6.x and 2.4.x kernels with IPTABLES
    #
    # The following rules build upon the rc.firewall-iptables-stronger ruleset.
    # Please see that ruleset in Section 6 for how all variables get set, etc.
    
    
      #Enable internal interfaces to communication between each other
      #
      $IPTABLES -A FORWARD -i $EXTIF -o $INTIF2 -m state --state ESTABLISHED,RELATED \
     -j ACCEPT
      $IPTABLES -A FORWARD -i $INTIF -o $INTIF2 -m state --state ESTABLISHED,RELATED \
     -j ACCEPT
      $IPTABLES -A FORWARD -i $INTIF2 -o $INTIF -m state --state ESTABLISHED,RELATED \
     -j ACCEPT
    
      $IPTABLES -t nat -A POSTROUTING -o $EXTIF -j SNAT --to $EXTIP
         

6.5.2. ipchains support for multiple internal lans

  • # 2.2.x kernels with IPCHAINS
    #
    # The following rules build upon the rc.firewall-ipchains-stronger ruleset.
    # Please see that ruleset in Section 6 for how all variables get set, etc.
    
      #Enable internal interfaces to communication between each other
      $IPCHAINS -A forward -i eth1 -d 192.168.0.0/24 -j ACCEPT
      $IPCHAINS -A forward -i eth2 -d 192.168.1.0/24 -j ACCEPT
    
      #Enable internal interfaces to MASQ out to the Internet
      $IPCHAINS -A forward -j MASQ -i eth0 -s 192.168.0.0/24 -d 0.0.0.0/0
      $IPCHAINS -A forward -j MASQ -i eth0 -s 192.168.1.0/24 -d 0.0.0.0/0
         

6.5.3. ipfwadm support for multiple internal lans

  • # 2.0.x kernels with IPFWADM
    #
    # The following rules build upon the rc.firewall-ipfwadm-stronger ruleset.
    # Please see that ruleset in Section 6 for how all variables get set, etc.
    
      #Enable internal interfaces to communication between each other
      /sbin/ipfwadm -F -a accept -V 192.168.0.1 -D 192.168.1.0/24
      /sbin/ipfwadm -F -a accept -V 192.168.1.1 -D 192.168.0.0/24
    
      #Enable internal interfaces to MASQ out to the Internet 
      /sbin/ipfwadm -F -a masq -W eth0 -S 192.168.0.0/24 -D 0.0.0.0/0
      /sbin/ipfwadm -F -a masq -W eth0 -S 192.168.1.0/24 -D 0.0.0.0/0
         

Please note that it is CORRECT to have "eth0" specified multiple times for the exmples shown above. The reason for this is the Linux kernel needs to know which interface is used for OUTGOING traffic. Since eth0 in the above examples is the Internet connection, it is listed for each internal interface.

    
Partner

 

Latest Features
Peter Smith Releases Linux Network Security Online
Securing a Linux Web Server
Password guessing with Medusa 2.0
Password guessing as an attack vector
Squid and Digest Authentication
Squid and Basic Authentication
Demystifying the Chinese Hacking Industry: Earning 6 Million a Night
Free Online security course (LearnSIA) - A Call for Help
What You Need to Know About Linux Rootkits
Review: A Practical Guide to Fedora and Red Hat Enterprise Linux - Fifth Edition
Yesterday's Edition
Pro-Privacy Senator Wyden on Fighting the NSA From Inside the System
NIST to hypervisor admins: secure your systems
Quick PHP patch beats slow research reveal
Partner Sponsor

Community | HOWTOs | Blogs | Features | Book Reviews | Networking
 Security Projects |  Latest News |  Newsletters |  SELinux |  Privacy |  Home
 Hardening |   About Us |   Advertise |   Legal Notice |   RSS |   Guardian Digital
(c)Copyright 2014 Guardian Digital, Inc. All rights reserved.