ADSL利用NAT实现上网应用于Linux服务器

运维 系统运维
如果你安装了Linux系统,怎样才能实现Linux上网呢?这里为你讲解Linux服务器ADSL利用NAT实现上网共享,让你轻松应用Linux服务器上网。希望你能学会Linux服务器ADSL利用NAT实现上网。

如果你安装了Linux系统,怎样才能实现Linux上网呢?这里为你讲解Linux服务器ADSL利用NAT实现上网共享,让你轻松应用Linux服务器上网。希望你能学会Linux服务器ADSL利用NAT实现上网。

1、 网卡配置。

两块网卡,eth0为拨号网卡,IP:192.168.1.1(其他的地址也可);eth1为内网网卡,IP:192.168.0.1.掩码均为255.255.255.0.局域网网段为192.168.0.0.

注意:此处两块网卡均不能设网关。 拨号(PPPOE)的网卡不用设置

2、 PPPoE软件的升级与安装

1) 在 http://www.roaringpenguin.com/pppoe/#download 下载

2) 安装rp-pppoe.以root身份执行

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

3、 修改/etc/ sysctl.conf

将其中的

net.ipv4.ip_forward = 0

改为

net.ipv4.ip_forward = 1

4、 去除ipchains模块,只选择iptables方法如下:

1)setup

2)选择system service

3)去除ipchains

4)选中iptables

5)重启机器

5、 PPPoE客户端配置

在rp-pppoe-3.5-1.i386.rpm安装完毕后,接下来就可进行PPPoE客户端配置了。过程如下。

#/usr/sbin/adsl-setup

  >;>;>; Enter your PPPoE user name: ——此处输入拨号帐号的用户名
  >;>;>; 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): ——输eth0
  >;>;>; Enter the demand value (default no): ——输no
  >;>;>; Enter the DNS information here: ——输210.52.149.2(视当地运营商的DNS服务器IP而定)
  >;>;>; Please enter your PPPoE password: ——输网通用户口令
  >;>;>; Choose a type of firewall (0-2): ——输0
  >;>;>; Accept these settings and adjust configuration files (y/n)? ——输y

6、 启动拨号连接

/usr/sbin/adsl-start

成功连接后,屏幕显示Connected.

此时这台linux已可以上网浏览了。

7、 IP伪装

为了使局域网中的其他机器能通过Linux服务器共享上网,至少须执行下面的命令:

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

完成后,在192.168.0.0网段(网关为192.168.0.1)的PC机就可透过Linux上网了!

8、 开机自启动

为了使Linux服务器能够自动拨号,执行下面步骤。

1)chkconfig ——add adsl

2)setup

3)选择system services

4)选中ADSL

5)OK退出

6)打开/etc/rc.d/rc.local,在该文件的末尾添上下面语句

  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 

说明:前面四句用于关闭ICMP,防止别人Ping.

9、至此,一切OK,一个简单的拨号建成了。重启机器后,发现linux的internet共享连接已经一切就绪了。这样就可以Linux服务器实现上网了。

【编辑推荐】

  1. 全面解析Linux集群技术的要点
  2. LifeKeeper又一款Linux服务器集群软件
  3. 讲解Linux服务器集群技术
  4. 详解保护Linux服务器七步骤
  5. 全面介绍Linux配置ntop
责任编辑:小霞 来源: 计世网
相关推荐

2013-11-06 09:18:09

思科OpenStack

2009-02-27 13:12:00

2011-01-18 09:12:47

Linux服务器集群系统

2010-10-13 10:23:34

低功耗服务器

2009-02-18 12:55:00

虚拟化刀片服务器XenDesktop3

2010-03-16 19:59:32

上网行为管理网桥深信服科技

2011-07-06 11:18:40

ADSL交换机

2009-12-16 14:45:35

Linux操作系统

2009-02-06 11:18:00

代理服务器SuperProxyADSL

2023-10-30 00:14:34

Agent提示工程LLM

2024-03-19 15:09:07

2023-11-06 10:07:22

模型人工智能数字

2009-07-22 10:25:37

2009-06-10 15:57:49

AndroidMIPS架构

2010-07-09 14:39:31

HART通讯协议

2009-05-06 16:54:05

firefoxseo浏览器

2023-05-05 14:11:12

区块链航空领域

2010-03-29 09:00:11

Linux企业服务器

2010-07-28 16:14:53

2009-08-06 11:27:23

VMware虚拟机NA
点赞
收藏

51CTO技术栈公众号