---恢复内容开始---
ifconfig
hling@hling:~$ ifconfig
ens33 Link encap:以太网 硬件地址 00:0c:29:6c:9e:a3 物理地址
inet 地址:192.168.59.130 ip地址 广播:192.168.59.255 掩码:255.255.255.0
inet6 地址: fe80::5ec1:30c1:a604:1c1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:14598 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:11070 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:16373056 (16.3 MB) 发送字节:1089240 (1.0 MB)
中断:19 基本地址:0x2000
lo 主机的回环地址 Link encap:本地环回
inet 地址:127.0.0.1 掩码:255.0.0.0
inet6 地址: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 跃点数:1
接收数据包:1642 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:1642 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:114763 (114.7 KB) 发送字节:114763 (114.7 KB)
其中:
eth0表示第一块网卡,其中HWaddr
表示网卡的物理地址,可以看到目前这个网卡的物理地址(MAC地址)是00:0c:29:6c:9e:a3
lo
- 第一行:连接类型:Ethernet(以太网)HWaddr(硬件mac地址)。
- 第二行:网卡的IP地址、子网、掩码。
- 第三行:UP(代表网卡开启状态)RUNNING(代表网卡的网线被接上)MULTICAST(支持组播)MTU:1500(最大传输单元):1500字节。
- 第四、五行:接收、发送数据包情况统计。
- 第七行:接收、发送数据字节数统计信息。
ifconfig eth0 up
ifconfig eth0 down
ifconfig eth0 up为启动网卡eth0,ifconfig eth0 down
为关闭网卡eth0。ssh登陆linux服务器操作要小心,关闭了就不能开启了,除非你有多网卡。
ifconfig eth0 add 33ffe:3240:800:1005::2/64 #为网卡eth0配置IPv6地址
ifconfig eth0 del 33ffe:3240:800:1005::2/64 #为网卡eth0删除IPv6地址
用ifconfig修改MAC地址:
ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE
配置IP地址:
[root@localhost ~]# ifconfig eth0 192.168.2.10 [root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 [root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255
启用和关闭arp协议:
ifconfig eth0 arp #开启网卡eth0 的arp协议 ifconfig eth0 -arp #关闭网卡eth0 的arp协议
设置最大传输单元:
ifconfig eth0 mtu 1500 #设置能通过的最大数据包大小为 1500 bytes
---恢复内容结束---