Enable IP packet forwarding for Gateway and nat settings in ubuntu

Source: Internet
Author: User
Basic idea: enable IP forwarding and set iptables rules. 2. 1. enable IP forwarding in either of the following ways: echo & quot; 1 & quot; & gt;/proc/sys/net/ipv4/ip_forward fixed: modify/etc/sysctl. conf to cancel the annotation of this line: net. ipv4.ip _ forward1 and then immediately generate... basic idea: enable IP forwarding and set iptables rules.

2. 1. enable IP forwarding
Two methods,
Temporary: echo "1">/proc/sys/net/ipv4/ip_forward
Fixed: modify/etc/sysctl. conf to cancel the comments of this line:
Net. ipv4.ip _ forward = 1
Then make it take effect immediately
Sysctl-p

2. set iptables rules
Temporary: iptables-t nat-a postrouting-j MASQUERADE
Fixed:
Or write the preceding code to a startup script (such as/etc/rc. local ). There is another version:
Iptables-F
Iptables-P INPUT ACCEPT
Iptables-P FORWARD ACCEPT
Iptables-t nat-a postrouting-s 192.168.0.0/24-o eth1-jMASQUERADE
It is said that "the first sentence is to clear all previous iptables rules, the second sentence is to allow receiving and sending data packets, and the fourth sentence is to NAT on the eth1 network port", just a few more nonsense words than above, and finally specify what Nic parameters, have not tried. The usage of iptables is still easy to learn.

3. client settings
Set the default gateway to 192.168.0.1. for the IP address, set it to 192.168.0.

From Patriot's blog
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.