Linux iptables gateway configuration and port forwarding

Source: Internet
Author: User

[Root @ localhost ~] # Vi/usr/local/bin/firewall. Sh
Echo 1>/proc/sys/NET/IPv4/ip_forward

Modprobe ip_tables
Modprobe iptable_filter
Modprobe iptable_nat
Modprobe ip_conntrack
Modprobe ip_conntrack_ftp
Modprobe ip_nat_ftp

Iptables-F Input
Iptables-F forward
Iptables-F postrouting-T Nat
Iptables-P forward drop
Iptables-T Nat-A postrouting-O eth1-s 192.168.168.0/24-J Masquerade
Iptables-a forward-I eth1-M state -- State established, related-J accept
Iptables-a forward-s 192.168.168.0/24-J accept

# Eth1 is Internet, and 3389 is forwarded to 192.168.168.23
Iptables-T Nat-A prerouting-I eth1-P TCP -- dport 3389-J DNAT -- To 192.168.168.23: 3389
Iptables-a forward-I eth1-P TCP -- dport 3389-D 192.168.168.23-J accept

[Root @ localhost ~] # Echo "/usr/local/bin/firewall. Sh">/etc/rc. Local

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.