Easy to use Linux to turn on routing and forwarding functions.

Source: Internet
Author: User

Mark, today want to let a REDHAT7 open iptables NAT forwarding function, find a half day.

A server: 192.168.30.20/24

b Server: 192.168.30.1/24,eth0; 192.168.40.1/24,eth1

C Server: 192.168.40.20/24


Goal: Allow A to ping and ssh to the C machine. This will need to jump through the B server.


Operation Process:

1. Turn on the kernel route forwarding parameter on the B server

Temporary entry into force:

echo "1" >/proc/sys/net/ipv4/ip_forward

For permanent entry, you need to modify the sysctl.conf:

Net.ipv4.ip_forward = 1

Execution Sysctl-p Immediate effect


2, b server turn on iptables NAT forwarding

Iptables-t nat-a postrouting-s 192.168.30.0/24-d 192.168.40.0/24-o eth1-j Masquerade

# Configure the Source Address 30 network segment, Destination address 40 segment of the address translation, from the ETH1 network card out.

Iptables-t nat-a postrouting-s 192.168.40.0/24-d 192.168.30.0/24-o eth0-j Masquerade

#配置源地址40网段, address translation of the destination address 30 network segment, from the Eth0 NIC.

Permanent Save: Iptables-save >/etc/sysconfig/iptables

TIP: note the corresponding network card.


3. Set the route to B server IP on a and C servers

A:route add-net 192.168.40.0 netmask 255.255.255.0 GW 192.168.30.1

C:route add-net 192.168.30.0 netmask 255.255.255.0 GW 192.168.40.1


This article is from the "Danielqu" blog, make sure to keep this source http://qujunorz.blog.51cto.com/6378776/1884459

Easy to use Linux to turn on routing and forwarding functions.

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.