Linux NAT Service--enables intranet servers to surf the internet

Source: Internet
Author: User
Tags traceroute command

The 1th chapter NAT enables the intranet host to Sisu the network 1.1 environment

Host name Server / end- network IP Intranet

Nat-s Server 10.0.0.41 172.16.1.41

Nat-c Client-72.16.1.31

1.2 Configuration (server side) 1.2.1 Set iptables rules on Nat-s

match The IP of 172.16.1.0/24 network segment of intranet,want to Sisu net, can throw the packet to 10.0.0.41 this address.

Iptables-t nat-a postrouting-s172.16.1.0/255.255.255.0-j SNAT--to 10.0.0.41
1.2.2 Turn on kernel forwarding

(1) First see if it is already open, if the value is 1, it is already open

(2) Otherwise, you need to modify the configuration file /etc/sysctl.confto find the parameter so that it becomes:Net.ipv4.ip_forward = 1

(3) then run:sysctl-p

[[email protected] ~]# sysctl-a |grep ' Net.ipv4.ip_forward ' #<== see if kernel forwarding is turned on net.ipv4.ip_forward = 0 #<==0 for off, 1 for open [[email protected] ~]# sed-i ' s#net.ipv4.ip_forward =0#net.ipv4.ip_forward = 1#g '/etc/sysctl.conf #<==sed command One-click Modify [[Em AIL protected] ~]# sysctl-p #<== make kernel parameters effective [[email protected] ~]# sysctl-a |grep ' Net.ipv4.ip_forward ' #<== validate again NET.IPV 4.ip_forward = 1

1.3 Configuring Gateways and DNS (clients)
[Email protected] ~]# cat>>/etc/sysconfig/network-scripts/ifcfg-eth1<<eof #网关与DNS > gateway= 172.16.1.41> dns1=8.8.8.8> dns2=114.114.114.114> EOF [[email protected] ~]# tail-3/etc/sysconfig/       Network-scripts/ifcfg-eth1 #验证GATEWAY =172.16.1.41dns1=8.8.8.8dns2=114.114.114.114 [[email protected] ~]# Ifdown eth0 #先把其它的网卡暂时关闭 [[email protected] ~]# ifdown eth1 && ifup eth1 #使eth1配置生效, execute this command a few more times! [Email protected] ~]$ route-n #查看网关 [[email protected] ~]$ cat/etc/resolv.conf #查看DNSnameserver 114.114.114.114n Ameserver 8.8.8.8


1.4 Authentication (client) 1.4.1ping

can ping the address of the Brother Valley server, indicating the internet!

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/85/6B/wKioL1ei6zrR7yW9AAAjxT9Mx0I365.png-wh_500x0-wm_3 -wmp_4-s_1011466800.png "title=" 01.png "alt=" Wkiol1ei6zrr7yw9aaajxt9mx0i365.png-wh_50 "/>

1.1.1traceroute

with the traceroute command can see the process of packet forwarding, want to go out of the network, must find the gateway, the gateway to the packet dropped to the external network card, external network card can help us out of the network.

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/85/6B/wKioL1ei61aRuAE2AAAWQCHB5sw000.png-wh_500x0-wm_3 -wmp_4-s_3993100940.png "title=" 02.png "alt=" Wkiol1ei61aruae2aaawqchb5sw000.png-wh_50 "/>

1.1.1nslookup

Can parse the domain name normally, explain can open webpage normally!

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/85/6C/wKiom1ei62zx8KOJAAAcMRfkKzQ440.png-wh_500x0-wm_3 -wmp_4-s_3417961612.png "title=" 03.png "alt=" Wkiom1ei62zx8kojaaacmrfkkzq440.png-wh_50 "/>

This article is from the "Chen was 007" blog, please be sure to keep this source http://chenfage.blog.51cto.com/8804946/1834349

Linux NAT Service--enables intranet servers to surf the internet

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.