linux網卡配置網關
A. linux下如何設置網關
一、打開終端。你可以從邊欄打開終端程序,或按下<br/>Ctrl+<br/>Alt+<br/>T組合鍵來打開它。
B. linux緗戝叧鍦板潃鎬庝箞鏌linux緗戝叧鍦板潃
linux緗戝叧閰嶇疆鍛戒護錛
linux閰嶇疆緗戝叧鏈夊氱嶅懡浠
1.閰嶇疆緗戝叧錛
vi/etc/sysconfig/network
鍔犲叆錛欸ATEWAY=192.168.0.1
2.ip鍦板潃澶勯厤緗緗戝叧錛
vi/etc/sysconfig/network-scripts/ifcfg-eth0
鍔犲叆錛欸ATEWAY=192.168.0.1
3.鍛戒護琛岄厤緗緗戝叧
routeadddefaultgw192168.0.1
絎涓夌嶆柟娉曢厤緗鍚庡彲浠ョ珛椹鐢熸晥錛屼絾緋葷粺閲嶅惎鍚庡皢闇瑕侀噸鏂伴厤緗錛岃屽墠涓ょ嶆柟娉曢渶瑕侀厤緗鍚庨噸鏂板惎鍔ㄧ綉鍗℃墠鑳藉墿涓嬶紝緋葷粺閲嶅惎鍚庢棤闇鍐嶆¢厤緗錛
linux緋葷粺錛岃兘PING閫氱綉鍏籌紝浣唒ing涓嶉氬叾浠栧湴鍧錛屽寘鎷鍚屼竴緗戞電殑鍦板潃錛岃烽棶鏄鎬庝箞鍥炰簨錛
鍦↙inux緋葷粺涓嬫槸鍙浠ユe父ping閫氱綉鍏崇殑錛岀劧鍚巔ing閫氫箣鍚庡傛灉鍙戠幇銆俻ing涓嶉氬叾浠栧湴鍧鐨勮瘽錛岄偅鍙鑳芥槸鍥犱負閭d釜鍦板潃璁劇疆浜嗛檺鍒訛紝鎵浠ュ艱嚧浣犺繖杈規嫾涓嶉氾紝鍙堟垨鑰呮槸榪炴帴涓婄殑闂棰樺艱嚧鐨勩
鉶氭嫙鏈虹綉鍏蟲槸鍟ワ紵涓巚mware錛寃indows錛岃櫄鎷熺殑Linux璋佹湁鍏籌紵鎬庝箞鏌ョ湅錛
緗戝叧錛屽氨鏄璁$畻鏈虹綉緇滄墍鍦ㄧ殑澶ч棬銆
鉶氭嫙鏈虹綉鍏籌紝灝辨槸鉶氭嫙鏈虹幆澧冧笅鐨勬墍璁劇珛鐨勮櫄鎷熺綉緇滃ぇ闂錛涘弽涔嬶紝鐗╃悊鏈虹郴緇熶篃鏄涓鏍風殑錛涚敤閫氫織鐐圭殑璇濊詫紝鐗╃悊鏈猴紝鉶氭嫙鏈猴紝灝辮薄浜虹殑涓や釜涓栫晫銆傜簿紲炰笘鐣岋紝鍜岀幇瀹炰笘鐣岋紱linux澶氱綉鍗$綉鍏沖彧鑳芥湁涓涓鍚楋紵
1)鍙淇濈暀涓涓榛樿ょ綉鍏172.20.0.12)routeadd-net192.168.2.0/24gw192.168.1.1鍦/etc/rc.local鏂囨湰鏈鍚庢坊鍔犱笂闈涓鍙ユ棦姘鎬箙鐢熸晥
C. linux閰嶇疆緗戝叧鍜宒nslinuxdns緗戝叧
linux鐨剆enbmail鎬庝箞璁劇疆dns錛
vi/etc/sysconfig/network-script/ifcfg-緗戝崱鍚嶈繘鍏ョ綉緇滅紪杈
IPADDR=浣犵殑IP鍦板潃
NETMASK=瀛愮綉鎺╃爜
GATEWAY=緗戝叧
DNS1=浣犺佽劇疆鐨凞NS鏈嶅姟鍣↖P鍦板潃
浜屻乿i/etc/resolv.conf
娣誨姞涓鏉
nameserver8.8.8.8#8.8.8.8渚挎槸浣犻渶瑕佽劇疆鐨凞NS鏈嶅姟鍣ㄥ湴鍧
linux鎬庢牱璁劇疆澶栫綉ip銆佺綉鍏熾佹帺鐮侊紵
1銆佸懡浠よ屼嬌鐢╲i緙栬緫鍣ㄦ墦寮緗戝崱閰嶇疆鏂囦歡ifcfg-eth0錛歷i/etc/sysconfig/network-scripts/ifcfg-eth02銆佸紑濮嬬紪杈戱紝濉鍐檌p鍦板潃銆佸瓙緗戞帺鐮併佺綉鍏熾丏NS絳夈
鍏朵腑鈥滅孩妗嗗唴鐨勪俊鎮鈥濇槸蹇呴』寰楁湁鐨勩3銆佺紪杈戝畬鍚庯紝淇濆瓨閫鍑恆4銆侀噸鍚緗戠粶鏈嶅姟銆俿ervicenetworkrestart鎴/etc/init.d/networkrestart5銆乸ing緗戝叧錛宲ing澶栫綉榪涜屾祴璇曘傞兘鑳絧ing閫氳〃紺虹綉緇滄e父銆SUSELinuxEnterpriseServer璁劇疆IP鍦板潃銆佺綉鍏熾丏NS鐨勬柟娉曪紵
灝嗕笅闈㈢殑浠g爜鏀規垚鐩稿簲鐨処P錛岀劧鍚庡嶅埗鍒扮數鑴戜腑浠繪剰涓涓猼xt涓錛屽悗緙鏀逛負bat錛屼互鍚庨渶瑕佽劇疆鐨勬椂鍊欏弻鍑昏繍琛屼竴涓媌at鏂囦歡鍗沖彲
D. 淇鏀筶inuxip鍦板潃緗戝叧淇鏀筶inuxip鍦板潃
linux璁劇疆緗戝崱ip鍦板潃錛
鍦╟entos鍛戒護琛岀晫闈㈡墦寮緗戝崱閰嶇疆鏂囦歡錛岀劧鍚庝慨鏀歸厤緗鏂囦歡涓鍙傛暟絳変簬none鎴杝tai錛屾坊鍔爄p鍦板潃鐨勫弬鏁拌劇疆錛岀劧鍚庝繚瀛橀鍑猴紝systemctlrestartnetwork閲嶅惎緗戠粶鏈嶅姟錛岃╅厤緗鏂囦歡鐢熸晥錛屽懡浠よ岀晫闈㈡墽琛宨focnfig鏌ョ湅淇鏀瑰悗鏂扮殑闈欐乮p鍦板潃灝卞彲浠ヤ簡銆
宓屽叆寮廘inux寮鍙戜腑濡備綍淇鏀笽P錛
鎴戠敤鐨凷BC2410鐨勫紑鍙戞澘錛2.4鐗圠inux鍐呮牳銆傝佷慨鏀笽P鍦板潃鍙闇瑕佸惎鍔ㄥ紑鍙戞澘騫舵壘鍒/etc/init.d/rcS錛屽湪榪欓噷鍙浠ユ壘鍒/sbin/ifconfigeth0錛屼慨鏀瑰悗闈㈢殑IP鍦板潃灝卞彲浠ヤ簡銆傚悓鏃跺彲浠ヤ慨鏀逛富鏈哄悕錛氬嵆淇鏀/etc/sysconfig/HOSTNAME銆
linux緋葷粺錛屽備綍淇鏀箇ifi鐨剗p鍦板潃錛
閫氳繃嫻忚堝櫒鎵撳紑璺鐢卞櫒鐨勭$悊鍚庡彴錛岀劧鍚庤繘琛岃劇疆銆
LINUX淇鏀笽P,姘鎬箙鐢熸晥鍛戒護鏂規硶錛
鍙閫氳繃淇鏀歸厤緗鏂囦歡ifcfg-eth0錛屽叿浣撴ラゅ備笅:
1.鐢╲i鎵撳紑鏂囦歡:
vi/etc/sysconfig/network-scripts/ifcfg-eth0
2.闇娣誨姞鎴栦慨鏀圭殑鍐呭(娉ㄦ剰娑夊強鍦板潃鐨勮鋒牴鎹浣犵殑瀹為檯鎯呭喌閰屾儏璋冩暣)錛
DEVICE=eth0
HWADDR=00:0C:29:5A:22:EF
TYPE=Ethernet
UUID=53c1c149-e126-443e-93fd-db592deb339e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static#璁劇疆闈欐両P
IPADDR=192.168.10.24
NETMASK=255.255.255.0
BROADCAST=192.168.10.255
GATEWAY=192.168.10.2#璁劇疆浣犺嚜宸辯殑緗戝叧
3.閫鍑猴紝淇濆瓨鎵鍋氱殑淇鏀廣
linux濡備綍淇鏀規渶鍚庣櫥褰昳p錛
鎵撳紑linux錛岄夋嫨淇鏀規渶鍚庣櫥褰昳p錛屽嵆鍙淇鏀