Use debian iptables for simple routing (dual Nic)

Source: Internet
Author: User
Use debian iptables for simple routing (dual Nic)-Linux Release Technology-Debian information. The following is a detailed description. 1. Add the following to/etc/rc. d/rc. local:

(1). directly access the Internet through DHCP.
Echo 1>/proc/sys/net/ipv4/ip_forward
Iptables-t nat-a postrouting-o eth0-s 192.168.1.0/24-j MASQUERADE

(2). For ADSL dial-up Internet access
Echo 1>/proc/sys/net/ipv4/ip_forward
Iptables-t nat-a postrouting-o ppp0-s 192.168.1.0/24-j MASQUERADE

(3). If it is a fixed IP Address

Iptables-t nat-a postrouting-o eth0-s 192.168.1.0/24-j SNAT? To-source 10.4.40.13 (fixed IP)

2./etc/network/interfaces file configuration
# This file describes the network interfaces available on your system
# And how to activate them. For more information, see interfaces (5 ).

# The loopback network interface
Auto lo
Iface lo inet loopback

Auto dsl-provider
Iface dsl-provider inet ppp
Pre-up/sbin/ifconfig eth1 up # line maintained by pppoeconf
Provider dsl-provider

Auto eth1
Iface eth1 inet manual

Auto eth0
Iface eth0 inet static
Address 192.168.1.1
Netmask 255.255.255.0

3. Configure the client Nic
Iface eth0 inet static
Address 192.168.1.3
Netmask 255.255.255.0
Gateway 192.168.1.1

If another server is connected to the above server, the configuration is basically the same as above, for example:

1. Same as above (omitted)

2. Configure the Internet Nic
Iface eth0 inet static
Address 192.168.1.20.
Netmask 255.255.255.0
Gateway 192.168.1.1 // specify the IP address of the previous Server

3. Configure the Intranet Nic
Iface eth1 inet static
Address 192.168.1.134
Netmask 255.255.255.0

4. Configure other client NICs
Iface eth0 inet static
Address 192.168.1.135
Netmask 255.255.255.0
Gateway 192.168.1.htm // gateway

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.