linux查看系統ip
1. linux鏌ョ湅ip鍦板潃鐨勫懡浠
Linux鏌ョ湅IP鍦板潃鐨勫懡浠ゆ槸錛歩fconfig鍜宨p鍛戒護銆
1. ifconfig鍛戒護
ifconfig鏄疞inux涓鐢ㄤ簬閰嶇疆緗戠粶鎺ュ彛鐨勭粡鍏稿懡浠ゃ傞氳繃璇ュ懡浠わ紝浣犲彲浠ユ煡鐪嬫垨閰嶇疆緗戠粶鎺ュ彛鐨勫悇縐嶅弬鏁幫紝鍖呮嫭IP鍦板潃銆傝佹煡鐪婭P鍦板潃錛屽彧闇鍦ㄥ懡浠よ屼腑杈撳叆“ifconfig”騫跺洖杞︺傝ュ懡浠ゅ皢鍒楀嚭鎵鏈夌綉緇滄帴鍙e強鍏墮厤緗淇℃伅錛屽寘鎷琁P鍦板潃銆
2. ip鍛戒護
ip鍛戒護鏄疞inux涓鍙︿竴涓鐢ㄤ簬閰嶇疆緗戠粶鎺ュ彛鐨勭幇浠e伐鍏鳳紝瀹冩槸ifconfig鍛戒護鐨勬浛浠e搧銆備嬌鐢╥p鍛戒護錛屼綘鍙浠ユ洿鏂逛究鍦版煡鐪嬪拰綆$悊緗戠粶鎺ュ彛鐨勯厤緗銆傝佹煡鐪婭P鍦板潃錛屽彲浠ヤ嬌鐢“ip addr”鎴“ip address”鍛戒護銆傝繖灝嗘樉紺烘墍鏈夌綉緇滄帴鍙g殑璇︾粏淇℃伅錛屽寘鎷琁P鍦板潃銆
璇︾粏瑙i噴錛
鍦↙inux緋葷粺涓錛岀綉緇滈厤緗鏄闈炲父閲嶈佺殑閮ㄥ垎錛岃屾煡鐪婭P鍦板潃鏄鍏朵腑鐨勫熀鏈鎿嶄綔涔嬩竴銆傛棤璁烘槸浣跨敤ifconfig榪樻槸ip鍛戒護錛岄兘鍙浠ヨ交鏉捐幏鍙栧埌緋葷粺鐨処P鍦板潃淇℃伅銆
* ifconfig鍛戒護錛氳繖鏄涓涓鍘嗗彶鎮犱箙鐨勫懡浠わ紝璁稿氳佺敤鎴峰瑰叾闈炲父鐔熸倝銆傞氳繃璇ュ懡浠わ紝浣犲彲浠ユ煡鐪嬬綉緇滄帴鍙g殑璇︾粏閰嶇疆錛屽寘鎷琁P鍦板潃銆佸瓙緗戞帺鐮併丮AC鍦板潃絳夈傝櫧鐒秈p鍛戒護鍦ㄦ煇浜涙柟闈㈠姛鑳芥洿寮哄ぇ錛屼絾ifconfig浠嶇劧鏄涓涓甯哥敤鐨勫伐鍏楓
* ip鍛戒護錛氫笌ifconfig鐩告瘮錛宨p鍛戒護鎻愪緵浜嗘洿鐜頒唬鍖栫殑鎺ュ彛鏉ョ$悊緗戠粶閰嶇疆銆傚畠鏀鎸佹洿澶氱殑鍔熻兘錛屽苟涓旇娉曟洿鍔犳竻鏅般傞氳繃“ip addr”鎴“ip address”瀛愬懡浠わ紝浣犲彲浠ヨ交鏉懼湴鏌ョ湅鎵鏈夌綉緇滄帴鍙g殑璇︾粏淇℃伅錛屽寘鎷琁P鍦板潃銆傝繖瀵逛簬榪涜岀郴緇熺$悊鍜岀綉緇滈厤緗闈炲父鏈夌敤銆
鎬葷殑鏉ヨ達紝鏃犺轟綘閫夋嫨浣跨敤ifconfig榪樻槸ip鍛戒護錛岄兘鍙浠ュ湪Linux緋葷粺涓杞繪澗鏌ョ湅IP鍦板潃銆傝繖浜涘懡浠ゆ槸Linux緗戠粶綆$悊鐨勫熀鐭籌紝瀵逛簬緋葷粺綆$悊鍛樺拰鏅閫氱敤鎴鋒潵璇撮兘鏄闈炲父閲嶈佺殑宸ュ叿銆
2. linux鑾峰緱IP鍦板潃linux鑾峰緱ip
linux鏌ョ湅ip鐨勫嚑涓鍛戒護錛
鍦╨inux涓嬪彲浠ラ氳繃涓や釜鍛戒護鏉ユ煡鐪嬫湰鏈虹殑IP鍦板潃錛
1.鏀鎸佸寘鎷琇inux鍦ㄥ唴鐨勬墍鏈塙nix緋葷粺銆
#/sbin/ifconfig
2.瀵逛簬Linux鑰岃█錛屼篃鍙浠ヤ嬌鐢╥p鍛戒護鏌ョ湅錛屾彁紺猴細娌℃湁ifconfig鍛戒護鏃跺彲浠ョ敤姝ゅ懡浠ゆ煡鐪
#ipaddrshow
linux鑷鍔ㄨ幏鍙栫殑IP濡備綍鏌ョ湅錛
鍙浠ヤ嬌鐢╥fconfig鏌ョ湅緗戝崱淇℃伅,濡:涔熷彲浠ユ煡鐪嬮厤緗鏂囦歡,涓鑸鍦/etc/sysconfig/network-scripts鐩褰曚笅,濡:
Linux錛氭庢牱鑾峰彇鏈嶅姟鍣↖P鍦板潃錛
絎涓姝ワ細嬋媧葷綉鍗$郴緇熻呭ソ鍚庨粯璁ょ殑緗戝崱鏄痚th0錛岀敤涓嬮潰鐨勫懡浠ゅ皢榪欏潡緗戝崱嬋媧匯
#ifconfigeth0up絎浜屾ワ細璁劇疆緗戝崱榪涘叆緋葷粺鏃跺惎鍔ㄦ兂瑕佹瘡嬈″紑鏈哄氨鍙浠ヨ嚜鍔ㄨ幏鍙朓P鍦板潃涓婄綉錛屽氨瑕佽劇疆緗戠粶鏈嶅姟鍦ㄧ郴緇熷惎鍔ㄦ椂涔熷惎鍔ㄣ侺inux鏈変竴鐐逛笌windows涓嶅悓鐨勬槸寰堝氭湇鍔¢粯璁ゆ槸鍋滄㈢殑錛岃屼笖浣犲湪鏌愭′嬌鐢ㄨユ湇鍔℃椂鍚鍔ㄨ繖涓鏈嶅姟錛屼絾鏄娌¤劇疆瀹冧負榛樿ゅ惎鍔錛屽垯涓嬫¤繘鍏ョ郴緇熻繖涓鏈嶅姟渚濈劧鏄鍋滄㈢殑銆備笅闈㈡槸璁劇疆緗戠粶鏈嶅姟鍦ㄧ郴緇熷惎鍔ㄦ椂涔熷惎鍔ㄧ殑鏂規硶銆備嬌鐢╟hkconfig鍛戒護璁╃綉緇滄湇鍔″湪緋葷粺鍚鍔ㄧ駭鍒鏄2345鏃墮粯璁ゅ惎鍔ㄣ#chkconfig--level2345networkon絎涓夋ワ細淇鏀圭綉鍗℃枃浠秈fcfg-eth0淇鏀筰fcfg-eth0鏂囦歡錛岃劇疆ONBOOT鐨勫間負yes錛岃╃綉緇滄湇鍔″惎鍔ㄦ椂浣跨敤璇ョ綉鍗°傝劇疆BOOTPROTO鐨勫間負dhcp錛岃╃綉鍗′粠DHCP鏈嶅姟鍣ㄨ嚜鍔ㄨ幏鍙朓P鍦板潃銆#vi/etc/sysconfig/network-scripts/ifcfg-eth0ONBOOT=yesBOOTPROTO=dhcp鎬葷粨錛氶氬父鎯呭喌涓嬬涓夋ユ槸鏈閲嶈佺殑錛屽洜涓哄ぇ閮ㄥ垎Linux緋葷粺榛樿ょ綉緇滄湇鍔℃槸緋葷粺鍚鍔ㄦ椂涔熷惎鍔ㄧ殑錛岀綉鍗′篃鏄鍚鐢ㄧ殑錛屽彧瑕佽劇疆濂界涓夋ワ紝鐒跺悗浣跨敤涓嬮潰鐨勫懡浠ゅ惎鍔ㄧ綉緇滄湇鍔″氨OK銆#servicenetworkstart閰嶇疆闈欐両P鍦板潃涓婄綉涓庡姩鎬両P鍦板潃涓婄綉鍚屽嚭涓杈欙紝淇鏀筰fcfg-eth0錛岀劧鍚庣敤鍛戒護servicenetworkretart閲嶅惎緗戠粶鏈嶅姟銆侱EVICE=eth0
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS=8.8.8.8
BOOTPROTO=static
ONBOOT=yesdebian錛氱紪杈/etc/network/interfaces#
#Theprimarynetworkinterface
allow-
address192.168.1.36
netmask255.255.255.0
gateway192.168.1.10#鍏鍙哥殑緗戝叧鏄192.168.1.10錛屼竴鑸鏄192.168.1.1
淇濆瓨緙栬緫緇撴灉錛屽苟閲嶅惎緗戠粶鏈嶅姟
linux鍒涘緩鏈鍦扮鍙e拰IP鐢ㄤ粈涔堟寚浠わ紵
Linux緋葷粺鐢ㄥ懡浠netconfig鏉ュ壋寤烘湰鍦扮鍙e拰IP鍦板潃銆
linux鐨刵ode鑺傜偣鎬庝箞鑷鍔ㄨ幏鍙杋p鍦板潃錛
絎涓姝ワ細嬋媧葷綉鍗
緋葷粺瑁呭ソ鍚庨粯璁ょ殑緗戝崱鏄痚th0錛岀敤涓嬮潰鐨勫懡浠ゅ皢榪欏潡緗戝崱嬋媧匯
#ifconfigeth0up
絎浜屾ワ細璁劇疆緗戝崱榪涘叆緋葷粺鏃跺惎鍔
鎯寵佹瘡嬈″紑鏈哄氨鍙浠ヨ嚜鍔ㄨ幏鍙朓P鍦板潃涓婄綉錛屽氨瑕佽劇疆緗戠粶鏈嶅姟鍦ㄧ郴緇熷惎鍔ㄦ椂涔熷惎鍔ㄣ侺inux鏈変竴鐐逛笌windows涓嶅悓鐨勬槸寰堝氭湇鍔¢粯璁ゆ槸鍋滄㈢殑錛岃屼笖浣犲湪鏌愭′嬌鐢ㄨユ湇鍔℃椂鍚鍔ㄨ繖涓鏈嶅姟錛屼絾鏄娌¤劇疆瀹冧負榛樿ゅ惎鍔錛屽垯涓嬫¤繘鍏ョ郴緇熻繖涓鏈嶅姟渚濈劧鏄鍋滄㈢殑銆備笅闈㈡槸璁劇疆緗戠粶鏈嶅姟鍦ㄧ郴緇熷惎鍔ㄦ椂涔熷惎鍔ㄧ殑鏂規硶銆
浣跨敤chkconfig鍛戒護璁╃綉緇滄湇鍔″湪緋葷粺鍚鍔ㄧ駭鍒鏄2345鏃墮粯璁ゅ惎鍔ㄣ
#chkconfig--level2345networkon
絎涓夋ワ細淇鏀圭綉鍗℃枃浠秈fcfg-eth0
淇鏀筰fcfg-eth0鏂囦歡錛岃劇疆ONBOOT鐨勫間負yes錛岃╃綉緇滄湇鍔″惎鍔ㄦ椂浣跨敤璇ョ綉鍗°傝劇疆BOOTPROTO鐨勫間負dhcp錛岃╃綉鍗′粠DHCP鏈嶅姟鍣ㄨ嚜鍔ㄨ幏鍙朓P鍦板潃銆
#vi/etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
BOOTPROTO=dhcp
3. 鍦╨inux/unix緋葷粺涓嬫庝箞鏌ヨip鍦板潃錛
鍦↙inux/Unix緋葷粺涓嬫煡璇IP鍦板潃鐨勬柟娉曚富瑕佹湁浠ヤ笅鍑犵嶏細
涓銆佷嬌鐢ㄥ懡浠よ屽伐鍏鋒煡璇IP鍦板潃
1. 浣跨敤ifconfig鍛戒護
鍦ㄧ粓絝涓杈撳叆`ifconfig`錛屽洖杞﹀悗浣犲彲浠ョ湅鍒扮綉緇滄帴鍙g殑鐩稿叧淇℃伅錛屽寘鎷琁P鍦板潃銆
2. 浣跨敤ip鍛戒護
杈撳叆`ip addr`鎴朻ip address`錛屼篃鍙浠ユ煡鐪嬪埌IP鍦板潃銆
浜屻侀氳繃緗戠粶閰嶇疆鏂囦歡涓鏌ヨIP鍦板潃
1. 鏌ョ湅緗戠粶閰嶇疆鏂囦歡
鍦ㄤ竴浜汱inux鍙戣岀増涓錛岀綉緇滈厤緗淇℃伅浼氫繚瀛樺湪鏂囦歡涓錛屽俙/etc/network/interfaces`鎴朻/etc/sysconfig/network-scripts/`鐩褰曚笅鐨勭浉鍏蟲枃浠躲備綘鍙浠ヤ嬌鐢ㄦ枃鏈緙栬緫鍣ㄦ墦寮榪欎簺鏂囦歡鏌ョ湅IP鍦板潃銆
涓夈
鏌ヨ㈡柟娉曡В鏋錛
1. ifconfig鍛戒護錛氳繖鏄涓涓浼犵粺鐨勭綉緇滈厤緗鍛戒護錛岀敤浜庢樉紺哄拰閰嶇疆緗戠粶鎺ュ彛鐨勪俊鎮銆傚湪澶у氭暟Linux鍙戣岀増涓閮藉彲浠ヤ嬌鐢ㄣ傞氳繃璇ュ懡浠わ紝浣犲彲浠ョ湅鍒版瘡涓緗戠粶鎺ュ彛鐨処P鍦板潃銆
2. ip鍛戒護錛氳繖鏄涓涓鏇寸幇浠g殑緗戠粶閰嶇疆宸ュ叿錛岀敤浜庢樉紺哄拰鎿嶄綔璺鐢便佺綉緇滆懼囥佺瓥鐣ヨ礬鐢卞拰闅ч亾銆傚畠鍙浠ユ浛浠d紶緇熺殑ifconfig鍛戒護錛屽苟涓旀彁渚涗簡鏇村氱殑鍔熻兘鍜岄夐」銆傞氳繃`ip addr`鎴朻ip address`鍛戒護錛屼綘鍙浠ヨ交鏉懼湴鏌ョ湅IP鍦板潃銆
3. 鏌ョ湅緗戠粶閰嶇疆鏂囦歡錛氬湪涓浜汱inux鍙戣岀増涓錛岀綉緇滈厤緗淇℃伅琚淇濆瓨鍦ㄦ枃浠朵腑銆傝繖浜涙枃浠跺寘鍚浜嗙綉緇滄帴鍙g殑閰嶇疆淇℃伅錛屽寘鎷琁P鍦板潃銆佸瓙緗戞帺鐮併佺綉鍏崇瓑銆傞氳繃鐩存帴鏌ョ湅榪欎簺鏂囦歡錛屼綘鍙浠ユ壘鍒癐P鍦板潃淇℃伅銆備笉榪囷紝榪欑嶆柟娉曞彲鑳介渶瑕佷竴浜涘熀鏈鐨勬枃鏈澶勭悊鑳藉姏錛屽備嬌鐢ㄦ枃鏈緙栬緫鍣ㄨ繘琛屾悳緔㈠拰絳涢夈
浠ヤ笂灝辨槸鏌ヨLinux/Unix緋葷粺涓婭P鍦板潃鐨勬柟娉曘傛牴鎹瀹為檯鎯呭喌鍜屽彂琛岀増鐨勪笉鍚岋紝浣犲彲浠ラ夋嫨閫傚悎浣犵殑鏂規硶鏉ユ煡璇IP鍦板潃銆
4. linux濡備綍鏌ョ湅ip鍦板潃
linux濡備綍鏌ョ湅ip鍦板潃鍛錛屼笅闈㈠氨璁╂垜浠鏉ョ湅鐪嬪惂銆
1銆佹墦寮linux緋葷粺錛屽湪linux鐨勬岄潰鐨勭┖鐧藉勫彸鍑匯
2銆佸湪寮瑰嚭鐨勪笅鎷夐夐」閲岋紝鐐瑰嚮鎵撳紑緇堢銆
3銆佸彲浠ュ湪鎵撳紑鐨凩inux鏈嶅姟鍣ㄧ粓絝涓鐢ㄦ煡璇ip鍛戒護鏌ユ壘銆
4銆乴inux鏌ョ湅ip鍦板潃鐨勫懡浠や負ifconfig -a錛屽湪鍛戒護紿楀彛杈撳叆鐒跺悗鎸夊洖杞︺
5銆佹寜涓嬪洖杞﹀悗灝變細鍦ㄧ粓絝鍛戒護紿楀彛閲屾樉紺哄嚭ip鍦板潃銆