0. 确认本机 linux 发行版以及系统版本1cat /pro/version

如输出1Linux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16:44:24 UTC 2018

可看到是 Red Hat 4.8.5-28,确认是红帽系统后,我们才能用以下方法拨号上网

1. 检查自己的机器是否安装了rp-pppoe1rpm -qa rp-pppoe

如出现类似以下信息,rp-pppoe-3.11-7.el7.x86_64则证明已经预安装了。否则需要自行安装1pm -ivh rp-pppoe-3.8-5.fc10.i386.rpm

接下来开始拨号上网

2. 设置拨号参数 - pppoe-setup

终端执行以下命令后,会出现一系列需要配置的内容

注意:配置拨号只需要在最开始配置一次即可1pppoe-setup

a. 配置 DSL - 回车默认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:

如果要配置当前的DSL配置,请输入设备

(默认为ppp0),如果要创建一个新的,请输入’n’:

默认则可

b. LOGIN NAME - 输入宽带账号Enter your Login Name (default root): 200000123456

即输入当前的宽带帐号

c. INTERFACE - 输入连接的以太网接口名称 - 默认是 eth0,回车即可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.

输入连接到PPPoE调制解调器的以太网接口

对于Solaris,这可能类似于/ dev / hme0。

对于Linux,它将是ethX,其中“ X”是数字。

(默认eth0):

d.是否自动切断网络连接 - 默认是no,回车即可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):

现在系统要求询问你是否希望在没有联网的情况下,系统是否在空闲一段时间后,自动切断同网络的连接。我不喜欢这样,我希望在不用的时候,自己手动断掉连接。于是选择默认值,直接输入回车。

e.DNS - 设置DNS参数 - 输入 serverPlease 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:

配置DNS,此处输入server来自动获取DNS

f. PASSWORD - 输入宽带账号密码Please enter your Password:123456Please re-enter your Password:123456

g. USERCTRL - 是否允许普通用户开启或关闭PPPoE拨号,默认是允许,回车即可Please enter ‘yes’ (three letters, lower-case.) if you want to allow

normal user to start or stop DSL connection (default yes):

h. FIREWALLING - 防火墙选择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 workstation2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway

for a LAN

0 为不开启任何防火墙策略,1 为适用于基本的独立网络冲浪工作站

,2适用于充当局域网Internet网关的机器。自己选择一个,然后输入对应的数字即可

i. 开机启动配置,此处输入yes开机自动启动PPPoE拨号Do you want to start this connection at boot time?Please enter no or yes (default no):yes

j. 配置确认,没配错的话输入 y 保存配置1

2

3

4

5

6

7Ethernet Interface: eth0

User name: 02519885455

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)?

配置默认保存在 /etc/sysconfig/network-scripts/ifcfg-ppp0

PPPoe 拨号日志在 /var/log/messages 中,可以通过 tail -f /var/log/messages 查看 PPPoe 最新拨号日志内容

3. 拨号上网1

2

3

4

5

6

7

8# 拨号

pppoe-start

# 停止拨号

pppoe-stop

# 动态换IP

pppoe-stop && pppoe-start

# 拨号连接状态

pppoe-status

4. 脚本自动拨号

大概思路是,通过 ssh 登录上服务器,然后执行拨号命令,再返回当前的 ip

这里远程登陆服务器用的是 paramiko 这个库,比较好用还有 pexpect1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48# -*- coding: utf-8 -*-

# @Time : 2020/12/23 下午7:09

# @Author : wu

"""

pip install paramiko

"""

import paramiko

import time

import fire

def ssh_connect(host, port, user, passwd, **kwargs):

"""

获取 ssh 客户端

"""

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect(host, port, user, passwd, **kwargs)

return ssh

def get_ip(ssh: paramiko.SSHClient) -> str:

"""

改变 ip 并返回 ip

"""

ssh.exec_command("pppoe-stop && pppoe-start")

ip = ''

while not ip:

# 拨完号有可能暂时没那么快获取到 ip

time.sleep(0.5)

stdin, stdout, stderr = ssh.exec_command("ifconfig ppp0 | grep inet | awk '{print $2}'")

ip = stdout.read().decode('utf-8').strip()

print('未获取到 ip')

# 如果是搭配 squid 使用,可能每次拨完号后都要重新开放指定端口

ssh.exec_command("iptables -I INPUT -p tcp --dport 3128 -j ACCEPT")

return ip

def run():

ssh = ssh_connect('nanjingdx3.f3322.net', 20094, 'root', 'pawdd')

ip = get_ip(ssh)

print(ip)

ssh.close()

if __name__ == '__main__':

fire.Fire(run)

在此仅仅是提供了个思路,具体更高级的用法还可以看 paramiko

linux pppoe 拨号日志,PPPoe宽带拨号相关推荐

  1. newifi路由器 php,newifi新路由如何设置宽带拨号上网PPPoE

    newifi新路由怎么设置宽带拨号上网PPPoE?新买回来的newifi新路由并不会自动上网,而是需要手动设置上网帐号,由于此路由器的操作方式与平时的大不相同,下面分享具体教程 新买回来的newifi ...

  2. linux抓包pppoe,pppoe抓包流程和拨号流程

    pppoe拨号流程 PPPoE(Point to Point Protocol over Ethernet,基于以太网的点对点协议)的工作流程包含发现(Discovery)和会话(Session)两个 ...

  3. 【windows10】使用宽带拨号即PPPoE拨号上网

    [windows10]使用宽带拨号即PPPoE拨号上网 1.背景 2.宽带拨号 1.背景 在接入互联网实现上网时,我目前使用的是PPPoE拨号上网. PPPoE(Point-to-Point Prot ...

  4. linux下面系统要 pppoe拨号上网,Linux系统下PPPOE拨号共享上网方法是什么?

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

  5. 如何在路由器上设置PPPoE(ADSL虚拟拨号)上网,即(宽带拨号)?

    如何在路由器上设置PPPoE(ADSL虚拟拨号)上网,即(宽带拨号)? 参考链接: 1.https://service.tp-link.com.cn/detail_article_341.html 2 ...

  6. pppoe远程计算机错误,PPPoE宽带拨号连接常见错误代码是什么意思

    原标题:"PPPoE宽带拨号连接常见错误代码的解决办法 错误769的处理方法"的相关路由器设置教程资料分享.- 来源:191路由网. 当我们家的网络出现问题时,网络管理员一般会问你 ...

  7. 联通小区宽带拨号上网指南(Windows和Linux)

    Windows下: 据说联通小区宽带拨号上网是光缆支撑的网络,通过网线上网的,为了方便管理网络连接,写了两个bat,便于管理网络: 拨号上网.bat: netsh interface set inte ...

  8. 一个账号多路由器拨号失败服务器无响应,PPPoE拨号失败 PPPoE拨号失败服务器无响应怎么办?...

    路由器一般有三种上网方式:1.宽带拨号上网:2.自动获得IP地址:3固定(静态)IP地址,路由器PPPoE拨号失败或者PPPoE拨号失败服务器无响应怎么办? 路由器上网方式 (1)检查WAN口.网线. ...

  9. RouterOS 设置PPPOE Server让用户通过拨号才能上网 教程(超详细)

    根据PPPOE Server让用户通过拨号才能上网拓扑图对RouterOS做如下设置. 大家能看这篇文章,证明大家网络技术水平已经超越入门级,为了节省读者阅读时间,这里就不讲基础性的知识,比如:固定I ...

最新文章

  1. [01]EXTJS4.0的概述和HELLOWORD程序
  2. Python 画樱花(动态画+飘落效果+暗色效)
  3. 惠普HP unix命令大全
  4. 德力西电气签约永洪科技,数字化赋能电气制造新征程
  5. SpringSecurity案例之认证服务security配置
  6. Linux中ifcfg-eth0配置参数解释
  7. Java 8:功能接口示例
  8. MySQL中count(*)用法
  9. php怎样创建csv文件,如何使用PHP创建CSV文件?(代码示例)
  10. 多重响应交叉表点不动确定_风靡全球的尼克巨星登陆杭城!还有19.9元美食、多重惊喜好礼……嗨翻12月!...
  11. 网络设备流量分析——ElastiFlow容器化部署与应用
  12. SpringBoot与缓存
  13. AD15复制相同模块布局
  14. Vue模板语法——插值
  15. linux的百度网盘客户端
  16. RuntimeError: Error compiling objects for extension 和nvcc fatal : Unsupported gpu architecture ‘c
  17. 总结:linux运维常用命令
  18. 高德地图标识大全_连地震都查得一清二楚!高德地图新功能体验
  19. Java全栈学习路线-拭去心尘
  20. adguard home上网慢_AdGuardHome最新版本DNS设置负载均衡设置讨论:哪种设置快

热门文章

  1. TOJ 5266: 三角形相似
  2. quartus下载的时候program/configure verify blank-check 这些选项的作用
  3. git bush如何上传文件
  4. 带你上手 AI 大赛
  5. C语言实现三子棋(五子棋可以改赢得函数即可)
  6. 南信大网络工程和计算机科学与技术,南信大最好就业的专业?
  7. 纳米结构中的磁斯格明子
  8. 第一章__翠竹深林附桃源,险峰洞中别洞天.
  9. python打开浏览器全屏_Python+Selenium自动化——浏览器启动自动全屏配置
  10. 玩转iPhone实用技巧