CentOS 7 以上系统上使用 ADSL 拨号上网时,几乎每隔两三分钟就会自动掉线,自动拨号连接一次上网,导致网络特别是ip地址非常的不稳定。

ADSL 拨号上网的过程,在安装拨号程序 pppoe-setup 后,执行命令 pppoe-stop / pppoe-start 拨号上网,

发现pppd连接不停的掉线,新开一个终端,一直在Ping,发现网络隔两三分钟左右就自动掉一次,然后自动重新连接,

pppoe-connect: PPPoE connection lost; attempting re-connection.

 

查看系统日志 /var/log/messages 日志,发现有如下内容,不断重复:

vim /var/log/messages


Apr  2 21:10:20 106 pppd[10191]: Exit.
Apr  2 21:10:20 106 pppoe-connect: PPPoE connection lost; attempting re-connection.
Apr  2 21:10:25 106 pppd[30084]: pppd 2.4.5 started by root, uid 0
Apr  2 21:10:25 106 pppd[30084]: Using interface ppp0
Apr  2 21:10:25 106 pppd[30084]: Connect: ppp0 <--> /dev/pts/0
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): new Generic device (driver: 'unknown' ifindex: 21)
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): exported as /org/freedesktop/NetworkManager/Devices/20
Apr  2 21:10:25 106 pppoe[30085]: PPP session is 14652 (0x393c)
Apr  2 21:10:25 106 pppd[30084]: CHAP authentication succeeded: Authentication success,Welcome!
Apr  2 21:10:25 106 pppd[30084]: CHAP authentication succeeded
Apr  2 21:10:25 106 pppd[30084]: local  IP address 27.158.124.120
Apr  2 21:10:25 106 pppd[30084]: remote IP address 27.158.124.1
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: starting connection 'ppp0'
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) scheduled...
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) started...
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) scheduled...
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) complete.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) starting...
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: prepare -> config (reason 'none') [40 50 0]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) successful.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) scheduled.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) complete.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) started...
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: config -> ip-config (reason 'none') [50 70 0]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Configure Commit) scheduled...
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) complete.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Commit) started...
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Commit) complete.
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Apr  2 21:10:25 106 NetworkManager[820]:   (ppp0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Apr  2 21:10:25 106 NetworkManager[820]: <info>  Policy set 'ppp0' (ppp0) as default for IPv4 routing and DNS.
Apr  2 21:10:25 106 NetworkManager[820]: <info>  (ppp0): Activation: successful, device activated.
Apr  2 21:10:25 106 nm-dispatcher: Dispatching action 'up' for ppp0
Apr  2 21:10:25 106 NetworkManager[820]: <info>  Setting system hostname to '120.124.158.27.broad.sm.fj.dynamic.163data.com.cn' (from address lookup)
Apr  2 21:10:25 106 nm-dispatcher: Dispatching action 'hostname'
Apr  2 21:10:25 106 systemd: Reloaded Squid caching proxy.
Apr  2 21:10:51 106 NetworkManager[820]: <info>  (eth1): Activation: Stage 4 of 5 (IPv6 Configure Timeout) scheduled...
Apr  2 21:10:51 106 NetworkManager[820]: <info>  (eth1): Activation: Stage 4 of 5 (IPv6 Configure Timeout) started...
Apr  2 21:10:51 106 NetworkManager[820]:   (eth1): device state change: ip-config -> failed (reason 'ip-config-unavailable') [70 120 5]
Apr  2 21:10:51 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_GLOBAL
Apr  2 21:10:51 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_SITE
Apr  2 21:10:51 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_GLOBAL
Apr  2 21:10:51 106 NetworkManager[820]: <info>  Disabling autoconnect for connection 'eth1'.
Apr  2 21:10:51 106 NetworkManager[820]: <warn>  (eth1): Activation: failed for connection 'eth1'
Apr  2 21:10:51 106 NetworkManager[820]: <info>  (eth1): Activation: Stage 4 of 5 (IPv6 Configure Timeout) complete.
Apr  2 21:10:51 106 NetworkManager[820]:   (eth1): device state change: failed -> disconnected (reason 'none') [120 30 0]
Apr  2 21:10:51 106 NetworkManager[820]:   (eth1): deactivating device (reason 'none') [0]
Apr  2 21:11:15 106 pppoe[30085]: Inactivity timeout... something wicked happened on session 14652
Apr  2 21:11:15 106 pppoe[30085]: Sent PADT
Apr  2 21:11:15 106 pppd[30084]: Modem hangup
Apr  2 21:11:15 106 pppd[30084]: Connect time 0.9 minutes.
Apr  2 21:11:15 106 pppd[30084]: Sent 606 bytes, received 958 bytes.
Apr  2 21:11:15 106 pppd[30084]: Connection terminated.
Apr  2 21:11:15 106 NetworkManager[820]:   (ppp0): device state change: activated -> unmanaged (reason 'removed') [100 10 36]
Apr  2 21:11:15 106 NetworkManager[820]:   (ppp0): deactivating device (reason 'removed') [36]
Apr  2 21:11:15 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_LOCAL
Apr  2 21:11:15 106 NetworkManager[820]: <info>  Setting system hostname to 'localhost.localdomain' (no default device)
Apr  2 21:11:15 106 dbus[747]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Apr  2 21:11:15 106 systemd: Starting Network Manager Script Dispatcher Service...
Apr  2 21:11:15 106 dbus[747]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr  2 21:11:15 106 systemd: Started Network Manager Script Dispatcher Service.
Apr  2 21:11:15 106 nm-dispatcher: Dispatching action 'hostname'
Apr  2 21:11:15 106 nm-dispatcher: Dispatching action 'down' for ppp0
Apr  2 21:11:15 106 systemd: Reloaded Squid caching proxy.

Apr  2 21:11:16 106 pppd[30084]: Exit.
Apr  2 21:11:16 106 pppoe-connect: PPPoE connection lost; attempting re-connection.
Apr  2 21:11:21 106 pppd[30250]: pppd 2.4.5 started by root, uid 0
Apr  2 21:11:21 106 pppd[30250]: Using interface ppp0
Apr  2 21:11:21 106 pppd[30250]: Connect: ppp0 <--> /dev/pts/0
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): new Generic device (driver: 'unknown' ifindex: 22)
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): exported as /org/freedesktop/NetworkManager/Devices/21
Apr  2 21:11:21 106 pppoe[30251]: PPP session is 5435 (0x153b)
Apr  2 21:11:21 106 pppd[30250]: CHAP authentication succeeded: Authentication success,Welcome!
Apr  2 21:11:21 106 pppd[30250]: CHAP authentication succeeded
Apr  2 21:11:21 106 pppd[30250]: local  IP address 120.35.203.123
Apr  2 21:11:21 106 pppd[30250]: remote IP address 120.35.203.1
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: starting connection 'ppp0'
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) scheduled...
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) started...
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) scheduled...
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 1 of 5 (Device Prepare) complete.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) starting...
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: prepare -> config (reason 'none') [40 50 0]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) successful.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) scheduled.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 2 of 5 (Device Configure) complete.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) started...
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: config -> ip-config (reason 'none') [50 70 0]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Configure Commit) scheduled...
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 3 of 5 (IP Configure Start) complete.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Commit) started...
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: Stage 5 of 5 (IPv4 Commit) complete.
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Apr  2 21:11:21 106 NetworkManager[820]:   (ppp0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Apr  2 21:11:21 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_GLOBAL
Apr  2 21:11:21 106 NetworkManager[820]: <info>  Policy set 'ppp0' (ppp0) as default for IPv4 routing and DNS.
Apr  2 21:11:21 106 NetworkManager[820]: <info>  (ppp0): Activation: successful, device activated.
Apr  2 21:11:21 106 nm-dispatcher: Dispatching action 'up' for ppp0
Apr  2 21:11:21 106 NetworkManager[820]: <info>  Setting system hostname to '123.203.35.120.broad.sm.fj.dynamic.163data.com.cn' (from address lookup)
Apr  2 21:11:21 106 systemd: Reloaded Squid caching proxy.
Apr  2 21:11:21 106 nm-dispatcher: Dispatching action 'hostname'
Apr  2 21:11:59 106 pppoe[30251]: Inactivity timeout... something wicked happened on session 5435
Apr  2 21:11:59 106 pppoe[30251]: Sent PADT
Apr  2 21:11:59 106 pppd[30250]: Modem hangup
Apr  2 21:11:59 106 pppd[30250]: Connect time 0.7 minutes.
Apr  2 21:11:59 106 pppd[30250]: Sent 537 bytes, received 813 bytes.
Apr  2 21:11:59 106 pppd[30250]: Connection terminated.
Apr  2 21:11:59 106 NetworkManager[820]:   (ppp0): device state change: activated -> unmanaged (reason 'removed') [100 10 36]
Apr  2 21:11:59 106 NetworkManager[820]:   (ppp0): deactivating device (reason 'removed') [36]
Apr  2 21:11:59 106 NetworkManager[820]: <info>  NetworkManager state is now CONNECTED_LOCAL
Apr  2 21:11:59 106 NetworkManager[820]: <info>  Setting system hostname to 'localhost.localdomain' (no default device)
Apr  2 21:11:59 106 dbus[747]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Apr  2 21:11:59 106 systemd: Starting Network Manager Script Dispatcher Service...
Apr  2 21:11:59 106 dbus[747]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr  2 21:11:59 106 systemd: Started Network Manager Script Dispatcher Service.
Apr  2 21:11:59 106 nm-dispatcher: Dispatching action 'hostname'
Apr  2 21:11:59 106 nm-dispatcher: Dispatching action 'down' for ppp0
Apr  2 21:11:59 106 systemd: Reloaded Squid caching proxy.
Apr  2 21:11:59 106 pppd[30250]: Exit.

Apr  2 21:11:59 106 pppoe-connect: PPPoE connection lost; attempting re-connection.
Apr  2 21:12:04 106 pppd[30414]: pppd 2.4.5 started by root, uid 0
Apr  2 21:12:04 106 pppd[30414]: Using interface ppp0
Apr  2 21:12:04 106 pppd[30414]: Connect: ppp0 <--> /dev/pts/0
Apr  2 21:12:04 106 NetworkManager[820]: <info>  (ppp0): new Generic device (driver: 'unknown' ifindex: 23)
Apr  2 21:12:04 106 NetworkManager[820]: <info>  (ppp0): exported as /org/freedesktop/NetworkManager/Devices/22
Apr  2 21:12:04 106 pppoe[30415]: PPP session is 6079 (0x17bf)
Apr  2 21:12:04 106 pppd[30414]: CHAP authentication succeeded: Authentication success,Welcome!
Apr  2 21:12:04 106 pppd[30414]: CHAP authentication succeeded
Apr  2 21:12:04 106 pppd[30414]: local  IP address 27.157.129.205
Apr  2 21:12:04 106 pppd[30414]: remote IP address 27.157.129.1

 

在网上搜了许多相关的问题,发现网上出现此问题的人也不在少数,要么修改 /etc/ppp/options 的内容,要么就是修改 /etc/ppp/pppoe-server-options 的内容

# cat /etc/ppp/options   
lock
# cat /etc/ppp/pppoe-server-options
# PPP options for the PPPoE server
# LIC: GPL
require-pap
login
lcp-echo-interval 10
lcp-echo-failure 2

我也在这两个文件上修改了许多次,浪费了挺多的时,网络掉线问题依旧,没有解决。

后来灵机一动,平常修改IP的设置之类的都在网卡上设置的,就试着在 vim /etc/sysconfig/network-scripts/ifcfg-ppp0  里面作了修改,

原文件如下:

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

USERCTL=no
BOOTPROTO=dialup
NAME=DSLppp0
DEVICE=ppp0
TYPE=xDSL
ONBOOT=yes
PIDFILE=/var/run/pppoe-adsl.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=10
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=10
DEFROUTE=yes
SYNCHRONOUS=no
ETH=eth1
PROVIDER=DSLppp0
USER=05989123456
PEERDNS=no
DEMAND=no

修改此原文的几个地方,如下:

PPPOE_TIMEOUT=100
LCP_FAILURE=300
LCP_INTERVAL=200
CONNECT_TIMEOUT=60

至此,问题解决!

之后,一直末出现每隔几分钟掉线的情况了,其实将上面四个配置的数值,适当修改得大些即可解决问题。

问题的原因是:

pppoe 拨号超时(PPPOE_TIMEOUT=10)、连接超时(CONNECT_TIMEOUT=10)、轮询重拨间隔(LCP_FAILURE=3、LCP_INTERVAL=20)等默认值太小了,导致pppoe拨号一有风吹草动的异常,都会引发自动重新拨号,即一开始我们遇到的每隔两三分钟会不间断的自动重拨。

 

上述问题,其实还有潜在的可能,例如提示里错误信息:

(eth1): device state change: ip-config -> failed (reason 'ip-config-unavailable')

表示设备网卡 eth1 状态接收拨号时有问题,不可用,导致网络不稳定

 

还有的可能是如下提示错误:

Apr  3 11:45:33 localhost pppd[2759]: LCP: timeout sending Config-Requests
Apr  3 11:45:33 localhost pppd[2759]: Connection terminated.
Apr  3 11:45:33 localhost pppd[2759]: Modem hangup
Apr  3 11:45:37 localhost pppoe[2760]: Timeout waiting for PADS packets
Apr  3 11:45:37 localhost pppd[2759]: Exit.
Apr  3 11:45:37 localhost systemd: Removed slice User Slice of root.
Apr  3 11:45:37 localhost systemd: Stopping User Slice of root.
Apr  3 11:52:41 localhost systemd: Created slice User Slice of root.
Apr  3 11:52:41 localhost systemd: Starting User Slice of root.
Apr  3 11:52:41 localhost systemd: Started Session 2 of user root.
Apr  3 11:52:41 localhost systemd-logind: New session 2 of user root.
Apr  3 11:52:41 localhost systemd: Starting Session 2 of user root.
Apr  3 11:53:00 localhost pppd[3107]: pppd 2.4.5 started by root, uid 0
Apr  3 11:53:00 localhost pppd[3107]: Using interface ppp0
Apr  3 11:53:00 localhost pppd[3107]: Connect: ppp0 <--> /dev/pts/1
Apr  3 11:53:00 localhost pppoe[3108]: PPP session is 18173 (0x46fd)
Apr  3 11:53:00 localhost pppd[3107]: CHAP authentication succeeded: Authentication success,Welcome!
Apr  3 11:53:00 localhost pppd[3107]: CHAP authentication succeeded
Apr  3 11:53:00 localhost pppd[3107]: local  IP address 27.150.163.241
Apr  3 11:53:00 localhost pppd[3107]: remote IP address 27.150.162.1

即第一行错误提示:LCP: timeout sending Config-Requests

LCP: timeout sending Config-Requests 说明是在发送拨号配置请求时超时,问题出现在电信运营商,需要联系电信解决。

 

最后,附正常拨号日志记录

1. 拨号连接,即使用 adsl-start 或 pppoe-start 命令:

Apr 26 13:1Array:54 cs pppd[53Array8]: pppd 2.4.2 started by root, uid 0

Apr 26 13:1Array:54 cs pppd[53Array8]: Using interface ppp0

Apr 26 13:1Array:54 cs pppd[53Array8]: Connect: ppp0 <--> /dev/pts/1

Apr 26 13:1Array:54 cs pppoe[5401]: PADS: Service-Name: ’

Apr 26 13:1Array:54 cs pppoe[5401]: PPP session is 11441

Apr 26 13:1Array:55 cs pppd[53Array8]: Remote message: Welcome to use Quidway ROUTER, Huawei Tech.^M^J

Apr 26 13:1Array:55 cs pppd[53Array8]: PAP authentication succeeded

Apr 26 13:1Array:55 cs pppd[53Array8]: Couldn’t set pass-filter in kernel: Invalid argument

Apr 26 13:1Array:55 cs pppd[53Array8]: Cannot determine ethernet address for proxy ARP

Apr 26 13:1Array:55 cs pppd[53Array8]: local  IP address 213.61.33.28

Apr 26 13:1Array:55 cs pppd[53Array8]: remote IP address 213.61.33.1

上面是pppoe正常拨号并建立连接的信息,一般ADSL拨号成功都是这样,并可以看到获得IP地址:213.61.33.28;此时会有一个ppp0的设备出现,可通过ifconfig看到。

 

2. 正常挂断,即使用 adsl-stop 或 pppoe-stop 命令:

Apr 25 21:46:1Array cs adsl-stop: Killing pppd

Apr 25 21:46:1Array cs pppd[32741]: Terminating on signal 15.

Apr 25 21:46:1Array cs adsl-stop: Killing adsl-connect

Apr 25 21:46:1Array cs pppd[32741]: Connection terminated.

Apr 25 21:46:1Array cs pppd[32741]: Connect time 106.4 minutes.

Apr 25 21:46:1Array cs pppd[32741]: Sent 445650 bytes, received 2ArrayArray213 bytes.

Apr 25 21:46:1Array cs pppoe[32744]: read (asyncReadFromPPP): Session 10686: Input/output error

Apr 25 21:46:1Array cs pppoe[32744]: Sent PADT

Apr 25 21:46:1Array cs pppd[32741]: Exit. 

 

 

参考推荐

Linux ADSL定时掉线

ADSL拨号异常

debian ADSL cannot dial-upproblem