文件名称:
ifconfig.md
所在目录:
Openharmony v1.0 / docs / docs-en / kernel
文件大小:
22.08 KB
下载地址:
文本预览:
# ifconfig
## Command Function
This command is used to query and set parameters of a NIC, such as the IP address, subnet mask, gateway, and MAC address, and enable or disable the NIC.
## Syntax
ifconfig
\[_-a_\]
<_interface_\> <_address_\> \[_netmask_\] \[_gateway _\]
\[_hw ether _\] \[_mtu_\]
\[_inet6 add _\]
\[_inet6 del _\]
\[_up|down_\]
## Parameter Description
**Table 1** Parameters
## Usage
- This command can be used only after the TCP/IP protocol stack is enabled.
- Detecting the IP address conflict takes a period of time. Each time you run the **ifconfig** command to set an IP address, there is a delay of about 2 seconds.
## Example
1. ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
2. ifconfig -a
3. ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
4. ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
## Output
1. Setting network parameters:
```
OHOS # ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
OHOS # ifconfig
eth0 ip:192.168.100.31 netmask:255.255.255.0 gateway:192.168.100.1
HWaddr 00:49:cb:6c:a1:31 MTU:1500 Running Default Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
```
The following table describes the output parameters.
**Table 2** Output description
2. Obtaining protocol stack statistics:
```
OHOS # ifconfig -a
RX packets:6922 errors:0 ip dropped:4312 link dropped:67 overrun:0 bytes:0 (0.0 B)
RX packets(ip6):3 errors:0 dropped:0 overrun:0 bytes:0 (0.0 B)
TX packets:1394 errors:0 link dropped:67 overrun:0 bytes:0(0.0 B)
TX packets(ip6):3 errors:0 overrun:0 bytes:0(0.0 B)
```
The following table describes the output parameters.
**Table 3** ifconfig -a output description
3. Setting the IPv6 address information:
```
OHOS # ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
OHOS # ifconfig
eth1 ip:192.168.3.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 00:0e:c6:a8:5a:c2 MTU:1500 Running Link UP
eth0 ip:192.168.2.60 netmask:255.255.255.0 gateway:0.0.0.0
ip6: 2001:A:B:C:D:E:F:D/64
HWaddr 46:44:02:02:03:03 MTU:1500 Running Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:16436 Running Link UP
```
4. Deleting the IPv6 address information:
```
OHOS # ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
OHOS # ifconfig
eth1 ip:192.168.3.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 00:0e:c6:a8:5a:c2 MTU:1500 Running Link UP
eth0 ip:192.168.2.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 46:44:02:02:03:03 MTU:1500 Running Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:16436 Running Link UP
```
## Command Function
This command is used to query and set parameters of a NIC, such as the IP address, subnet mask, gateway, and MAC address, and enable or disable the NIC.
## Syntax
ifconfig
\[_-a_\]
<_interface_\> <_address_\> \[_netmask
\[_hw ether _\] \[_mtu
\[_inet6 add _\]
\[_inet6 del _\]
\[_up|down_\]
## Parameter Description
**Table 1** Parameters
## Usage
- This command can be used only after the TCP/IP protocol stack is enabled.
- Detecting the IP address conflict takes a period of time. Each time you run the **ifconfig** command to set an IP address, there is a delay of about 2 seconds.
## Example
1. ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
2. ifconfig -a
3. ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
4. ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
## Output
1. Setting network parameters:
```
OHOS # ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
OHOS # ifconfig
eth0 ip:192.168.100.31 netmask:255.255.255.0 gateway:192.168.100.1
HWaddr 00:49:cb:6c:a1:31 MTU:1500 Running Default Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
```
The following table describes the output parameters.
**Table 2** Output description
2. Obtaining protocol stack statistics:
```
OHOS # ifconfig -a
RX packets:6922 errors:0 ip dropped:4312 link dropped:67 overrun:0 bytes:0 (0.0 B)
RX packets(ip6):3 errors:0 dropped:0 overrun:0 bytes:0 (0.0 B)
TX packets:1394 errors:0 link dropped:67 overrun:0 bytes:0(0.0 B)
TX packets(ip6):3 errors:0 overrun:0 bytes:0(0.0 B)
```
The following table describes the output parameters.
**Table 3** ifconfig -a output description
3. Setting the IPv6 address information:
```
OHOS # ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
OHOS # ifconfig
eth1 ip:192.168.3.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 00:0e:c6:a8:5a:c2 MTU:1500 Running Link UP
eth0 ip:192.168.2.60 netmask:255.255.255.0 gateway:0.0.0.0
ip6: 2001:A:B:C:D:E:F:D/64
HWaddr 46:44:02:02:03:03 MTU:1500 Running Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:16436 Running Link UP
```
4. Deleting the IPv6 address information:
```
OHOS # ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
OHOS # ifconfig
eth1 ip:192.168.3.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 00:0e:c6:a8:5a:c2 MTU:1500 Running Link UP
eth0 ip:192.168.2.60 netmask:255.255.255.0 gateway:0.0.0.0
HWaddr 46:44:02:02:03:03 MTU:1500 Running Link UP
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:16436 Running Link UP
```
点赞
回复
X