Linux command
ifconfig 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show all interfaces
ifconfig
Show specific interface
ifconfig [eth0]
Set IP address
sudo ifconfig [eth0] [192.168.1.100]
Enable interface
sudo ifconfig [eth0] up
Disable interface
sudo ifconfig [eth0] down
Set netmask
sudo ifconfig [eth0] netmask [255.255.255.0]
说明
ifconfig configures network interfaces. It displays and modifies IP addresses, netmasks, and interface status. Without arguments, it shows all active interfaces. With -a, it shows all interfaces including those that are down. The tool is part of net-tools and is being replaced by the ip command from iproute2, but remains widely used on many systems.
参数
- up
- Activate interface.
- down
- Deactivate interface.
- netmask _MASK_
- Set network mask.
- broadcast _ADDR_
- Set broadcast address.
- mtu _SIZE_
- Set MTU size.
- -a
- Display all interfaces, even if down.
- hw _class_ _address_
- Set hardware (MAC) address (e.g. `hw ether AA:BB:...`).
- promisc / -promisc
- Enable or disable promiscuous mode.
- arp / -arp
- Enable or disable ARP protocol on the interface.
- multicast / -multicast
- Enable or disable multicast flag.
- add _ADDR_/_PREFIX_
- Add an IPv6 address to the interface.
- del _ADDR_/_PREFIX_
- Remove an IPv6 address from the interface.
- --help
- Display help information.
FAQ
What is the ifconfig command used for?
ifconfig configures network interfaces. It displays and modifies IP addresses, netmasks, and interface status. Without arguments, it shows all active interfaces. With -a, it shows all interfaces including those that are down. The tool is part of net-tools and is being replaced by the ip command from iproute2, but remains widely used on many systems.
How do I run a basic ifconfig example?
Run `ifconfig` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does up do in ifconfig?
Activate interface.