Linux ifconfig command
Linux ifconfig command is used to display or set the network device.
ifconfig can set the status of network devices, or displays the current settings.
grammar
ifconfig [网络设备][down up -allmulti -arp -promisc][add<地址>][del<地址>][<hw<网络设备类型><硬件地址>][io_addr<I/O地址>][irq<IRQ地址>][media<网络媒介类型>][mem_start<内存地址>][metric<数目>][mtu<字节>][netmask<子网掩码>][tunnel<地址>][-broadcast<地址>][-pointopoint<地址>][IP地址]
Parameter Description:
- add <address> Sets the IP address of the network device IPv6.
- del <address> Remove network device IPv6 IP address.
- Close down the specified network device.
- <Hw <network device type> <hardware address> Set the type of network equipment and hardware address.
- io_addr <I / O address> Set the network device I / O address.
- irq <IRQ address> Sets the network device IRQ.
- media <media network type> set network device media types.
- mem_start <memory address> Set the start address in main memory network equipment occupied.
- metric <number> is specified in the calculation of the packet forwarding number, the number to be added.
- mtu <bytes> Sets the network device MTU.
- netmask <Subnet Mask> Set subnet mask of network equipment.
- tunnel <address> to establish a communication tunnel between IPv4 and IPv6 addresses.
- Start up a specified network device.
- -broadcast <address> will be sent to the specified address as the packet broadcast packets to deal with.
- -pointopoint network equipment <address> with the specified address to establish a direct connection, this model has a security function.
- -promisc shut down or start promiscuous mode specified network device.
- [IP address] Specifies the IP address of the network device.
- Name [network equipment] specified network device.
Examples
Display network device information
# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:172220 errors:0 dropped:0 overruns:0 frame:0 TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB) Interrupt:185 Base address:0x2024 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2022 errors:0 dropped:0 overruns:0 frame:0 TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
Start Close the specified NIC
# ifconfig eth0 down # ifconfig eth0 up
Provision and delete IPv6 address for the network card
# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //为网卡诶之IPv6地址 # ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //为网卡删除IPv6地址
Modify the MAC address with ifconfig
# ifconfig eth0 down //关闭网卡 # ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址 # ifconfig eth0 up //启动网卡 # ifconfig eth1 hw ether 00:1D:1C:1D:1E //关闭网卡并修改MAC地址 # ifconfig eth1 up //启动网卡
Configure the IP address
# ifconfig eth0 192.168.1.56 //给eth0网卡配置IP地址 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0 // 给eth0网卡配置IP地址,并加上子掩码 # ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255 // 给eth0网卡配置IP地址,加上子掩码,加上个广播地址
Enable and disable the ARP protocol
# ifconfig eth0 arp //开启 # ifconfig eth0 -arp //关闭
Sets the maximum transmission unit
# ifconfig eth0 mtu 1500 //设置能通过的最大数据包大小为 1500 bytes