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簲鐢ㄧ▼搴忕殑锅ュ悍鐘跺喌锛屽苟杩涜屾晠闅沧帓镆ュ拰镐ц兘浼桦寲銆