如何设置Linux服务器为PPP拨入服务器

如何设置Linux服务器为PPP拨入服务器,第1张

我按下面这个配置成功了,你可以试下:

一、安装的前提条件

1.确保安装了网卡并工作正常

使用命令

#ifconfig eth0

查看网卡状态,然后关闭ifdown eth0,注意一定要关闭ifdown eth0

2.在系统中不要设置默认路由(网关),让ADSL拨号后自动获得

如果已经设置了默认路由,使用以下方法删除:

在文件 /etc/sysconfig/network 中删除 GATEWAY= 这一行,然后以root执行:

#/etc/rc.d/init.d/network restart

3.已经安装了pppd软件包

如果存在文件 /usr/sbin/pppd,则说明已经安装了pppd

如果未安装,从RedHatLinux 6.2安装光盘上安装ppp-2.3.11-

4.i386.rpm这个软件包

二、安装PPPOE客户端软件

Linux下的PPPOE客户端软件比较多,而且大多使用GNU License,我们推荐使用rp-pppoe 这个软件包。从http://www.roaringpenguin.com/pppoe/这个网站上,不仅可以下载

RedHat 62平台下的rp-pppoe的二进制软件包,而且可以下载源代码软件包。

1.二进制软件包的安装:

A.下载二进制软件包

http://www.roaringpenguin.com/pppoe/rp-pppoe-3.2-1.i386.rpm

B.进行安装

以root执行:

#rpm -Uvh rp-pppoe-3.2-1.i386.rpm

2.从源代码进行安装:

从源代码进行安装同样适用于其它平台的Linux,但必须在Linux系统中安装gcc编译器。

A.下载源代码软件包

http://www.roaringpenguin.com/pppoe/rp-pppoe-3.2.tar.gz

B.解压缩

#tar xvfz rp-pppoe-3.2.tar.gz

#cd rp-pppoe-3.2

C.进行编译和安装

运行脚本

#./go

将自动进行编译和安装,最后,调用/usr/sbin/adsl-setup进行配置,具体解释见三。

三、配置PPPOE客户端软件

安装完软件包后,必须配置pppoe的配置文件/etc/ppp/pppoe.conf,从而让ADSL拨号时使用配置文件中的用户名、密码等参数。我们不必手工改动这个文件,可以使用adsl-setup这个工具进行配置:

#/usr/sbin/adsl-setup

当出现

>>>Enter your PPPoE user name :

输入ADSL帐号的用户名

当出现

>>>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 ,这是ADSL相连的网卡的名字

当出现

>>>Enter the demand value (default no):

输入 no

当出现

>>>Enter the DNS information here:

输入 server ,这表示使用ADSL拨号自动获得的DNS服务器IP地址

当出现

>>>Please enter your PPPoE password:

输入ADSL帐号的密码

当出现

>>>Choose a type of firewall (0-2):

输入 0 ,不使用防火墙

当出现

>>>Accept these settings and adjust configuration files (y/n)?

如果输入的信息正确,输入 y ,完成配置,否则,输入 n 重新输入。

四、启动PPPOE客户端软件

使用命令

/usr/sbin/adsl-start 启动PPPOE客户端软件,进行连接,如果成功,将出现

Connected

如果不成功,请检查网线、ADSL MODEM等物理设备,并查看 /var/log/messages中的信息

/usr/sbin/adsl-stop 关闭和ISP的连接

/usr/sbin/adsl-status 查看当前连接的状态

如果想在Linux系统启动时自动启动ADSL连接,输入以下命令

#chkconfig --add adsl

将在当前的运行级下加入ADSL的自启动脚本

五、测试

当连接成功后,使用命令

#ifconfig -a

在输出中应该含有关于 ppp0 的一堆信息,其中还绑定了 IP 地址,说明已经从拨号中获得了IP地址。

使用命令

#netstat -nr

查看路由表信息,这时的默认路由应该是上面获得的IP地址。

如果没有默认路由,我们可以手动增加:

#route add default gw 上面获得的IP地址

使用命令

#nslookup www.sina.com.cn

如果解析出新浪的IP,说明已经从拨号中正确获得了DNS服务器

最后,使用命令ping某个域名或IP,如果有响应,表示你已经大功告成了。

六、其它说明

1、RedHat Linux 7.1已经集成了rp-pppoe这个软件包,只不过版本有些低,如果你不在意版本高低,可以直接进行三后面的步骤。

2、以后要拔号上网时,只要:

ifdown eth0

ifup ppp0

/usr/sbin/adsl-start

不是用现成的rp-pppoe-3.10-8.el6.x86_64.rpm吗,下面是我以前在RHEL6里面的 *** 作步骤:

1) Download rp-pppoe-3.10-8.el6.x86_64.rpm

You can search it on http://rpm.pbone.net/, choose the one for RedHat EL 6.

2) Install rp-pppoe-3.10-8.el6.x86_64.rpm

[root]# rpm -Uvh rp-pppoe-3.10-8.el6.x86_64.rpm

warning: rp-pppoe-3.10-8.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 1d1e034b: NOKEY

Preparing...########################################### [100%]

1:rp-pppoe ########################################### [100%]

3) Setpup PPPoE

[root]# pppoe-setup

Welcome to the PPPoE client setup. First, I will run some checks on

your system to make sure the PPPoE client is installed properly...

The following DSL config was found on your system:

Device: Name:

ppp0 DSLppp0

Please enter the device if you want to configure the present DSL config

(default ppp0) or enter 'n' if you want to create a new one: #Press Enter to accept the default value

LOGIN NAME

Enter your Login Name: 075588888888@163.gd #Input your ADSL account provided by ISP and press Enter

INTERFACE

Enter the Ethernet interface connected to the PPPoE modem

For Solaris, this is likely to be something like /dev/hme0.

For Linux, it will be ethX, where 'X' is a number.

(default eth0): #Press Enter to accept the default value

Do you want the link to come up on demand, or stay up continuously?

If you want it to come up on demand, enter the idle time in seconds

after which the link should be dropped. If you want the link to

stay up permanently, enter 'no' (two letters, lower-case.)

NOTE: Demand-activated links do not interact well with dynamic IP

addresses. You may have some problems with demand-activated links.

Enter the demand value (default no): #Press Enter to accept the default value

DNS

Please enter the IP address of your ISP's primary DNS server.

If your ISP claims that 'the server will provide dynamic DNS addresses',

enter 'server' (all lower-case) here.

If you just press enter, I will assume you know what you are

doing and not modify your DNS setup.

Enter the DNS information here: server #Input 'server' and press Enter

PASSWORD

Please enter your Password: 123456 #Input your ADSL password provided by ISP

Please re-enter your Password: 123456 #Input your ADSL password provided by ISP

USERCTRL

Please enter 'yes' (three letters, lower-case.) if you want to allow

normal user to start or stop DSL connection (default yes): #Press Enter to accept the default value

FIREWALLING

Please choose the firewall rules to use. Note that these rules are

very basic. You are strongly encouraged to use a more sophisticated

firewall setuphowever, these will provide basic security. If you

are running any servers on your machine, you must choose 'NONE' and

set up firewalling yourself. Otherwise, the firewall rules will deny

access to all standard servers like Web, e-mail, ftp, etc. If you

are using SSH, the rules will block outgoing SSH connections which

allocate a privileged source port.

The firewall choices are:

0 - NONE: This script will not set any firewall rules. You are responsible

for ensuring the security of your machine. You are STRONGLY

recommended to use some kind of firewall rules.

1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation

2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway

for a LAN

Choose a type of firewall (0-2): 0 #Input '0' and press Enter

Start this connection at boot time

Do you want to start this connection at boot time?

Please enter no or yes (default no):yes #Input 'yes' and press Enter

** Summary of what you entered **

Ethernet Interface: eth0

User name: 075588888888@163.gd

Activate-on-demand: No

DNS addresses: Supplied by ISP's server

Firewalling:NONE

User Control: yes

Accept these settings and adjust configuration files (y/n)? y #Input 'y' and press Enter

Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0

Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets

(But first backing it up to /etc/ppp/chap-secrets.bak)

(But first backing it up to /etc/ppp/pap-secrets.bak)

Congratulations, it should be all set up!

Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'

to bring it down.

Type '/sbin/pppoe-status /etc/sysconfig/network-scripts/ifcfg-ppp0'

to see the link status.

[root]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:21:CC:C6:10:54

inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0

UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1

RX packets:13599 errors:0 dropped:0 overruns:0 frame:0

TX packets:11903 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:7355622 (7.0 MiB) TX bytes:1311797 (1.2 MiB)

Interrupt:20 Memory:f3900000-f3920000

loLink encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:12 errors:0 dropped:0 overruns:0 frame:0

TX packets:12 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:628 (628.0 b) TX bytes:628 (628.0 b)

ppp0 Link encap:Point-to-Point Protocol #The interface ppp0 created successfully

inet addr:119.137.75.6 P-t-P:119.137.72.1 Mask:255.255.255.255

UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1

RX packets:4 errors:0 dropped:0 overruns:0 frame:0

TX packets:3 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:3

RX bytes:404 (404.0 b) TX bytes:54 (54.0 b)

[root]# pppoe-status

ppppoe-status: Link is down -- could not find interface corresponding to

pppd pid 27651

[root]# ifup ppp0

[root]# pppoe-status

pppoe-status: Link is up and running on interface ppp0

332: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP>mtu 1492 qdisc pfifo_fast state UNKNOWN qlen 3

link/ppp

inet 119.137.75.6 peer 119.137.72.1/32 scope global ppp0

[root]# ping www.baidu.com

PING www.a.shifen.com (220.181.111.148) 56(84) bytes of data.

64 bytes from 220.181.111.148: icmp_seq=1 ttl=55 time=73.7 ms

64 bytes from 220.181.111.148: icmp_seq=2 ttl=55 time=74.0 ms

^C

--- www.a.shifen.com ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1902ms

rtt min/avg/max/mdev = 73.794/73.940/74.086/0.146 ms


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7420907.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存