Dual-nic network forwarding

Source: Internet
Author: User

Dual-nic network forwarding existing dual-nic ubuntu connection internal and external two network Nic eth0, network segment 192.168.63.0 Intranet Nic eth1, network segment 10.147.9.0 target, other Intranet devices, such as 10.147.9.70, can access the Internet, such as 192.168.63.1. First, you must set the dual Nic to use $ sudo vim/etc/network/interfaces at the same time. auto loiface lo inet loopback iface eth1 inet staticaddress 10.147.9.1 auto eth1 note, the Internet segment seems to have been set up in gnome, so it is not mentioned. The specifics need to be studied. In this case, the Intranet and Internet are basically connected to other devices in the Intranet, such as 10.147.9.70, after the restart, the system fails to run windows. If route add 192.168.63.0 mask route 255.255.0 10.147.9.250 is permanent, add route add-p 192.168.63.0 mask route 255.255.0 route add-net 192.168.63.0 netmask route 255.255.255.0 gateway Routing permanent static route add $ sudo vim/etc/rc. localroute add-net 192.168.63.0 netmask 255.255.255.0 gateway 10.147.9.250 add the above sentence to exit 0, which means all requests sent to 192.168.63 All IP addresses of CIDR blocks are first sent to 10.147.9.250 instead of 10.147.9.1 from 10.147.9.70 ping 10.147.9.250 from 10.147.9.70 ping 192.168.63.50 from 10.147.9.70 (external network card address of the same device) ping from 10.147.9.70 to 192.168.63.1 the Internet gateway fails to ping from 10.147.9.250 to 10.147.9.70 to ping from 192.168.63.50 to 192.168.63.1. For more information, see iptables for the following operations: to enable the ipv4 forwarding function, change $ sudo vim/etc/sysctl. conf removes the # in the following sentence # net. ipv4.ip _ forward = 1 and $ sudo vim/proc/sys/net/ipv4/ip_forward change 0 to 1 and then run the following command I Ptables -- flushiptables -- table nat -- flushiptables -- delete-chainiptables -- table nat -- append POSTROUTING -- out-interface eth0-j MASQUERADEiptables -- append FORWARD -- in-interface eth1-j ACCEPT 10.147.9.70 ping 192.168.63.1, another problem is that the settings cannot be saved after shutdown. That is to say, you have to re-run the above four commands for one afternoon and finally get it done. Add the preceding four commands to the script that runs automatically upon startup. This is also Ubuntu tips $ sudo vim/etc/rc. add the above four commands to exit 0 in local. I will write a short article about how to explore and share my experience with others, we will also share our experiences with more people to avoid detours. Continued: in fact, this is an example of bridge forwarding. The intranet is connected to the Internet through a server with a dual Nic. When the Intranet accesses an Internet address, it sends the request to the Intranet Nic of the gateway, iptablesd then sends the request to the corresponding Internet server through another network adapter connected to the Internet to complete forwarding.

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.