Using NAT for Internet access to Linux servers

Source: Internet
Author: User

If you have installed Linux, how can you access the Internet through Linux? Here we will explain how to use NAT to share Internet access on the Linux Server ADSL, so that you can easily use the Linux server to access the Internet. I hope you will learn how to use NAT to access the Internet on the Linux Server ADSL.

1. Nic configuration.

Two NICs, eth0 is a dial-up Nic, IP: 192.168.1.1 other addresses are also allowed), eth1 is an intranet Nic, IP: 192.168.0.1. The mask is 255.255.255.0. The lan network segment is 192.168.0.0.

Note: Neither network card can be configured with a gateway. Dial PPPOE) Nic does not need to be set

2. PPPoE software upgrade and Installation

1) download in http://www.roaringpenguin.com/pppoe/#download

2) install rp-pppoe. Run as root

Rpm-Uvh rp-pppoe-3.5-1.i386.rpm

3. Modify/etc/sysctl. conf

Replace

Net. ipv4.ip _ forward = 0

Change

Net. ipv4.ip _ forward = 1

4. Remove the ipchains module and select only the iptables method as follows:

1) setup

2) Select system service

3) Remove ipchains

4) Select iptables

5) restart the machine

5. PPPoE client Configuration

After installing the rp-pppoe-3.5-1.i386.rpm, you can configure the PPPoE client. The process is as follows.

#/Usr/sbin/adsl-setup

>;>;>; Enter your PPPoE user name: -- Enter the user name of the dial-up account.
>;>;>; Enter the Ethernet interface connected to the ADSL modem For Solaris, this is likely to be something like/dev/hme0.for Linux, it will be ethn, where n is a number. (default eth0): -- enter eth0
>;>;>; Enter the demand value (default no): -- Enter no
>;>;>; Enter the DNS information here: -- Enter 210.52.149.2 depending on the IP address of the local carrier's DNS server)
>;>;>; Please enter your PPPoE password: -- enter the Netcom User password
>;>;>; Choose a type of firewall (0-2): -- enter 0
>;>;>; Accept these settings and adjust configuration files (y/n )? -- Input y

6. Start the dial-up connection

/Usr/sbin/adsl-start

After successful connection, the screen displays Connected.

Now, this linux instance can be browsed online.

7. IP camouflage

To enable other machines in the LAN to share the Internet via a Linux server, at least the following command must be executed:

Iptables-t nat-a postrouting-o ppp0-j MASQUERADE

After that, you can access the Internet through Linux on a PC with the network segment 192.168.0.0 and the gateway is 192.168.0.1!

8. Auto Start

To enable automatic dialing on a Linux server, perform the following steps.

1) chkconfig -- add adsl

2) setup

3) Select system services

4) Select ADSL

5) OK to exit

6) Open/etc/rc. d/rc. local and add the following statement at the end of the file.

 
 
  1. echo "[OK]"  
  2. echo "Drop ICMP form anywhere"  
  3. echo 1 >; /proc/sys/net/ipv4/icmp_echo_ignore_all  
  4. echo "[OK]"  
  5. iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE 

Note: The first four sentences are used to Disable ICMP to prevent other users from pinging.

9. Now everything is OK. A simple dial-up is built. After restarting the machine, we found that all internet shared connections in linux are ready. In this way, you can access the Internet on the Linux server.

  1. Key Points of Linux cluster technology
  2. Another Linux server cluster software for LifeKeeper
  3. Linux server cluster technology
  4. Step 7: Protect Linux servers
  5. Introduction to ntop configuration in Linux

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.