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锛屽嵆鍙淇鏀