Linux NAT configuration for Internet access

Source: Internet
Author: User
Tags nameserver

1. Environment

[Email protected] ~]# lsb_release-a
LSB Version:: core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32: Printing-4.0-noarch
Distributor Id:centos
Description:centos release 5.10 (Final)
release:5.10
Codename:final

[Email protected] ~]# getconf long_bit
32

2. Configure Ip/dns and other information

External network:

# ifconfig Eth0 | grep "inet Addr"
inet addr:222.47.48.25 bcast:222.47.48.63 mask:255.255.255.192

Intranet:

# ifconfig Eth1 | grep "inet Addr"
inet addr:192.168.1.2 bcast:192.168.1.255 mask:255.255.255.0

Dns:

# cat/etc/resolv.conf
NameServer 222.47.62.142
NameServer 222.47.29.93

3. Turn on the kernel forwarding function

echo 1 >/proc/sys/net/ipv4/ip_forward//NIC will revert to 0 after reboot, so change the following parameter to "1"

# Cat/etc/sysctl.conf | grep Ip_forward
Net.ipv4.ip_forward = 0

4. Configure NAT

# iptables-t nat-a postrouting-s 192.168.1.0/255.255.255.0-o eth0-j SNAT--to-source 222.47.48.25

# iptables-d FORWARD 1

#/etc/init.d/iptables Save

#/etc/init.d/iptables Restart

This article is from the "Square Hill" blog, please be sure to keep this source http://63638790.blog.51cto.com/513514/1559409

Linux NAT configuration for Internet access

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.