1 概述ifconfig工具不僅可以被用來簡單地獲取網(wǎng)絡(luò)接口配置信息,,還可以修改這些配置。用ifconfig命令配置的網(wǎng)卡信息,,在網(wǎng)卡重啟后機(jī)器重啟后,配置就不存在,。要想將上述的配置信息永遠(yuǎn)的存的電腦里,,那就要修改網(wǎng)卡的配置文件了。 3 簡單實(shí)例 3.1 顯示網(wǎng)絡(luò)設(shè)備信息 (1) 顯示激活的網(wǎng)卡信息 ifconfig (2) 顯示所有的網(wǎng)卡信息 ifconfig -a (3) 顯示簡要的網(wǎng)卡信息 ifconfig -s 3.2 啟動關(guān)閉指定網(wǎng)卡 (1) 關(guān)閉網(wǎng)卡 ifconfig eth0 down (2) 啟動網(wǎng)卡 ifconfig eth0 up 3.3 配置和刪除ip地址 (1) 配置ip // 配置ip地址 ifconfig eth0 192.168.1.100 // 配置ip地址和子網(wǎng)掩碼 ifconfig eth0 192.168.1.100 netmask 255.255.255.0 // 配置ip地址,、子網(wǎng)掩碼和廣播地址 ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 (2) 單網(wǎng)卡添加多個IP地址 ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0 up ifconfig eth0:1 192.168.2.100 netmask 255.255.255.0 up (3) 刪除IP地址 ifconfig eth0 del 192.168.1.100 3.4 修改MAC地址 ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE 3.5 啟用和關(guān)閉ARP協(xié)議 (1) 啟用arp ifconfig eth0 arp (2) 禁用arp ifconfig eth0 -arp 禁用arp的時候,,可以看到出現(xiàn)NOARP字段。 [root@localhost ~]# ifconfig eth0 arp [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2635 bytes 204710 (199.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# ifconfig eth0 -arp [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2636 bytes 204770 (199.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 3.6 設(shè)置最大傳輸單元 ifconfig eth0 mtu 1500 3.7 設(shè)置網(wǎng)卡的promiscuous模式 (1) 啟用 ifconfig eth0 promisc (2) 禁用 ifconfig eth0 -promisc 如果選擇此參數(shù),,網(wǎng)卡將接收網(wǎng)絡(luò)中發(fā)給它所有的數(shù)據(jù)包,。當(dāng)啟用時出現(xiàn)PROMISC字段。 [root@localhost ~]# ifconfig eth0 promisc [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2659 bytes 206696 (201.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# [root@localhost ~]# ifconfig eth0 -promisc [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2661 bytes 206816 (201.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 3.8 設(shè)置網(wǎng)卡的多播模式 (1) 啟用 ifconfig eth0 allmulti (2) 禁用 ifconfig eth0 -allmulti 如果選擇此參數(shù),,網(wǎng)卡將接收網(wǎng)絡(luò)中所有的多播數(shù)據(jù)包,。當(dāng)啟用時會出現(xiàn)MULTICAST字段。 [root@localhost ~]# ifconfig eth0 allmulti [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4675<UP,BROADCAST,RUNNING,ALLMULTI,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2676 bytes 207716 (202.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# [root@localhost ~]# ifconfig eth0 -allmulti [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe9b:52d3 prefixlen 64 scopeid 0x20<link> ether 00:aa:bb:cc:dd:ee txqueuelen 1000 (Ethernet) RX packets 2676 bytes 207716 (202.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1071 bytes 144688 (141.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 3.9 配置和刪除IPv6地址 (1) 添加 ifconfig eth0 add 3ffe:3240:800:1005::2/64 (2) 刪除 ifconfig eth0 del 3ffe:3240:800:1005::2/64 --------------------- 作者:路癡的旅行 來源:CSDN 原文:https://blog.csdn.net/u011857683/article/details/83758503 版權(quán)聲明:本文為博主原創(chuàng)文章,,轉(zhuǎn)載請附上博文鏈接,! |
|