Configuring Linux Server request forwarding using Iptables

Source: Internet
Author: User

1 First change the net.ipv4.ip_forward=0 in the/etc/sysctl.conf configuration file to net.ipv4.ip_forward=1
then execute the SYSCTL-P/etc/sysctl.conf mission order to take effect.

2 Configuring IP spoofing for Firewalls
iptables-t nat-a postrouting-o eth0-j Masquerade

3 If you want a server within the internal network to be externally accessible, you can use the-j DNAT target of the prerouting chain within the NAT to specify that the destination IP address and port forwarding request be connected to the internal server. For example, if you want to forward incoming HTTP requests to a dedicated Apache HTTP Server server System on 172.11.0.21, run the following command
iptables-t nat-a prerouting-i eth0-p tcp--dport 80-j DNAT \
--to 172.11.0.21:80

4 This rule allows incoming 80-port requests to be forwarded from the firewall to the 172.11.0.21 server.
iptables-a forward-i eth0-p tcp--dport 80-d 172.11.0.21-j ACCEPT


Configuring Linux Server request forwarding using Iptables

Related Article

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.