linux隧道
① 鐢ㄤ簬鏌ョ湅鍜岄厤緗緗戠粶ifconfig鍛戒護宸茶娣樻卑錛屼綘鐭ラ亾涓嬩竴浠g殑鍛戒護鍚
鍓嶈█
鏈鏂囦富瑕佷粙緇峮et-tools濂椾歡涓巌proute2濂椾歡鐨勫尯鍒銆
net-tools濂椾歡涓巌proute2濂椾歡鐨勫尯鍒
ifconfig銆乺oute銆乤rp鍜宯etstat絳夊懡浠よ屽伐鍏烽兘鏄痭et-toos濂椾歡鐨勫伐鍏烽泦錛岀敤浜庤В鍐崇綉緇滄晠闅溿俷et-tools璧鋒簮浜嶣SD鐨凾CP/IP宸ュ叿綆憋紝鍚庢潵鎴愪負鑰佺増鏈琇inux鍐呮牳涓閰嶇疆緗戠粶鍔熻兘鐨勫伐鍏楓備絾鑷2001騫磋搗錛孡inux紺懼尯宸茬粡瀵瑰叾鍋滄㈢淮鎶ゃ傚悓鏃訛紝涓浜汱inux鍙戣岀増姣斿侫rch linux鍜孋entOS/RHEL 7鍒欏凡緇忓畬鍏ㄦ姏寮冧簡net-tools錛屽彧鏀鎸乮proute2銆
iproute2鐨勫嚭鐜版棬鍦ㄤ粠鍔熻兘涓婂彇浠net-tools銆俷et-tools閫氳繃procfs(/proc)鍜宨octl緋葷粺璋冪敤鍘昏塊棶鍜屾敼鍙樺唴鏍哥綉緇滈厤緗錛岃宨proute2鍒欓氳繃netlink濂楁帴瀛楁帴鍙d笌鍐呮牳閫氳銆傛姏寮鎬ц兘鑰岃█錛宨proute2鐨勭敤鎴鋒帴鍙f瘮net-tools鏄懼緱鏇村姞鐩磋傘傛瘮濡傦紝鍚勭嶇綉緇滆祫婧愶紙濡俵ink銆両P鍦板潃銆佽礬鐢卞拰闅ч亾絳夛級鍧囦嬌鐢ㄥ悎閫傜殑瀵硅薄鎶借薄鍘誨畾涔夛紝浣垮緱鐢ㄦ埛鍙浣跨敤涓鑷寸殑璇娉曞幓綆$悊涓嶅悓鐨勫硅薄銆傚埌鐩鍓嶄負姝錛宨proute2浠嶅勫湪鎸佺畫寮鍙戜腑銆
絎旇呭己鐑堝緩璁鐢ㄦ埛搴旇ヤ嬌鐢╥proute2鍙栦唬浼犵粺鐨刵et-tools濂椾歡錛屽洜涓篿proute2鍙浠ュ仛寰堝歯et-tools鏃犳硶鍋氬埌鐨勪簨鎯呫
涓よ呭父瑙佸懡浠ゅ規瘮
net-toolsiproute2鍛戒護浣滅敤 arp -naip neigh鏌ョ湅MAC鍦板潃琛╥fconfigip link鏌ョ湅緗戝崱鍩烘湰淇℃伅ifconfig -aip addr show鏌ョ湅緗戠珯璇︾粏淇℃伅ifconfig --helpip help鏌ョ湅甯鍔╀俊鎮痠fconfig -sip -s link鏌ョ湅緗戝崱嫻侀噺浼犺緭淇℃伅ifconfig eth0 upip link set eth0 up鍚鐢ㄧ綉鍗ipmaddrip maddr鏌ョ湅緗戝崱鐩稿叧鐨凪AC鍦板潃琛╥ptunnelip tunnel鏌ョ湅闅ч亾淇℃伅netstatss鏌ョ湅絝鍙d嬌鐢ㄦ儏鍐祅etstat -iip -s link鏌ョ湅姣忓紶緗戝崱鐨勪俊鎮鍙婁紶杈撲俊鎮痭etstat -gip maddr鏌ョ湅寮犵綉鍗$殑浜屽眰鍙婁笁灞傞偦灞呬俊鎮痭etstat -lss -l鏌ョ湅鏈鏈虹殑鐩戝惉絝鍙netstat -rip route鏌ョ湅鏈鏈鴻礬鐢辮〃route addip route add娣誨姞闈欐佽礬鐢眗oute delip route del鍒犻櫎闈欐佽礬鐢眗oute -nip route show鏌ョ湅鏈鏈鴻礬鐢辮〃vconfigip link鏌ョ湅鏈鍦拌繛鎺ユ儏鍐
Linux鏌ョ湅MAC鍦板潃琛
? (172.16.87.174) 浣嶄簬 00:0c:29:2a:8e:23 [ether] 鍦 vmnet8
? (172.16.87.170) 浣嶄簬 鍦 vmnet8
? (172.16.87.179) 浣嶄簬 00:0c:29:2a:8e:23 [ether] 鍦 vmnet8
? (192.168.42.129) 浣嶄簬 da:1a:b5:a1:93:bc [ether] 鍦 enp0s20u1
鏌ョ湅緗戝崱鍩烘湰淇℃伅
鏌ョ湅緗戝崱鍩烘湰淇℃伅
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
link/ether 3c:97:0e:43:e8:bd brd ff:ff:ff:ff:ff:ff
3: wlp3s0: mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether 60:67:20:c7:be:00 brd ff:ff:ff:ff:ff:ff
4: vmnet1: mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
5: vmnet8: mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
12: enp0s20u1: mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
link/ether c6:34:99:3e:12:f9 brd ff:ff:ff:ff:ff:ff
Linux 鏌ョ湅ip 鍛戒護甯鍔╀俊鎮
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
vrf | sr }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec |
-f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
-4 | -6 | -I | -D | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch][filename] |
-rc[vbuf][size] | -n[etns] name | -a[ll] | -c[olor]}
Linux鏌ョ湅緗戝崱嫻侀噺浼犺緭淇℃伅
Linux鏌ョ湅緗戝崱嫻侀噺浼犺緭淇℃伅
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
300977974 305919 0 0 0 0
TX: bytes packets errors dropped carrier collsns
300977974 305919 0 0 0 0
2: eth0: mtu 1400 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether fa:16:3e:48:b5:08 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
107994934 965313 0 0 0 0
TX: bytes packets errors dropped carrier collsns
714725526 808580 0 0 0 0
https://www.linuxrumen.com/rmxx/804.html
② docker鍙浠ユ惌寤虹綉緇滃悧錛
瀹瑰櫒鏈嶅姟csk鏀鎸佺殑緗戠粶綾誨瀷鏈夛細Bridge妯″紡銆丠ost妯″紡銆佸瑰櫒瑕嗙洊緗戠粶銆
1銆丅ridge妯″紡
Bridge妯″紡錛屽叾瀹炲氨鏄甯哥敤鐨凩inux緗戞ˉ妯″紡錛屽瑰櫒鍦ㄥ畨瑁呭畬鎴愬悗錛屼細鍦ㄧ郴緇熶笂榛樿ゅ壋寤轟竴涓狶inux緗戞ˉ錛屽苟涓哄畠鍒嗛厤涓涓瀛愮綉錛屾瘮濡侱ocker錛岄拡瀵規瘡涓涓瀹瑰櫒錛屽潎涓哄叾鍒涘緩涓涓鉶氭嫙鐨勪互澶緗戣懼囷紝鍏朵腑涓絝浼氬叧鑱斿埌緗戞ˉ涓婏紝鍙︿竴絝鍒欎細閫氳繃鏄犲皠錛屾槧灝勫埌瀹瑰櫒鍐呴儴鐨勭綉緇滅┖闂翠腑錛岀劧鍚庡皢璇ヨ櫄鎷熺綉孌典腑鐨勪竴涓狪P鍦板潃鍒嗛厤緇欐敼鎺ュ彛銆
瀹瑰櫒鏈嶅姟鐨勫姛鑳
1銆佸瑰櫒緙栨帓錛氬瑰櫒鏈嶅姟鎻愪緵浜嗚嚜鍔ㄥ寲鐨勫瑰櫒緙栨帓鍔熻兘錛屽彲浠ユ牴鎹鐢ㄦ埛瀹氫箟鐨勮勫垯鍜岀瓥鐣ヨ嚜鍔ㄩ儴緗插拰綆$悊瀹瑰櫒銆傝繖鍖呮嫭瀹瑰櫒鐨勫壋寤恆佽皟搴︺佹墿灞曞拰鍥炴敹絳夋搷浣溿
2銆佽嚜鍔ㄥ寲鎵╃緝瀹癸細瀹瑰櫒鏈嶅姟鍙浠ユ牴鎹鐢ㄦ埛鐨勯渶奼傝嚜鍔ㄦ墿灞曟垨緙╁噺瀹瑰櫒鐨勬暟閲忥紝浠ラ傚簲涓嶆柇鍙樺寲鐨勬祦閲忛渶奼傘傝繖鍙浠ョ『淇濆簲鐢ㄧ▼搴忓嬬粓鍏鋒湁瓚沖熺殑璧勬簮鏉ュ勭悊璐熻澆錛屽苟鎻愰珮搴旂敤紼嬪簭鐨勫彲鐢ㄦу拰鎬ц兘銆
3銆佺綉緇滃拰瀛樺偍綆$悊錛氬瑰櫒鏈嶅姟鎻愪緵浜嗙綉緇滃拰瀛樺偍綆$悊鍔熻兘錛屽彲浠ヤ負瀹瑰櫒鍒嗛厤鐙絝嬬殑緗戠粶鍦板潃鍜屽瓨鍌ㄥ嵎銆傝繖鏍鳳紝瀹瑰櫒涔嬮棿鍙浠ラ氳繃緗戠粶閫氫俊錛屽苟涓斿彲浠ユ寔涔呭寲鍦板瓨鍌ㄥ拰璁塊棶鏁版嵁銆
4銆佺洃鎺у拰鏃ュ織錛氬瑰櫒鏈嶅姟鎻愪緵浜嗙洃鎺у拰鏃ュ織鍔熻兘錛屽彲浠ュ疄鏃剁洃嫻嬪瑰櫒鐨勮繍琛岀姸鎬佸拰鎬ц兘鎸囨爣錛屽苟璁板綍瀹瑰櫒鐨勬棩蹇椾俊鎮銆傝繖鏈夊姪浜庣敤鎴蜂簡瑙e簲鐢ㄧ▼搴忕殑鍋ュ悍鐘跺喌錛屽苟榪涜屾晠闅滄帓鏌ュ拰鎬ц兘浼樺寲銆