PCDN测试拨号方法:
环境:
系统:centos7系统
网卡配置:
enp5s0f0配置的有公网管理IP
enp5s0f1,用于拨号,网线接入未做任何配置
1、安装拨号软件
[root@centos7 ~]# yum -y install rp-pppoe
2、配置虚拟网卡
[root@centos7 ~]# ip a ##查看网卡信息
##配置虚拟网卡用来同时拨多个账号
[root@centos7 ~]# ip link add macvlan0 link enp5s0f1 type macvlan mode bridge
[root@centos7 ~]# ip link add macvlan1 link enp5s0f1 type macvlan mode bridge
[root@centos7 ~]# ip link add macvlan2 link enp5s0f1 type macvlan mode bridge
[root@centos7 ~]# ip link set macvlan2 up
[root@centos7 ~]# ip link set macvlan2 up
[root@centos7 ~]# ip link set macvlan2 up
3、配置拨号上网
[root@centos7 ~]# 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...
LOGIN NAME
Enter your Login Name (default root): test1 ###拨号账户
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):macvlan0 ##用哪个端口进行拨号,这个是配置的虚拟接口macvlan0,macvlan
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): ##若长时间连线,连线会自动中断(no表示
没有数据传输时也不中断)
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: 8.8.8.8 ##设置DNS
PASSWORD
Please enter your Password: ###输入拨号账户的密码
Please re-enter your Password: ##再次输入密码
USERCTRL
Please enter 'yes' (three letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): yes
##是否允许普通账户连接
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 setup; however, 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 ###配置防火墙,无特殊需求选0
Start this connection at boot time
Do you want to start this connection at boot time?
Please enter no or yes (default no):no ##是否开机自动拨号
** Summary of what you entered **
Ethernet Interface: macvlan0
User name: test1
Activate-on-demand: No
DNS: 8.8.8.8
Firewalling: NONE
User Control: yes
Accept these settings and adjust configuration files (y/n)? y ##确认信息
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.
4、添加路由,避免拨号掉线
[root@centos7 ~]# route -n
[root@centos7 ~]# route add -net 目的地址/掩码 gw 下一跳网关
或者
[root@centos7 ~]# ip route add *.*.*.0/24 via 下一跳网关 dev enp5s0f0
再次查看路由
[root@centos7 ~]# route -n
5、连接拨号
[root@centos7 ~]# ifup ppp0
6、查看拨号网卡配置
[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ppp0
USERCTL=yes
BOOTPROTO=dialup
NAME=DSLppp0
DEVICE=ppp0
TYPE=xDSL
ONBOOT=no
PIDFILE=/var/run/pppoe-adsl-ppp0.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
DEFROUTE=no
SYNCHRONOUS=no
ETH=macvlan0
PROVIDER=DSLppp0
USER=051307
PEERDNS=no
DEMAND=no
[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ppp1
USERCTL=yes
BOOTPROTO=dialup
NAME=DSLppp1
DEVICE=ppp1
TYPE=xDSL
ONBOOT=no
PIDFILE=/var/run/pppoe-adsl-ppp1.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
DEFROUTE=no
SYNCHRONOUS=no
ETH=macvlan1
PROVIDER=DSLppp1
USER=05130
PEERDNS=no
DEMAND=no
[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ppp2
USERCTL=yes
BOOTPROTO=dialup
NAME=DSLppp2
DEVICE=ppp2
TYPE=xDSL
ONBOOT=no
PIDFILE=/var/run/pppoe-adsl-ppp2.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
DEFROUTE=yes
SYNCHRONOUS=no
ETH=macvlan2
PROVIDER=DSLppp2
USER=0513036
PEERDNS=no
DEMAND=no
[root@centos7 ~]#