ipaddrshoweth0
❶ 在LINUX 下怎么查看网卡的MAC地址
准备工具/材料:装有LINUX系统的电脑一台。
在LINUX下查看网卡的MAC地址的办法如下:
1、首先在桌面右键选择“打开终端”。
❷ centos7如何查看ip信息
1、首先使用ip add命令查看系统当前IP地址,可以看到当前IP地址是10.0.0.3。
❸ Linux绯荤粺鏌ョ湅IP鍦板潃 IP璁剧疆涓庢煡鐪嬪懡浠ゅぇ鍏
Linux鏄涓绉嶈嚜鐢卞拰寮鏀炬簮鐮佺殑绫籙nix鎿嶄綔绯荤粺锛屽瓨鍦ㄧ潃璁稿氫笉鍚岀殑Linux鐗堟湰锛屼絾瀹冧滑閮戒娇鐢ㄤ簡Linux鍐呮牳锛屽湪寰堝氫笓涓氳$畻鏈哄満鍚堥兘鏈夌敤鍒般侺inux鎿嶄綔绯荤粺浣跨敤鐩稿硅緝涓哄嶆潅锛岀敱浜庨氬父閮芥槸鍛戒护鎿嶄綔锛屾瘮鎴戜滑鐔熺煡鐨刉inodows绯荤粺鏇翠笉瀹规槗涓婃墜锛屼絾鍏跺畨鍏ㄦу嵈瑕佹洿楂橈紝閽堝归渶瑕佽剧疆Linux绯荤粺缃戠粶鐨勬湅鍙嬶紝浠ヤ笅鐧句簨缃戝皬缂栦负鍏堕檮涓妉inux绯荤粺IP璁剧疆涓庢煡鐪嬪懡浠ゅぇ鍏锛屽笇鏈涘规柊鎵嬫湅鍙嬫湁鎵甯鍔┿
1. 浣跨敤ifconfig鍛戒护閰嶇疆骞舵煡鐪嬬綉缁滄帴鍙f儏鍐电ず渚1: 閰嶇疆eth0鐨処P锛屽悓鏃舵縺娲昏惧:# ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up绀轰緥2: 閰嶇疆eth0鍒鍚嶈惧 eth0:1 鐨処P锛屽苟娣诲姞璺鐢# ifconfig eth0:1 192.168.4.2# route add 鈥揾ost 192.168.4.2 dev eth0:1绀轰緥3:婵娲伙紙绂佺敤锛夎惧# ifconfig eth0:1 up(down)绀轰緥4:鏌ョ湅鎵鏈夛紙鎸囧畾锛夌綉缁滄帴鍙i厤缃# ifconfig (eth0)鈥斺斺斺斺斺斺斺斺2. 浣跨敤route 鍛戒护閰嶇疆璺鐢辫〃绀轰緥1:娣诲姞鍒颁富鏈鸿矾鐢# route add 鈥揾ost 192.168.4.2 dev eth0:1# route add 鈥揾ost 192.168.4.1 gw 192.168.4.250绀轰緥2:娣诲姞鍒扮綉缁滅殑璺鐢# route add 鈥搉et IP netmask MASK eth0# route add 鈥搉et IP netmask MASK gw IP# route add 鈥搉et IP/24 eth1绀轰緥3:娣诲姞榛樿ょ綉鍏# route add default gw IP绀轰緥4:鍒犻櫎璺鐢# route del 鈥揾ost 192.168.4.1 dev eth0:1绀轰緥5:鏌ョ湅璺鐢变俊鎭#route 鎴杛oute -n(-n 琛ㄧず涓嶈В鏋愬悕瀛,鍒楀嚭閫熷害浼氭瘮route 蹇)鈥斺斺斺斺斺斺斺斺3.ARP 绠$悊鍛戒护绀轰緥1:鏌ョ湅ARP缂撳瓨# arp绀轰緥2:娣诲姞# arp 鈥搒 IP MAC绀轰緥3: 鍒犻櫎# arp 鈥揹 IP鈥斺斺斺斺斺斺斺斺4.ip鏄痠proute2杞浠跺寘閲岄潰鐨勪竴涓寮哄ぇ鐨勭綉缁滈厤缃宸ュ叿锛屽畠鑳藉熸浛浠d竴浜涗紶缁熺殑缃戠粶绠$悊宸ュ叿銆備緥濡傦細ifconfig銆乺oute绛,涓婇潰鐨勭ず渚嬪畬鍏ㄥ彲浠ョ敤涓嬮潰鐨刬p鍛戒护瀹炵幇,鑰屼笖ip鍛戒护鍙浠ュ疄鐜版洿澶氱殑鍔熻兘.涓嬮潰浠嬬粛涓浜涚ず渚:
4.0 ip鍛戒护鐨勮娉昳p [OPTIONS] OBJECT [COMMAND [ARGUMENTS]]
4.1 ip link set鈥撴敼鍙樿惧囩殑灞炴.缂╁啓锛歴et銆乻
绀轰緥1锛歶p/down 璧峰姩锛忓叧闂璁惧囥# ip link set dev eth0 up杩欎釜绛変簬浼犵粺鐨 # ifconfig eth0 up(down)绀轰緥2锛氭敼鍙樿惧囦紶杈撻槦鍒楃殑闀垮害銆傚弬鏁:txqueuelen NUMBER鎴栬卼xqlen NUMBER# ip link set dev eth0 txqueuelen 100绀轰緥3锛氭敼鍙樼綉缁滆惧嘙TU(鏈澶т紶杈撳崟鍏)鐨勫笺# ip link set dev eth0 mtu 1500绀轰緥4锛 淇鏀圭綉缁滆惧囩殑MAC鍦板潃銆傚弬鏁: address LLADDRESS# ip link set dev eth0 address 00:01:4f:00:15:f1
4.2 ip link show鈥撴樉绀鸿惧囧睘鎬.缂╁啓锛歴how銆乴ist銆乴st銆乻h銆乴s銆乴-s閫夐」鍑虹幇涓ゆ℃垨鑰呮洿澶氭★紝ip浼氳緭鍑烘洿涓鸿︾粏鐨勯敊璇淇℃伅缁熻°傜ず渚:# ip -s -s link ls eth0杩欎釜鍛戒护绛変簬浼犵粺鐨 ifconfig eth0鈥斺斺斺斺斺斺斺斺5.1 ip address add鈥撴坊鍔犱竴涓鏂扮殑鍗忚鍦板潃. 缂╁啓锛歛dd銆乤绀轰緥1锛氫负姣忎釜鍦板潃璁剧疆涓涓瀛楃︿覆浣滀负鏍囩俱備负浜嗗拰Linux-2.0鐨勭綉缁滃埆鍚嶅吋瀹癸紝杩欎釜瀛楃︿覆蹇呴』浠ヨ惧囧悕寮澶达紝鎺ョ潃涓涓鍐掑彿锛# ip addr add local 192.168.4.1/28 brd + label eth0:1 dev eth0绀轰緥2: 鍦ㄤ互澶缃戞帴鍙eth0涓婂炲姞涓涓鍦板潃192.168.20.0锛屾帺鐮侀暱搴︿负24浣(155.155.155.0)锛屾爣鍑嗗箍鎾鍦板潃锛屾爣绛句负eth0:Alias锛# ip addr add 192.168.4.2/24 brd + dev eth1 label eth1:1杩欎釜鍛戒护绛変簬浼犵粺鐨:ifconfig eth1:1 192.168.4.2
5.2 ip address delete鈥撳垹闄や竴涓鍗忚鍦板潃. 缂╁啓锛歞elete銆乨el銆乨# ip addr del 192.168.4.1/24 brd + dev eth0 label eth0:Alias1
5.3 ip address show鈥撴樉绀哄崗璁鍦板潃. 缂╁啓锛歴how銆乴ist銆乴st銆乻h銆乴s銆乴# ip addr ls eth0
5.4.ip address flush鈥撴竻闄ゅ崗璁鍦板潃. 缂╁啓锛歠lush銆乫绀轰緥1 : 鍒犻櫎灞炰簬绉佺綉10.0.0.0/8鐨勬墍鏈夊湴鍧锛# ip -s -s a f to 10/8绀轰緥2 : 鍙栨秷鎵鏈変互澶缃戝崱鐨処P鍦板潃# ip -4 addr flush label 鈥渆th0鈥斥斺斺斺斺斺斺斺斺6. ip neighbour鈥搉eighbour/arp琛ㄧ$悊鍛戒护缂╁啓 neighbour銆乶eighbor銆乶eigh銆乶鍛戒护 add銆乧hange銆乺eplace銆乨elete銆乫ulsh銆乻how(鎴栬卨ist)
6.1 ip neighbour add 鈥 娣诲姞涓涓鏂扮殑閭绘帴鏉$洰ip neighbour change鈥撲慨鏀逛竴涓鐜版湁鐨勬潯鐩甶p neighbour replace鈥撴浛鎹涓涓宸叉湁鐨勬潯鐩缂╁啓锛歛dd銆乤锛沜hange銆乧hg锛況eplace銆乺epl绀轰緥1: 鍦ㄨ惧噀th0涓婏紝涓哄湴鍧10.0.0.3娣诲姞涓涓猵ermanent ARP鏉$洰锛# ip neigh add 10.0.0.3 lladdr 0:0:0:0:0:1 dev eth0 nud perm绀轰緥2:鎶婄姸鎬佹敼涓簉eachable# ip neigh chg 10.0.0.3 dev eth0 nud reachable
6.2.ip neighbour delete鈥撳垹闄や竴涓閭绘帴鏉$洰绀轰緥1:鍒犻櫎璁惧噀th0涓婄殑涓涓狝RP鏉$洰10.0.0.3# ip neigh del 10.0.0.3 dev eth06.3.ip neighbour show鈥撴樉绀虹綉缁滈偦灞呯殑淇℃伅.缂╁啓锛歴how銆乴ist銆乻h銆乴s绀轰緥1: # ip -s n ls 193.233.7.254193.233.7.254. dev eth0 lladdr 00:00:0c:76:3f:85 ref 5 used 12/13/20 nud reachable6.4.ip neighbour flush鈥撴竻闄ら偦鎺ユ潯鐩. 缂╁啓锛歠lush銆乫绀轰緥1: (-s 鍙浠ユ樉绀鸿︾粏淇℃伅)# ip -s -s n f 193.233.7.254鈥斺斺斺斺斺斺斺斺7. 璺鐢辫〃绠$悊7.1.缂╁啓 route銆乺o銆乺7.5.璺鐢辫〃浠嶭inux-2.2寮濮嬶紝鍐呮牳鎶婅矾鐢卞綊绾冲埌璁稿氳矾鐢辫〃涓锛岃繖浜涜〃閮借繘琛屼簡缂栧彿锛岀紪鍙锋暟瀛楃殑鑼冨洿鏄1鍒255銆傚彟澶栵紝涓轰簡鏂逛究锛岃繕鍙浠ュ湪/etc/iproute2/rt_tables涓涓鸿矾鐢辫〃鍛藉悕銆傞粯璁ゆ儏鍐典笅锛屾墍鏈夌殑璺鐢遍兘浼氳鎻掑叆鍒拌〃main(缂栧彿254)涓銆傚湪杩涜岃矾鐢辨煡璇㈡椂锛屽唴鏍稿彧浣跨敤璺鐢辫〃main銆
7.6.ip route add 鈥 娣诲姞鏂拌矾鐢眎p route change 鈥 淇鏀硅矾鐢眎p route replace 鈥 鏇挎崲宸叉湁鐨勮矾鐢辩缉鍐欙細add銆乤锛沜hange銆乧hg锛況eplace銆乺epl绀轰緥1: 璁剧疆鍒扮綉缁10.0.0/24鐨勮矾鐢辩粡杩囩綉鍏193.233.7.65# ip route add 10.0.0/24 via 193.233.7.65
绀轰緥2: 淇鏀瑰埌缃戠粶10.0.0/24鐨勭洿鎺ヨ矾鐢憋紝浣垮叾缁忚繃璁惧嘾ummy# ip route chg 10.0.0/24 dev mmy
绀轰緥3: 瀹炵幇閾捐矾璐熻浇骞宠.鍔犲叆缂虹渷澶氳矾寰勮矾鐢憋紝璁﹑pp0鍜宲pp1鍒嗘媴璐熻浇(娉ㄦ剰锛歴cope鍊煎苟闈炲繀闇锛屽畠鍙涓嶈繃鏄鍛婅瘔鍐呮牳锛岃繖涓璺鐢辫佺粡杩囩綉鍏宠屼笉鏄鐩磋繛鐨勩傚疄闄呬笂锛屽傛灉浣犵煡閬撹繙绋嬬鐐圭殑鍦板潃锛屼娇鐢╲ia鍙傛暟鏉ヨ剧疆灏辨洿濂戒簡)銆# ip route add default scope global nexthop dev ppp0 nexthop dev ppp1# ip route replace default scope global nexthop dev ppp0 nexthop dev ppp1绀轰緥4: 璁剧疆NAT璺鐢便傚湪杞鍙戞潵鑷192.203.80.144鐨勬暟鎹鍖呬箣鍓嶏紝鍏堣繘琛岀綉缁滃湴鍧杞鎹锛屾妸杩欎釜鍦板潃杞鎹涓193.233.7.83# ip route add nat 192.203.80.142 via 193.233.7.83
绀轰緥5: 瀹炵幇鏁版嵁鍖呯骇璐熻浇骞宠,鍏佽告妸鏁版嵁鍖呴殢鏈轰粠澶氫釜璺鐢卞彂鍑恒倃eight 鍙浠ヨ剧疆鏉冮噸.# ip route replace default equalize nexthop via 211.139.218.145 dev eth0 weight 1 nexthop via 211.139.218.145 dev eth1 weight 1
7.7.ip route delete鈥 鍒犻櫎璺鐢辩缉鍐欙細delete銆乨el銆乨绀轰緥1:鍒犻櫎涓婁竴鑺傚懡浠ゅ姞鍏ョ殑澶氳矾寰勮矾鐢# ip route del default scope global nexthop dev ppp0 nexthop dev ppp1
7.8.ip route show 鈥 鍒楀嚭璺鐢辩缉鍐欙細show銆乴ist銆乻h銆乴s銆乴
绀轰緥1: 璁$畻浣跨敤gated/bgp鍗忚鐨勮矾鐢变釜鏁# ip route ls proto gated/bgp |wc1413989179010
绀轰緥2: 璁$畻璺鐢辩紦瀛橀噷闈㈢殑鏉℃暟锛岀敱浜庤缂撳瓨璺鐢辩殑灞炴у彲鑳藉ぇ浜庝竴琛岋紝浠ユら渶瑕佷娇鐢-o閫夐」# ip -o route ls cloned |wc159254318707绀轰緥3: 鍒楀嚭璺鐢辫〃TABLEID閲岄潰鐨勮矾鐢便傜己鐪佽剧疆鏄痶able main銆俆ABLEID鎴栬呮槸涓涓鐪熸g殑璺鐢辫〃ID鎴栬呮槸/etc/iproute2/rt_tables鏂囦欢瀹氫箟鐨勫瓧绗︿覆锛屾垨鑰呮槸浠ヤ笅鐨勭壒娈婂硷細all 鈥 鍒楀嚭鎵鏈夎〃鐨勮矾鐢憋紱cache 鈥 鍒楀嚭璺鐢辩紦瀛樼殑鍐呭广俰p ro ls 193.233.7.82 tab cache绀轰緥4: 鍒楀嚭鏌愪釜璺鐢辫〃鐨勫唴瀹# ip route ls table fddi153
绀轰緥5: 鍒楀嚭榛樿よ矾鐢辫〃鐨勫唴瀹# ip route ls杩欎釜鍛戒护绛変簬浼犵粺鐨: route
7.9.ip route flush 鈥 鎿﹂櫎璺鐢辫〃绀轰緥1: 鍒犻櫎璺鐢辫〃main涓鐨勬墍鏈夌綉鍏宠矾鐢憋紙绀轰緥锛氬湪璺鐢辩洃鎺х▼搴忔寕鎺変箣鍚庯級锛# ip -4 ro flush scope global type unicast绀轰緥2:娓呴櫎鎵鏈夎鍏嬮殕鍑烘潵鐨処Pv6璺鐢憋細# ip -6 -s -s ro flush cache绀轰緥3:鍦╣ated绋嬪簭鎸傛帀涔嬪悗锛屾竻闄ゆ墍鏈夌殑BGP璺鐢憋細# ip -s ro f proto gated/bgp绀轰緥4: 娓呴櫎鎵鏈塱pv4璺鐢眂ache# ip route flush cache*** IPv4 routing cache is flushed.
7.10ip route get 鈥 鑾峰緱鍗曚釜璺鐢 .缂╁啓锛歡et銆乬浣跨敤杩欎釜鍛戒护鍙浠ヨ幏寰楀埌杈剧洰鐨勫湴鍧鐨勪竴涓璺鐢变互鍙婂畠鐨勭‘鍒囧唴瀹广俰p route get鍛戒护鍜宨p route show鍛戒护鎵ц岀殑鎿嶄綔鏄涓嶅悓鐨勩俰p route show鍛戒护鍙鏄鏄剧ず鐜版湁鐨勮矾鐢憋紝鑰宨p route get鍛戒护鍦ㄥ繀瑕佹椂浼氭淳鐢熷嚭鏂扮殑璺鐢便傜ず渚1: 鎼滅储鍒193.233.7.82鐨勮矾鐢# ip route get 193.233.7.82193.233.7.82 dev eth0src 193.233.7.65 realms inr.ac cachemtu 1500 rtt 300绀轰緥2: 鎼滅储鐩鐨勫湴鍧鏄193.233.7.82锛屾潵鑷193.233.7.82锛屼粠eth0璁惧囧埌杈剧殑璺鐢憋紙杩欐潯鍛戒护浼氫骇鐢熶竴鏉¢潪甯告湁鎰忔濈殑璺鐢憋紝杩欐槸涓鏉″埌193.233.7.82鐨勫洖鐜璺鐢憋級# ip r g 193.233.7.82 from 193.233.7.82 iif eth0193.233.7.82 from 193.233.7.82 dev eth0src 193.233.7.65realms inr.ac/inr.accache ;mtu 1500 rtt 300 iif eth0鈥斺斺斺斺斺斺斺斺8. ip route 鈥 璺鐢辩瓥鐣ユ暟鎹搴撶$悊鍛戒护鍛戒护add銆乨elete銆乻how(鎴栬卨ist)娉ㄦ剰锛氱瓥鐣ヨ矾鐢(policy routing)涓嶇瓑浜庤矾鐢辩瓥鐣(rouing policy)銆傚湪鏌愪簺鎯呭喌涓嬶紝鎴戜滑涓嶅彧鏄闇瑕侀氳繃鏁版嵁鍖呯殑鐩鐨勫湴鍧鍐冲畾璺鐢憋紝鍙鑳借繕闇瑕侀氳繃鍏朵粬涓浜涘煙锛氭簮鍦板潃銆両P鍗忚銆佷紶杈撳眰绔鍙g敋鑷虫暟鎹鍖呯殑璐熻浇銆傝繖灏卞彨鍋氾細绛栫暐璺鐢(policy routing)銆
8.5. ip rule add 鈥 鎻掑叆鏂扮殑瑙勫垯ip rule delete 鈥 鍒犻櫎瑙勫垯缂╁啓锛歛dd銆乤锛沝elete銆乨el銆乨
绀轰緥1: 閫氳繃璺鐢辫〃inr.ruhep璺鐢辨潵鑷婧愬湴鍧涓192.203.80/24鐨勬暟鎹鍖卛p ru add from 192.203.80/24 table inr.ruhep prio 220
绀轰緥2:鎶婃簮鍦板潃涓193.233.7.83鐨勬暟鎹鎶ョ殑婧愬湴鍧杞鎹涓192.203.80.144锛屽苟閫氳繃琛1杩涜岃矾鐢眎p ru add from 193.233.7.83 nat 192.203.80.144 table 1 prio 320
绀轰緥3:鍒犻櫎鏃犵敤鐨勭己鐪佽勫垯ip ru del prio 32767
8.7. ip rule show 鈥 鍒楀嚭璺鐢辫勫垯缂╁啓锛歴how銆乴ist銆乻h銆乴s銆乴绀轰緥1:# ip ru ls0:from all lookup local32762:from 192.168.4.89 lookup fddi15332764:from 192.168.4.88 lookup fddi15332766:from all lookup main32767:from all lookup 253鈥斺斺斺斺斺斺斺斺9.ip maddress 鈥 澶氭挱鍦板潃绠$悊缂╁啓锛歴how銆乴ist銆乻h銆乴s銆乴9.3.ip maddress show 鈥 鍒楀嚭澶氭挱鍦板潃绀轰緥1: # ip maddr ls mmy
9.4. ip maddress add 鈥 鍔犲叆澶氭挱鍦板潃ip maddress delete 鈥 鍒犻櫎澶氭挱鍦板潃缂╁啓锛歛dd銆乤锛沝elete銆乨el銆乨浣跨敤杩欎袱涓鍛戒护锛屾垜浠鍙浠ユ坊鍔狅紡鍒犻櫎鍦ㄧ綉缁滄帴鍙d笂鐩戝惉鐨勯摼璺灞傚氭挱鍦板潃銆傝繖涓鍛戒护鍙鑳界$悊閾捐矾灞傚湴鍧銆
绀轰緥1: 澧炲姞# ip maddr add 33:33:00:00:00:01 dev mmy绀轰緥2: 鏌ョ湅# ip -O maddr ls mmy2:mmylink33:33:00:00:00:01 users 2 staticlink01:00:5e:00:00:01绀轰緥3: 鍒犻櫎# ip maddr del 33:33:00:00:00:01 dev mmy鈥斺斺斺斺斺斺斺斺10.ip mroute 鈥 澶氭挱璺鐢辩紦瀛樼$悊
10.4.ip mroute show 鈥 鍒楀嚭澶氭挱璺鐢辩紦瀛樻潯鐩缂╁啓锛歴how銆乴ist銆乻h銆乴s銆乴
绀轰緥1:鏌ョ湅# ip mroute ls(193.232.127.6, 224.0.1.39)Iif: unresolved(193.232.244.34, 224.0.1.40)Iif: unresolved(193.233.7.65, 224.66.66.66)Iif: eth0Oifs: pimreg绀轰緥2:鏌ョ湅# ip -s mr ls 224.66/16(193.233.7.65, 224.66.66.66)Iif: eth0Oifs: pimreg9383 packets, 300256 bytes鈥斺斺斺斺斺斺斺斺11. ip tunnel 鈥 閫氶亾閰嶇疆缂╁啓tunnel銆乼unl
11.4.ip tunnel add 鈥 娣诲姞鏂扮殑閫氶亾ip tunnel change 鈥 淇鏀圭幇鏈夌殑閫氶亾ip tunnel delete 鈥 鍒犻櫎涓涓閫氶亾缂╁啓锛歛dd銆乤锛沜hange銆乧hg锛沝elete銆乨el銆乨绀轰緥1:寤虹珛涓涓鐐瑰圭偣閫氶亾锛屾渶澶TTL鏄32# ip tunnel add Cisco mode sit remote 192.31.7.104 local 192.203.80.1 ttl 32
11.4.ip tunnel show 鈥 鍒楀嚭鐜版湁鐨勯氶亾缂╁啓锛歴how銆乴ist銆乻h銆乴s銆乴绀轰緥1:# ip -s tunl ls Cisco鈥斺斺斺斺斺斺斺斺12. ip monitor鍜宺tmon 鈥 鐘舵佺洃瑙唅p鍛戒护鍙浠ョ敤浜庤繛缁鍦扮洃瑙嗚惧囥佸湴鍧鍜岃矾鐢辩殑鐘舵併傝繖涓鍛戒护閫夐」鐨勬牸寮忔湁鐐逛笉鍚岋紝鍛戒护閫夐」鐨勫悕瀛楀彨鍋歮onitor锛屾帴鐫鏄鎿嶄綔瀵硅薄锛歩p monitor [ file FILE ] [ all | OBJECT-LIST ]绀轰緥1:# rtmon file /var/log/rtmon.log绀轰緥2:# ip monitor file /var/log/rtmon.log r