ifup (激活网络接口,使其可用于传输和接收数据)

瑞兹 发表于 2021-01-28 09:06
浏览次数:
在手机上阅读

在某些类似Unix的操作系统上,ifup会激活网络接口,使其可用于传输和接收数据。

查看英文版

目录

1 ifup 运行系统环境

2 ifup 语法

3 ifup 例子

ifup 运行系统环境

Unix&Linux

ifup 语法

ifup [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
     [--allow CLASS] -a|IFACE...
ifup -h|--help
ifup -V|--version
ifdown [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
       [--allow CLASS] -a|IFACE...
ifquery [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
        [--allow CLASS] -a|IFACE...
ifquery -l|--list [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
        [--allow CLASS] -a|IFACE... 

技术说明

所述的ifupifdown你命令可以被用于配置网络接口基于所述文件的接口定义的/ etc /network/interfaces

ifquery命令用于解析接口的配置数据。

选件

-a,--all

如果提供给ifup,则影响标记为auto的所有接口。按照在/ etc / network / interfaces中定义的顺序启动接口。与--allow结合使用,将改为作用于指定类的所有接口。如果给ifdown,则影响所有定义的接口。按状态文件在状态文件中当前列出的顺序关闭接口。仅关闭/ etc / network / interfaces中定义的接口。

--force

强制配置或取消配置接口。

-h,--help

显示选项摘要。

--allow =CLASS

仅允许对/ etc / network / interfaces中allow-CLASS行中列出的接口进行操作。

-i FILE,-- interfaces = FILE

从FILE而不是/ etc / network / interfaces读取接口定义。

-X PATTERN,-- exclude =PATTERN

从接口列表中排除要由PATTERN操作的接口。PATTERN使用通常的shell glob语法。如果不使用外壳通配符,则它必须与确切的接口名称匹配。可以多次指定此选项,从而导致排除多个模式。

-o OPTION = VALUE

OPTION设置为VALUE,就像在/ etc / network / interfaces中一样。

-n--no-ACT

不要配置任何接口或运行任何“上”或“下”命令。

--no-mappings

不要运行任何映射。有关映射功能的更多信息,请参见接口

--no-scripts

不要在/etc/network/if-*.d/下运行任何脚本

-V,-- version

显示版权和版本信息。

-v,--verbose

在执行命令时显示命令。

-l--list

对于ifquery,列出与指定类匹配的所有接口。如果未指定任何类,则打印列为auto的所有接口。

档案

/ etc / network / interfaces

网络接口的定义。

/run/network/ ifstate

网络接口的当前状态。

已知局限性

该程序会记录网络接口是打开还是关闭。在特殊情况下,这些记录可能与接口的实际状态不一致。例如,使用ifup调出并随后使用ifconfig取消配置的接口仍将记录为up。要解决此问题,可以使用--force选项强制ifupifdown运行配置或取消配置命令,尽管它认为接口的当前状态是什么。

文件/ run / network / ifstate必须是可写的,ifupifdown才能正常工作。如果该位置不可写(例如,由于根 文件系统以只读方式安装,以进行系统恢复),则应将/ run / network / ifstate设为指向可写位置的符号链接。如果无法做到这一点,则可以使用--force选项运行配置或取消配置命令,而无需更新文件。

需要注意的是该程序没有自动运行:ifup的本身并不能带来了出现作为的结果界面硬件被安装和ifdown你本身并不能打倒那个消失硬件的结果中移除接口。要自动配置网络接口,您需要安装其他软件包,例如udevifplugd

ifup [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
     [--allow CLASS] -a|IFACE...
ifup -h|--help
ifup -V|--version
ifdown [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
       [--allow CLASS] -a|IFACE...
ifquery [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
        [--allow CLASS] -a|IFACE...
ifquery -l|--list [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE]
        [--allow CLASS] -a|IFACE... 

Technical Description

The ifup and ifdown commands may be used to configure network interfaces based on interface definitions in the file /etc/network/interfaces.

The ifquery command is used to parse interface configuration data.

Options

-a, --all

If given to ifup, affect all interfaces marked auto. Interfaces are brought up in the order in which they are defined in /etc/network/interfaces. Combined with --allow, acts on all interfaces of a specified class instead. If given to ifdown, affect all defined interfaces. Interfaces are brought down in the order in which they are currently listed in the state file. Only interfaces defined in /etc/network/interfaces will be brought down.

--force

Force configuration or deconfiguration of the interface.

-h, --help

Show summary of options.

--allow=CLASS

Only allow interfaces listed in an allow-CLASS line in /etc/network/interfaces to be acted upon.

-i FILE--interfaces=FILE

Read interface definitions from FILE instead of from /etc/network/interfaces.

-X PATTERN--exclude=PATTERN

Exclude interfaces from the list of interfaces to operate on by the PATTERNPATTERN uses a usual shell glob syntax. If shell wildcards are not used, it must match the exact interface name. This option may be specified multiple times resulting in more than one pattern being excluded.

-o OPTION=VALUE

Set OPTION to VALUE as though it were in /etc/network/interfaces.

-n--no-act

Don't configure any interfaces or run any "up" or "down" commands.

--no-mappings

Don't run any mappings. See interfaces for more information about the mapping feature.

--no-scripts

Don't run any scripts under /etc/network/if-*.d/

-V--version

Show Copyright and version information.

-v, --verbose

Show commands as they are executed.

-l--list

For ifquery, list all the interfaces which match the specified class. If no class specified, prints all the interfaces listed as auto.

Files

/etc/network/interfaces

definitions of network interfaces.

/run/network/ifstate

current state of network interfaces.

Known Limitations

The program keeps records of whether network interfaces are up or down. Under exceptional circumstances these records can become inconsistent with the real states of the interfaces. For example, an interface that was brought up using ifup and later deconfigured using ifconfig will still be recorded as up. To fix this you can use the --force option to force ifup or ifdown to run configuration or deconfiguration commands despite what it considers the current state of the interface to be.

The file /run/network/ifstate must be writable for ifup or ifdown to work properly. If that location is not writable (for example, because the root filesystem is mounted read-only for system recovery) then /run/network/ifstate should be made a symbolic link to a writable location. If that is not possible then you can use the --force option to run configuration or deconfiguration commands without updating the file.

Note that the program does not run automatically: ifup alone does not bring up interfaces that appear as a result of hardware being installed and ifdown alone does not bring down interfaces that disappear as a result of hardware being removed. To automate the configuration of network interfaces you need to install other packages such as udev or ifplugd.

查看英文版

查看中文版

ifup 例子

ifup -a

/ etc / network / interfaces中调出所有用auto定义的接口

ifup eth0

调出接口eth0

ifup eth0=home

将接口eth0设为逻辑接口home

ifdown -a

断开当前所有的接口。

ifquery -l

打印用auto关键字指定的所有接口的名称。

ifquery -l --allow=hotplug

打印用allow-hotplug关键字指定的所有接口的名称。

ifquery eth0

显示在ifupdown配置中指定的接口选项。每个键值对都使用“ ”作为分隔符打印在单独的行上。

ifup -a

Bring up all the interfaces defined with auto in /etc/network/interfaces

ifup eth0

Bring up interface eth0

ifup eth0=home

Bring up interface eth0 as logical interface home

ifdown -a

Bring down all interfaces that are currently up.

ifquery -l

Print names of all interfaces specified with the auto keyword.

ifquery -l --allow=hotplug

Print names of all interfaces specified with the allow-hotplug keyword.

ifquery eth0

Display the interface options as specified in the ifupdown configuration. Each key-value pair is printed out on individual line using ": " as separator.

查看英文版

查看中文版

其他命令行

info | isalist | iostat | iwconfig | id | insmod |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条