ip-up脚本参数
阅读原文时间:2023年07月15日阅读:1

pppoe连接建立后,系统自动调用/etc/ppp/ip-up脚本。

_其参数如下面文件所示,第4个参数是系统获得的动态ip。
#!/bin/bash

# Script which handles the routing issues as necessary for pppd
# Only the link to Newman requires this handling.

# When the ppp link comes up, this script is called with the following
# parameters
# $1 the interface name used by pppd (e.g. ppp3)
# $2 the tty device name
# $3 the tty device speed
# $4 the local IP address for the interface
# $5 the remote IP address
# $6 the parameter specified by the 'ipparam' option to pppd
#_

-----------------------------

man pppd

参考pppd的man-page里的SCRIPTS一节,摘录如下:
SCRIPTS
Pppd invokes scripts at various stages in its processing which can be
used to perform site-specific ancillary processing. These scripts are
usually shell scripts, but could be executable code files instead.
Pppd does not wait for the scripts to finish. The scripts are exe-
cuted as root (with the real and effective user-id set to 0), so that
they can do things such as update routing tables or run privileged
daemons. Be careful that the contents of these scripts do not compro-
mise your system’s security. Pppd runs the scripts with standard
input, output and error redirected to /dev/null, and with an environ-
ment that is empty except for some environment variables that give
information about the link. The environment variables that pppd sets
are:

DEVICE The name of the serial tty device being used.

IFNAME The name of the network interface being used.

IPLOCAL
The IP address for the local end of the link. This is only set
when IPCP has come up.

IPREMOTE
The IP address for the remote end of the link. This is only
set when IPCP has come up.

PEERNAME
The authenticated name of the peer. This is only set if the
peer authenticates itself.

SPEED The baud rate of the tty device.

ORIG_UID
The real user-id of the user who invoked pppd.

PPPLOGNAME
The username of the real user-id that invoked pppd. This is
always set.

For the ip-down and auth-down scripts, pppd also sets the following
variables giving statistics for the connection:

CONNECT_TIME
The number of seconds from when the PPP negotiation started
until the connection was terminated.

BYTES_SENT
The number of bytes sent (at the level of the serial port) dur-
ing the connection.

BYTES_RCVD
The number of bytes received (at the level of the serial port)
during the connection.

LINKNAME
The logical name of the link, set with the linkname option.

DNS1 If the peer supplies DNS server addresses, this variable is set
to the first DNS server address supplied.

DNS2 If the peer supplies DNS server addresses, this variable is set
to the second DNS server address supplied.

Pppd invokes the following scripts, if they exist. It is not an error
if they don’t exist.