Linux终端常用命令

ifconfig (参数)

显示网络设备信息(激活状态的):

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3E:00:1E:51  
          inet addr:10.160.7.81  Bcast:10.160.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:61430830 errors:0 dropped:0 overruns:0 frame:0
          TX packets:88534 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3607197869 (3.3 GiB)  TX bytes:6115042 (5.8 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:56103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5079451 (4.8 MiB)  TX bytes:5079451 (4.8 MiB)

eth0表示第一块网卡,其中HWaddr表示网卡的物理地址,可以看到目前这个网卡的物理地址(MAC地址)是00:16:3E:00:1E:51

inet addr用来表示网卡的IP地址,此网卡的IP地址是10.160.7.81,广播地址Bcast:10.160.15.255,掩码地址Mask:255.255.240.0

lo是表示主机的回环地址,这个一般是用来测试一个网络程序,但又不想让局域网或外网的用户能够查看,只能在此台主机上运行和查看所用的网络接口。比如把 httpd服务器的指定到回环地址,在浏览器输入127.0.0.1就能看到你所架WEB网站了。但只是您能看得到,局域网的其它主机或用户无从知道。

第一行:连接类型: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服务器操作要小心,关闭了就不能开启了,除非你有多网卡。

为网卡配置和删除IPv6地址:

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

 

posted @ 2019-09-16 09:35  B1ack_Wall  阅读(358)  评论(0编辑  收藏  举报