ip-up脚本参数

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.
 

转载于:https://www.cnblogs.com/renweihang/p/8036656.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Android系统中,我们可以使用以下脚本来配置IP地址: 1. 首先,我们需要在Android设备上打开终端或命令行界面,可以通过adb shell命令进入设备的shell环境。 2. 使用ifconfig或ip命令查看当前网络接口的配置信息,确定我们要配置的网络接口的名称,一般为wlan0或eth0。 3. 假设我们要将IP地址设置为192.168.1.100,子网掩码为255.255.255.0,使用的是静态IP地址。 a. 使用ifconfig eth0 down命令关闭网络接口。 b. 使用ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up命令设置IP地址和子网掩码,并打开网络接口。 c. 使用route add default gw 192.168.1.1 eth0命令设置默认网关,其中192.168.1.1是我们的路由器的IP地址。 d. 使用setprop net.dns1 8.8.8.8命令设置DNS服务器的IP地址,这里使用的是Google的公共DNS服务器。 4. 最后,可以使用ifconfig或ip命令再次确认已经成功配置了IP地址。 注意事项: - 需要具有root权限才能执行上述操作。 - 不同Android设备和ROM版本可能会略有差异,可以尝试在终端中输入help命令查看可用的命令和参数。 - 对于非专业人士,建议在更改网络配置之前备份现有的网络设置,以防需要还原之前的配置。 这样,我们就可以通过以上脚本在Android设备上成功配置IP地址。 ### 回答2: 在Android设备上配置IP地址需要使用adb命令行工具,并根据需要修改设备上的网络设置。以下是一个简单的脚本示例: 1. 在计算机上打开终端或命令行界面,确保ADB(Android Debug Bridge)已正确安装并且设备已连接到计算机。 2. 使用以下命令获取当前设备的网络接口列表: adb shell ifconfig 3. 根据需要选择一个网络接口,并使用以下命令配置IP地址: adb shell ifconfig <interface> <ip_address> netmask <netmask> 其中,<interface>代表所选择的网络接口(如eth0、wlan0等),<ip_address>为要配置的IP地址,<netmask>为子网掩码。 例如,要将eth0接口的IP地址设置为192.168.0.100,子网掩码为255.255.255.0,可以执行以下命令: adb shell ifconfig eth0 192.168.0.100 netmask 255.255.255.0 4. 验证IP地址是否已成功配置,可以再次运行ifconfig命令查看相关接口的网络配置信息。 请注意,执行这些命令需要root权限,否则可能无法成功修改网络配置。另外,修改网络配置可能会导致设备无法正常连接到网络,请谨慎操作。 ### 回答3: Android配置IP脚本可以通过以下步骤实现: 1. 打开设置菜单:使用Shell命令`am start -n com.android.settings/.Settings`打开Android设备的设置菜单。 2. 进入网络设置:使用模拟按键的Shell命令模拟物理按键的点击,通过`input keyevent`命令实现。例如,使用`input keyevent 20`模拟按下向下键进入网络设置。 3. 进入WLAN设置:在网络设置菜单中,使用模拟按键的Shell命令模拟物理按键的点击,通过`input keyevent`命令实现。例如,使用`input keyevent 20`模拟按下向下键进入WLAN设置。 4. 进入WLAN高级选项:在WLAN设置菜单中,使用模拟按键的Shell命令模拟物理按键的点击,通过`input keyevent`命令实现。例如,使用`input keyevent 20`模拟按下向下键进入WLAN高级选项。 5. 进入IP设置:在WLAN高级选项菜单中,使用模拟按键的Shell命令模拟物理按键的点击,通过`input keyevent`命令实现。例如,使用`input keyevent 20`模拟按下向下键进入IP设置。 6. 配置IP地址:使用Shell命令`settings put global dhcp_hostname your_hostname`设置IP地址。将`your_hostname`替换为你想设置的IP地址。 7. 保存配置并退出设置菜单:使用模拟按键的Shell命令模拟物理按键的点击,通过`input keyevent`命令实现。例如,使用`input keyevent 4`模拟按下返回键,返回WLAN高级选项菜单。重复多次类似的命令,直到返回到设置菜单。 8. 关闭设置菜单:使用Shell命令`input keyevent 4`模拟按下返回键关闭设置菜单。 以上是一个简单的Android配置IP脚本实现方式,但请注意,在实际使用时,应确保脚本命令正确,并根据具体设备的界面和菜单结构进行适配。同时,需要确保设备具有足够的权限执行这些脚本命令。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值