Linux dual-Nic NAT shared internet access

Source: Internet
Author: User
Linux dual-Nic NAT shared internet access I. network extension structure: Server: two NICs settings: eth0: 202.96.168.100 mask: 255.255.255.0 Gateway: 202.96.168.68 # with Inte. net associated eth1: 192.168.1.1 mask: 255.255.255.0 # connect to the lan...
Linux dual-Nic NAT shared internet access I. network extension structure: Server: two NICs settings: eth0: 202.96.168.100 mask: 255.255.255.0 Gateway: 202.96.168.68 # with Inte. net associated eth1: 192.168.1.1 mask: 255.255.255.0 # Subnet segment of the client connected to the LAN: 192.168.1.0/255 www.2cto.com II. server settings: (either of the two methods can be used) 1. use the NAT method to execute the following commands on the server: echo "1">/proc/sys. net/ipv4/ip_forward # enable IP forwarding. 1 indicates forwarding. 0 indicates not forwarding. you can also modify/etc/sysctl by running the preceding command. conf implementation, adding a line above and below in the file: net. ipv4.ip _ forward = 1 other commands are: iptables-F iptables-P INPUT ACCE PT iptables-p forward accept iptables-t nat-a postrouting-o eth0-j MASQUERADE # enable NAT www.2cto.com 2.2 and use the bridge method: echo "1">/proc/sys. net/ipv4/ip_forward ifconfig eth0 0.0.0.0 up ifconfig eth1 0.0.0.0 up brctl addbr br0 # Add a bridge brctl addif br0 eth0 brctl addif br0 eth1 # Add eth0 eth1 to the bridge to go to ifconfig br0 limit 25 broadcast 192.168.1.255 up # assign an IP address to the bridge, if you do not need NAT or remote access to the bridge P address, but you must enable the bridge (ifconfig br0 up) route add default gw 202.96.168.68 # if the bridge does not need to access other machines, you can not add a gateway. 3. client settings: eth0: 192.168.1.10 mask: 255.255.255.0 Gateway: 192.168.1.1 4. iptables command reference: iptables command syntax: iptables [-t nat] CMD [chain] [rule-matcher] [-j target]-t nat: indicates the operation of the nat table www.2cto.com CMD: for the operation command chain: for chain name rule-matcher: for rule matching target: iptables-t nat-F # clear the rules iptables-F in the original nat table # clear the rules iptables-p forward accept in the original filter # allow IP forwarding by default 5, according to the NAT method, the configuration is completed soon and the Internet can be smoothly accessed. For users who have no special requirements on network configuration, you can use the NAT method, which is simple and practical.
 
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.