Iptables firewall configuration instance

Source: Internet
Author: User
#! /Bin/sh # The following are network information about the firewall # internal network adapter: eth1 # internal IP address: 192.168.1.1 # internal subnet mask: 255.255.255.0 # internal network segment: 192.168.1.0/24 # internal Nic: eth0 # internal IP address: 24.68.32.118 # internal subnet mask: 255.255.252.0 #*************#! /Bin/sh
# The Network information about the firewall is as follows:
# Internal Nic: eth1
# Internal IP address: 192.168.1.1
# Internal subnet mask: 255.255.255.0
# Internal network segment: 192.168.1.0/24
# Internal Nic: eth0
# Internal IP address: 24.68.32.118
# Internal subnet mask: 255.255.252.0
#*************************************
# Save the current settings to/etc/sysconfig/ Iptables
# Use/etc/rc. d/init. d/iptables save
# Or/sbin/service iptables save
#*************************************
# Using IP Forwarding
Echo 1>/proc/sys/net/ipv4/ip_forward
# Clear original settings
Iptables-F
Iptables-X
Iptables-F-t mangle
Iptables-t mangle-X
Iptables-F-t nat
Iptables-t nat-X
# Set Filter Table default rules
Iptables-P INPUT ACCEPT
Iptables-P OUTPUT ACCEPT
Iptables-P FORWARD ACCEPT
# Enable NAT
Iptables-t nat-a postrouting-o eth0-j SNAT -- to-source24.68.32.118
# Enable external address translation
# All connections to 24.68.32.118: 8080 are forwarded to 192.168.1.5: 80.
Iptables-t nat-a prerouting-p tcp-d 24.68.32.118 -- dport8080-j DNAT -- to 192.168.1.5: 80
######################################## #####
# The following are successfully configured instances in the lab:
/*
Modprobe ip_tables
Modprobe ip_nat_ftp
Modprobe ip_nat_irc
Modprobe ip_conntrack
Modprobe ip_conntrack_ftp
Modprobe ip_conntrack_irc
/Sbin/iptables-F
/Sbin/iptables-X
/Sbin/iptables-Z
/Sbin/iptables-F-t nat
/Sbin/iptables-X-t nat
/Sbin/iptables-Z-t nat
/Sbin/iptables-P INPUT ACCEPT
/Sbin/iptables-P OUTPUT ACCEPT
/Sbin/iptables-P FORWARD ACCEPT
/Sbin/iptables-t nat-P PREROUTING ACCEPT
/Sbin/iptables-t nat-P POSTROUTING ACCEPT
/Sbin/iptables-t nat-P OUTPUT ACCEPT
Iptables-t nat-a postrouting-s 192.168.1.0/24-jMASQUERADE
*/

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.