了解dom fedora pppoe程序
更新記錄
item | note |
---|---|
20160831 | 第一版 |
20160902 | 新增: pppoe-start 流程圖 |
新增: pppoe-connect 流程圖 |
目錄
dom fedora
ldvr_pppoe_client
- 每2分鐘檢查一次
- 若設定值為連線
- 則確定是否有pppoe介面(即ifconfig | grep ppp0)
- 若無則重新撥號(即pppoe_stop再pppoe_start)
- pppoe_start: 即system(pppoe-start)
- pppoe_stop: 即system(pppoe-stop)
pppoe-start script
- /var/run/pppoe-adsl.pid(儲存pppoe-connect的pid)
- /var/run/pppoe-adsl.pid.pppd(儲存pppd的pid)
- /var/run/pppoe-adsl.pid.pppoe(儲存pppoe的pid)
1.確認/var/run/pppoe-adsl.pid (此為pppoe-connect的pid)
確認pid是否存在(kill -0 $pid)
若存在則離開表示,表示正在pppoe-connect2.若無則
產生/var/run/pppoe-adsl.pid.start (此為pppoe-start的pid)3.開始撥接
/usr/sbin/pppoe-connect4.若CONNECT_TIMEOUT=0,則離開
則表示一直執行pppo-connect不會有timeoutn5.等得timeout (CONNECT_TIMEOUT=60)
每次等6S (CONNECT_POLL=6),使用pppoe-status來確認是否已連線6.產生timeout
此時kill pppoe-connect
清除/var/run/pppoe-adsl.pid.pppd, /var/run/pppoe-adsl.pid.pppoe, /var/run/pppoe-adsl.pid.start
設定回原本的gateway
pppoe-connect script
Shell script to connect to an PPPoE provider using PPPoE
1
2
3
4# Usage: pppoe-connect [config_file]
# pppoe-connect interface user [config_file]
# Second form overrides USER and ETH from config file.
# If config_file is omitted, defaults to /etc/ppp/pppoe.conf開始建立pppoe連線之前,若DEFROUTE != no,,則會先移除目前的gateway
1
2
3
4
5
6
7if [ "${DEFROUTE}" != "no" ] ; then
DEFRT=$(ip route list match 0/0)
[ -n "${DEFRT}" ] && echo "$DEFRT" > /etc/default-routes
echo "$DEFRT" | while read spec; do
$IP route del $spec;
done
fi移除之後狀態如下
1
2
3
4
5
6[root@localhost tt]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.22.0 0.0.0.0 255.255.255.0 U 100 0 0 enp1s0
[root@localhost tt]# cat /etc/default-routes
default via 192.168.22.1 dev enp1s0 proto static metric 100pppd call
1
/usr/sbin/pppd pty /usr/sbin/pppoe -p /var/run/pppoe-adsl.pid.pppoe -I enp1s0 -T 80 -U -m 1412 ipparam ppp0 linkname ppp0 noipdefault noauth default-asyncmap defaultroute hide-password nodetach usepeerdns mtu 1492 mru 1492 noaccomp nodeflate nopcomp novj novjccomp user sz3lmc48@163.gd lcp-echo-interval 20 lcp-echo-failure 3
pppd_cmd
1
PPPOE_CMD:/usr/sbin/pppoe -p /var/run/pppoe-adsl.pid.pppoe -I enp1s0 -T 80 -U -m 1412
pppoe_stop
1-確認/var/run/pppoe-adsl.pid.pppd是否存在
2-若有則kill pppoe pid1
2
3
4
5CONFIG:/etc/sysconfig/network-scripts/ifcfg-ppp0
PPPOE_PIDFILE:/var/run/pppoe-adsl.pid.pppoe
PPPD_PIDFILE:/var/run/pppoe-adsl.pid.pppd
STARTPID:/var/run/pppoe-adsl.pid.start
DEMAND:no
[root@localhost tt]# cat /etc/sysconfig/network-scripts/ifcfg-ppp0
PIDFILE=/var/run/pppoe-adsl.pid1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22USERCTL=yes
BOOTPROTO=dialup
NAME=DSLppp0
DEVICE=ppp0
TYPE=xDSL
ONBOOT=no
PIDFILE=/var/run/pppoe-adsl.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=enp1s0
PROVIDER=DSLppp0
USER=sz3lmc48@163.gd
PEERDNS=yes
DEMAND=noCONNECT_POLL=6
設定pppoe-start時, 每6秒做一次pppoe-status,確認是否撥接成功(即interfac came up)CONNECT_TIMEOUT=60
設定pppoe-start時,預計連線判斷時間(即等待60S,來確認連線建立程序)若pppoe-start失敗
- kill $CONNECT_PID
- clean up PIDFILE
/var/run/pppoe-adsl.pid
/var/run/pppoe-adsl.pid.pppd
/var/run/pppoe-adsl.pid.pppoe
/var/run/pppoe-adsl.pid.start
pppoe-status
- Shell script to report on status of PPPoE connection
1
2# Usage: pppoe-status [config_file]
# If config_file is omitted, defaults to /etc/ppp/pppoe.conf
process 程序
pppoe-connect , pppd, pppoe
pppoe-connect先執行
再執行 pppd pty pppoe -p xx xx
由pppd去帶起pppoe1
2
3
4
5
6
7
8
9
10
11
12
13root 25411 16537 0 15:25 pts/1 00:00:00 /bin/bash ./pppoe-connect
root 25435 2 0 15:25 ? 00:00:00 [kworker/u8:0]
root 25546 25411 0 15:25 ? 00:00:00 /usr/sbin/pppd pty /usr/sbin/pppoe -p /var/run/pppoe-adsl.pid.pppoe -I enp1s0 -T 80 -U -m 1412 ipparam p
root 25547 25546 0 15:25 ? 00:00:00 /usr/sbin/pppoe -p /var/run/pppoe-adsl.pid.pppoe -I enp1s0 -T 80 -U -m 1412
root 25554 18056 0 15:25 pts/2 00:00:00 ps -ef
[root@localhost tt]# cat /var/run/pppoe-adsl.pid.pppoe
25547
[root@localhost tt]# cat /var/run/pppoe-adsl.pid
25411
[root@localhost tt]# cat /var/run/pppoe-adsl.pid.ppp
pppoe-adsl.pid.pppd pppoe-adsl.pid.pppoe
[root@localhost tt]# cat /var/run/pppoe-adsl.pid.pppd
25546/var/run/pppoe-adsl.pid
為pppoe-connect的pid/var/run/pppoe-adsl.pid.pppd
為pppd的pid/var/run/pppoe-adsl.pid.pppoe
為pppoe的pid
pppoe 相關檔案
pppd
- pppd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18[root@localhost tt]# pppd -v
pppd: unrecognized option '-v'
pppd version 2.4.7
Usage: pppd [ options ], where options are:
<device> Communicate over the named device
<speed> Set the baud rate to <speed>
<loc>:<rem> Set the local and/or remote interface IP
addresses. Either one may be omitted.
asyncmap <n> Set the desired async map to hex <n>
auth Require authentication from peer
connect <p> Invoke shell command <p> to set up the serial line
crtscts Use hardware RTS/CTS flow control
defaultroute Add default route through interface
file <f> Take options from file <f>
modem Use modem control lines
mru <n> Set MRU value to <n> for negotiation
See pppd(8) for more options.
[root@localhost tt]#
ppp script
- ppp-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15[root@localhost tt]# ls -l /usr/sbin/ppp*
-rwxr-xr-x 1 root root 394464 Feb 5 2016 /usr/sbin/pppd
-rwxr-xr-x 1 root root 54376 Feb 5 2016 /usr/sbin/pppdump
-rwxr-xr-x 1 root root 40456 Feb 5 2016 /usr/sbin/pppoe
-rwxr-xr-x 1 root root 11053 Feb 5 2016 /usr/sbin/pppoe-connect
-rwxr-xr-x 1 root root 24336 Feb 5 2016 /usr/sbin/pppoe-discovery
-rwxr-xr-x 1 root root 36424 Feb 5 2016 /usr/sbin/pppoe-relay
-rwxr-xr-x 1 root root 57440 Feb 5 2016 /usr/sbin/pppoe-server
-rwxr-xr-x 1 root root 12867 Feb 5 2016 /usr/sbin/pppoe-setup
-rwxr-xr-x 1 root root 23880 Feb 5 2016 /usr/sbin/pppoe-sniff
-rwxr-xr-x 1 root root 6456 Feb 5 2016 /usr/sbin/pppoe-start
-rwxr-xr-x 1 root root 2680 Feb 5 2016 /usr/sbin/pppoe-status
-rwxr-xr-x 1 root root 3601 Feb 5 2016 /usr/sbin/pppoe-stop
-rwxr-xr-x 1 root root 15696 Feb 5 2016 /usr/sbin/pppstats
-rwxr-xr-x 1 root root 23776 Feb 5 2016 /usr/sbin/ppp-watch
檔案架構
/etc/ppp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20[root@localhost tt]# cd /etc/ppp
[root@localhost ppp]# tree
.
├── chap-secrets
├── eaptls-client
├── eaptls-server
├── firewall-masq
├── firewall-standalone
├── ip-down
├── ip-down.ipv6to4
├── ip-up
├── ip-up.ipv6to4
├── ipv6-down
├── ipv6-up
├── options
├── options.pptp
├── pap-secrets
├── peers
│ └── wvdial
└── pppoe-server-options/etc/sysconfig/network-scripts/
1
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[root@localhost network-scripts]# tree
├── ifcfg-enp4s0
├── ifcfg-enp7s2
├── ifcfg-lo
├── ifcfg-ppp0
├── ifcfg-Wired_connection_1
├── ifdown -> ../../../usr/sbin/ifdown
├── ifdown-bnep
├── ifdown-eth
├── ifdown-ippp
├── ifdown-ipv6
├── ifdown-isdn -> ifdown-ippp
├── ifdown-post
├── ifdown-ppp
├── ifdown-routes
├── ifdown-sit
├── ifdown-Team
├── ifdown-TeamPort
├── ifdown-tunnel
├── ifup -> ../../../usr/sbin/ifup
├── ifup-aliases
├── ifup-bnep
├── ifup-eth
├── ifup-ippp
├── ifup-ipv6
├── ifup-isdn -> ifup-ippp
├── ifup-plip
├── ifup-plusb
├── ifup-post
├── ifup-ppp
├── ifup-routes
├── ifup-sit
├── ifup-Team
├── ifup-TeamPort
├── ifup-tunnel
├── ifup-wireless
├── init.ipv6-global
├── network-functions
└── network-functions-ipv6