{"id":41403,"date":"2025-06-02T07:15:55","date_gmt":"2025-06-01T23:15:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/41403.html"},"modified":"2025-06-02T07:15:55","modified_gmt":"2025-06-01T23:15:55","slug":"ubuntu20-04%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%bc%80%e5%90%af%e8%b7%af%e7%94%b1%e8%bd%ac%e5%8f%91%e8%ae%a9%e5%b1%80%e5%9f%9f%e7%bd%91%e5%86%85%e5%85%b6%e4%bb%96%e7%94%b5%e8%84%91%e9%80%9a%e8%bf%87%e8%af%a5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/41403.html","title":{"rendered":"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51"},"content":{"rendered":"<p>\u8981\u8ba9\u4f60\u7684 Ubuntu\u4f5c\u4e3a\u8def\u7531\u5668&#xff0c;\u901a\u8fc7 Wi-Fi \u4e0a\u7f51&#xff0c;\u5e76\u7ed9\u8fde\u63a5\u5230 UsbNetwork \u7684\u8bbe\u5907\u63d0\u4f9b\u7f51\u7edc&#xff0c;\u9700\u8981\u505a\u4ee5\u4e0b\u914d\u7f6e&#xff1a;<\/p>\n<hr \/>\n<h3>1. \u7f51\u7edc\u62d3\u6251<\/h3>\n<p>[\u4e92\u8054\u7f51] \u2190 (Wi-Fi, wlo1) \u2192 [Ubuntu] \u2190 (USB\u7f51\u7edc\/USB\u4ee5\u592a\u7f51, UsbNetwork) \u2192 [\u8bbe\u5907]<\/p>\n<ul>\n<li>Ubuntu&#xff1a;\n<ul>\n<li>Wi-Fi&#xff08;wlo1&#xff09;\u5df2\u8fde\u63a5\u4e92\u8054\u7f51&#xff08;\u6bd4\u5982\u5bb6\u5ead\u8def\u7531\u5668&#xff09;\u3002<\/li>\n<li>USB\u7f51\u7edc&#xff08;UsbNetwork&#xff09;\u8fde\u63a5\u8bbe\u5907&#xff08;IP: 192.168.2.x&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8bbe\u5907&#xff1a;\n<ul>\n<li>\u9ed8\u8ba4\u7f51\u5173\u6307\u5411 192.168.2.2&#xff08;Ubuntu \u7684 UsbNetwork IP&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250601231554-683cdf2a581cf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250601231554-683cdf2a717fa.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2. \u5728 Ubuntu \u4e0a\u914d\u7f6e\u8def\u7531\u548c NAT<\/h3>\n<h4>(1) \u542f\u7528 IP \u8f6c\u53d1<\/h4>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">sysctl<\/span> <span class=\"token parameter variable\">-w<\/span> <span class=\"token assign-left variable\">net.ipv4.ip_forward<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><\/p>\n<p>\u6c38\u4e45\u751f\u6548&#xff08;\u7f16\u8f91 \/etc\/sysctl.conf&#xff09;&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;net.ipv4.ip_forward&#061;1&#034;<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">sudo<\/span> <span class=\"token function\">tee<\/span> <span class=\"token parameter variable\">-a<\/span> \/etc\/sysctl.conf<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">sysctl<\/span> <span class=\"token parameter variable\">-p<\/span><\/p>\n<h4>(2) \u8bbe\u7f6e NAT&#xff08;\u8ba9\u8bbe\u5907\u901a\u8fc7 Wi-Fi \u4e0a\u7f51&#xff09;<\/h4>\n<p><span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-t<\/span> nat <span class=\"token parameter variable\">-A<\/span> POSTROUTING <span class=\"token parameter variable\">-o<\/span> wlo1 <span class=\"token parameter variable\">-j<\/span> MASQUERADE<br \/>\n<span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-A<\/span> FORWARD <span class=\"token parameter variable\">-i<\/span> eno1 <span class=\"token parameter variable\">-o<\/span> wlo1 <span class=\"token parameter variable\">-j<\/span> ACCEPT<br \/>\n<span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-A<\/span> FORWARD <span class=\"token parameter variable\">-i<\/span> wlo1 <span class=\"token parameter variable\">-o<\/span> eno1 <span class=\"token parameter variable\">-m<\/span> state <span class=\"token parameter variable\">&#8211;state<\/span> RELATED,ESTABLISHED <span class=\"token parameter variable\">-j<\/span> ACCEPT<\/p>\n<p>\u4fdd\u5b58 iptables \u89c4\u5219&#xff08;\u9632\u6b62\u91cd\u542f\u5931\u6548&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> iptables-persistent<br \/>\n<span class=\"token function\">sudo<\/span> netfilter-persistent save<\/p>\n<p>\u8fd9\u4e09\u6761\u5173\u952e\u7684\u547d\u4ee4\u89e3\u91ca\u5982\u4e0b&#xff1a; \u5f53\u7136&#xff01;\u8fd9\u4e09\u6761 iptables \u547d\u4ee4\u662f\u914d\u7f6e NAT&#xff08;\u7f51\u7edc\u5730\u5740\u8f6c\u6362&#xff09; \u548c \u6d41\u91cf\u8f6c\u53d1 \u7684\u6838\u5fc3\u89c4\u5219&#xff0c;\u7528\u4e8e\u8ba9\u8fde\u63a5\u5230 eno1&#xff08;\u6709\u7ebf\u7f51\u7edc&#xff09;\u7684\u8bbe\u5907\u901a\u8fc7 wlo1&#xff08;Wi-Fi&#xff09;\u8bbf\u95ee\u4e92\u8054\u7f51\u3002\u4ee5\u4e0b\u662f\u6bcf\u6761\u547d\u4ee4\u7684\u8be6\u7ec6\u89e3\u91ca&#xff1a;<\/p>\n<hr \/>\n<h4>1. sudo iptables -t nat -A POSTROUTING -o wlo1 -j MASQUERADE<\/h4>\n<h5>\u4f5c\u7528<\/h5>\n<p>\u542f\u7528 \u6e90\u5730\u5740\u8f6c\u6362&#xff08;SNAT&#xff09;&#xff0c;\u5c06\u6765\u81ea eno1&#xff08;\u5185\u7f51&#xff09;\u7684\u6d41\u91cf\u901a\u8fc7 wlo1&#xff08;\u5916\u7f51&#xff09;\u8f6c\u53d1\u65f6&#xff0c;\u81ea\u52a8\u4fee\u6539\u6570\u636e\u5305\u7684 \u6e90IP\u5730\u5740&#xff0c;\u4f7f\u5176\u770b\u8d77\u6765\u662f\u4ece Ubuntu \u7684 wlo1 \u63a5\u53e3\u53d1\u51fa\u7684\u3002<\/p>\n<h5>\u5173\u952e\u70b9<\/h5>\n<ul>\n<li>-t nat&#xff1a;\u64cd\u4f5c NAT \u8868&#xff08;\u4e13\u95e8\u7528\u4e8e\u5730\u5740\u8f6c\u6362&#xff09;\u3002<\/li>\n<li>-A POSTROUTING&#xff1a;\u5728\u6570\u636e\u5305 \u79bb\u5f00\u672c\u673a\u524d&#xff08;Post-Routing&#xff09;\u4fee\u6539\u6e90IP\u3002<\/li>\n<li>-o wlo1&#xff1a;\u4ec5\u5bf9\u4ece wlo1&#xff08;Wi-Fi&#xff09;\u53d1\u51fa\u7684\u6570\u636e\u5305\u751f\u6548\u3002<\/li>\n<li>-j MASQUERADE&#xff1a;\u52a8\u6001\u5c06\u5185\u7f51\u8bbe\u5907\u7684\u79c1\u6709IP&#xff08;\u5982 192.168.2.x&#xff09;\u66ff\u6362\u4e3a wlo1 \u7684\u5f53\u524dIP&#xff08;\u5982 192.168.0.x&#xff09;\u3002<\/li>\n<\/ul>\n<h5>\u4e3a\u4ec0\u4e48\u9700\u8981&#xff1f;<\/h5>\n<ul>\n<li>\u5185\u7f51\u8bbe\u5907&#xff08;eno1 \u4e0b\u7684 192.168.2.x&#xff09;\u7684IP\u662f\u79c1\u6709\u5730\u5740&#xff0c;\u65e0\u6cd5\u5728\u4e92\u8054\u7f51\u4e0a\u8def\u7531\u3002<\/li>\n<li>\u901a\u8fc7 MASQUERADE&#xff0c;\u5916\u7f51\u670d\u52a1\u5668\u4f1a\u5c06\u54cd\u5e94\u5305\u53d1\u56de wlo1 \u7684IP&#xff0c;\u518d\u7531 Ubuntu \u8f6c\u53d1\u7ed9\u5185\u7f51\u8bbe\u5907\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>2. sudo iptables -A FORWARD -i eno1 -o wlo1 -j ACCEPT<\/h4>\n<h5>\u4f5c\u7528<\/h5>\n<p>\u5141\u8bb8\u4ece eno1&#xff08;\u5185\u7f51&#xff09;\u8fdb\u5165\u3001\u4ece wlo1&#xff08;\u5916\u7f51&#xff09;\u79bb\u5f00\u7684\u6d41\u91cf \u901a\u8fc7\u9632\u706b\u5899\u3002<\/p>\n<h5>\u5173\u952e\u70b9<\/h5>\n<ul>\n<li>-A FORWARD&#xff1a;\u64cd\u4f5c FORWARD \u94fe&#xff08;\u63a7\u5236\u8f6c\u53d1\u7684\u6570\u636e\u5305&#xff09;\u3002<\/li>\n<li>-i eno1 -o wlo1&#xff1a;\u5339\u914d \u8fdb\u5165 eno1 \u4e14\u4ece wlo1 \u51fa\u53bb \u7684\u6d41\u91cf\u3002<\/li>\n<li>-j ACCEPT&#xff1a;\u5141\u8bb8\u8fd9\u4e9b\u6d41\u91cf\u901a\u8fc7\u3002<\/li>\n<\/ul>\n<h5>\u4e3a\u4ec0\u4e48\u9700\u8981&#xff1f;<\/h5>\n<ul>\n<li>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;Linux \u7684\u9632\u706b\u5899\u4f1a\u963b\u6b62\u8f6c\u53d1\u6d41\u91cf\u3002<\/li>\n<li>\u6b64\u89c4\u5219\u660e\u786e\u5141\u8bb8\u5185\u7f51\u8bbe\u5907\u8bbf\u95ee\u5916\u7f51\u7684\u8bf7\u6c42\u901a\u8fc7\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>3. sudo iptables -A FORWARD -i wlo1 -o eno1 -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT<\/h4>\n<h5>\u4f5c\u7528<\/h5>\n<p>\u5141\u8bb8\u4ece wlo1&#xff08;\u5916\u7f51&#xff09;\u8fd4\u56de\u7684\u3001\u4e0e\u5df2\u6709\u8fde\u63a5\u76f8\u5173\u7684\u6d41\u91cf \u901a\u8fc7\u9632\u706b\u5899&#xff0c;\u56de\u5230 eno1&#xff08;\u5185\u7f51&#xff09;\u3002<\/p>\n<h5>\u5173\u952e\u70b9<\/h5>\n<ul>\n<li>-i wlo1 -o eno1&#xff1a;\u5339\u914d \u8fdb\u5165 wlo1 \u4e14\u4ece eno1 \u51fa\u53bb \u7684\u6d41\u91cf\u3002<\/li>\n<li>-m state &#8211;state RELATED,ESTABLISHED&#xff1a;\u4ec5\u5141\u8bb8 \u5df2\u5efa\u7acb\u7684\u8fde\u63a5&#xff08;\u5982\u5185\u7f51\u8bbe\u5907\u53d1\u8d77\u7684\u8bf7\u6c42\u7684\u54cd\u5e94\u5305&#xff09;\u6216 \u76f8\u5173\u7684\u65b0\u8fde\u63a5&#xff08;\u5982FTP\u7684\u6570\u636e\u8fde\u63a5&#xff09;\u3002<\/li>\n<li>-j ACCEPT&#xff1a;\u5141\u8bb8\u8fd9\u4e9b\u6d41\u91cf\u901a\u8fc7\u3002<\/li>\n<\/ul>\n<h5>\u4e3a\u4ec0\u4e48\u9700\u8981&#xff1f;<\/h5>\n<ul>\n<li>\u786e\u4fdd\u5916\u7f51\u670d\u52a1\u5668\u8fd4\u56de\u7684\u54cd\u5e94\u5305\u80fd\u56de\u5230\u5185\u7f51\u8bbe\u5907\u3002<\/li>\n<li>\u963b\u6b62\u4ece\u5916\u7f51\u4e3b\u52a8\u53d1\u8d77\u7684\u975e\u6cd5\u8fde\u63a5&#xff08;\u4ec5\u5141\u8bb8\u201c\u56de\u5305\u201d&#xff09;&#xff0c;\u63d0\u5347\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u4e09\u8005\u7684\u534f\u4f5c\u6d41\u7a0b<\/h4>\n<li>\u5185\u7f51\u8bbe\u5907&#xff08;192.168.2.100&#xff09;\u8bbf\u95ee 8.8.8.8&#xff1a;\n<ul>\n<li>\u6570\u636e\u5305\u8fdb\u5165 eno1 \u2192 \u88ab FORWARD \u89c4\u5219\u653e\u884c \u2192 \u7ecf\u8fc7 POSTROUTING \u65f6\u6e90IP\u88ab\u6539\u4e3a wlo1 \u7684IP \u2192 \u4ece wlo1 \u53d1\u51fa\u3002<\/li>\n<\/ul>\n<\/li>\n<li>Google \u670d\u52a1\u5668 \u8fd4\u56de\u54cd\u5e94\u5305&#xff1a;\n<ul>\n<li>\u6570\u636e\u5305\u8fdb\u5165 wlo1 \u2192 \u88ab\u72b6\u6001\u68c0\u6d4b\u89c4\u5219\u8bc6\u522b\u4e3a ESTABLISHED \u2192 \u653e\u884c\u5e76\u8f6c\u53d1\u5230 eno1 \u2192 \u5230\u8fbe\u5185\u7f51\u8bbe\u5907\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>\u9a8c\u8bc1\u89c4\u5219\u662f\u5426\u751f\u6548<\/h4>\n<p><span class=\"token comment\"># \u67e5\u770bNAT\u89c4\u5219<\/span><br \/>\n<span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-t<\/span> nat <span class=\"token parameter variable\">-L<\/span> <span class=\"token parameter variable\">-v<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770bFORWARD\u89c4\u5219<\/span><br \/>\n<span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-L<\/span> FORWARD <span class=\"token parameter variable\">-v<\/span><\/p>\n<p>\u8f93\u51fa\u793a\u4f8b&#xff1a;<\/p>\n<p>Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\n   10  1200 MASQUERADE  all  &#8212;  any    wlo1    192.168.2.0\/24      anywhere<\/p>\n<p>Chain FORWARD (policy DROP 0 packets, 0 bytes)<br \/>\n pkts bytes target     prot opt in     out     source               destination<br \/>\n   15  1800 ACCEPT     all  &#8212;  eno1   wlo1    anywhere             anywhere<br \/>\n   20  2400 ACCEPT<\/p>\n<p>### **(3) \u914d\u7f6e DHCP&#xff08;\u53ef\u9009&#xff0c;\u81ea\u52a8\u5206\u914d IP&#xff09;**<br \/>\n\u5982\u679c\u4f60\u7684\u8bbe\u5907\u9700\u8981\u81ea\u52a8\u83b7\u53d6 IP&#xff0c;\u53ef\u4ee5\u5728 Ubuntu \u4e0a\u5b89\u88c5 &#096;isc-dhcp-server&#096;&#xff1a;<br \/>\n&#096;&#096;&#096;bash<br \/>\nsudo apt install isc-dhcp-server<\/p>\n<p>\u7f16\u8f91 \/etc\/dhcp\/dhcpd.conf&#xff1a;<\/p>\n<p>subnet 192.168.2.0 netmask 255.255.255.0 {<br \/>\n  range 192.168.2.100 192.168.2.200;<br \/>\n  option routers 192.168.2.2;  # \u7f51\u5173\u6307\u5411 Ubuntu<br \/>\n  option domain-name-servers 8.8.8.8, 8.8.4.4;<br \/>\n}<\/p>\n<p>\u6307\u5b9a\u76d1\u542c\u63a5\u53e3&#xff08;\u7f16\u8f91 \/etc\/default\/isc-dhcp-server&#xff09;&#xff1a;<\/p>\n<p>INTERFACESv4&#061;&#034;eno1&#034;<\/p>\n<p>\u542f\u52a8 DHCP \u670d\u52a1&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl restart isc-dhcp-server<\/p>\n<hr \/>\n<h3>3. \u8bbe\u5907\u7aef\u914d\u7f6e<\/h3>\n<h4>(1) \u81ea\u52a8\u83b7\u53d6 IP&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<ul>\n<li>\u786e\u4fdd\u8bbe\u5907\u8bbe\u7f6e\u4e3a DHCP \u81ea\u52a8\u83b7\u53d6 IP\u3002<\/li>\n<li>\u8bbe\u5907\u5e94\u8be5\u4f1a\u5f97\u5230 192.168.2.x \u7684 IP&#xff0c;\u7f51\u5173\u662f 192.168.2.2\u3002<\/li>\n<\/ul>\n<h4>(2) \u624b\u52a8\u8bbe\u7f6e IP&#xff08;\u5982\u679c\u6ca1\u6709 DHCP&#xff09;<\/h4>\n<ul>\n<li>IP: 192.168.2.x&#xff08;\u5982 192.168.2.100&#xff09;<\/li>\n<li>\u5b50\u7f51\u63a9\u7801: 255.255.255.0<\/li>\n<li>\u7f51\u5173: 192.168.2.2<\/li>\n<li>DNS: 8.8.8.8&#xff08;\u6216\u4f60\u7684 ISP DNS&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>4. \u6d4b\u8bd5\u7f51\u7edc<\/h3>\n<h4>(1) \u5728\u8bbe\u5907\u4e0a\u6d4b\u8bd5<\/h4>\n<p><span class=\"token function\">ping<\/span> <span class=\"token number\">192.168<\/span>.2.2      <span class=\"token comment\"># \u6d4b\u8bd5\u5230 Ubuntu \u7684\u8fde\u901a\u6027<\/span><br \/>\n<span class=\"token function\">ping<\/span> <span class=\"token number\">8.8<\/span>.8.8          <span class=\"token comment\"># \u6d4b\u8bd5\u5916\u7f51\u8bbf\u95ee<\/span><\/p>\n<ul>\n<li>\u5982\u679c 8.8.8.8 \u80fd\u901a&#xff0c;\u4f46\u7f51\u9875\u6253\u4e0d\u5f00&#xff0c;\u68c0\u67e5 DNS \u8bbe\u7f6e&#xff08;\u8bbe\u5907\u7aef\u624b\u52a8\u8bbe 8.8.8.8&#xff09;\u3002<\/li>\n<\/ul>\n<h4>(2) \u5728 Ubuntu \u4e0a\u68c0\u67e5 NAT<\/h4>\n<p><span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-t<\/span> nat <span class=\"token parameter variable\">-L<\/span> <span class=\"token parameter variable\">-v<\/span>  <span class=\"token comment\"># \u67e5\u770b NAT \u89c4\u5219\u662f\u5426\u751f\u6548<\/span><\/p>\n<p>\u8f93\u51fa\u793a\u4f8b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250601231554-683cdf2a85f87.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<hr \/>\n<h3>5. \u5e38\u89c1\u95ee\u9898<\/h3>\n<h4>(1) \u8bbe\u5907\u80fd ping \u901a\u7f51\u5173&#xff0c;\u4f46\u65e0\u6cd5\u4e0a\u7f51<\/h4>\n<ul>\n<li>\u68c0\u67e5 Ubuntu \u7684 wlan0 \u662f\u5426\u6b63\u5e38\u8054\u7f51&#xff1a;<span class=\"token function\">ping<\/span> <span class=\"token number\">8.8<\/span>.8.8  <span class=\"token comment\"># \u5728 Ubuntu \u4e0a\u6d4b\u8bd5<\/span>\n <\/li>\n<li>\u68c0\u67e5 NAT \u89c4\u5219&#xff1a;<span class=\"token function\">sudo<\/span> iptables <span class=\"token parameter variable\">-t<\/span> nat <span class=\"token parameter variable\">-L<\/span>  <span class=\"token comment\"># \u786e\u4fdd POSTROUTING \u6709 MASQUERADE<\/span>\n <\/li>\n<\/ul>\n<h4>(2) DHCP \u4e0d\u5206\u914d IP<\/h4>\n<ul>\n<li>\u68c0\u67e5 isc-dhcp-server \u662f\u5426\u8fd0\u884c&#xff1a;<span class=\"token function\">sudo<\/span> systemctl status isc-dhcp-server\n <\/li>\n<li>\u68c0\u67e5 UsbNetwork \u662f\u5426\u5df2\u5206\u914d IP&#xff1a;<span class=\"token function\">ip<\/span> a show UsbNetwork\n <\/li>\n<\/ul>\n<h4>(3) \u91cd\u542f\u540e\u5931\u6548<\/h4>\n<ul>\n<li>\u786e\u4fdd iptables \u89c4\u5219\u5df2\u4fdd\u5b58&#xff1a;<span class=\"token function\">sudo<\/span> netfilter-persistent save\n <\/li>\n<li>\u786e\u4fdd net.ipv4.ip_forward&#061;1 \u5df2\u5199\u5165 \/etc\/sysctl.conf\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>6. \u603b\u7ed3<\/h3>\n<table>\n<tr>\u6b65\u9aa4\u547d\u4ee4\/\u914d\u7f6e\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>1. \u542f\u7528\u8f6c\u53d1<\/td>\n<td>net.ipv4.ip_forward&#061;1<\/td>\n<td>\u8ba9 Ubuntu \u8f6c\u53d1\u6d41\u91cf<\/td>\n<\/tr>\n<tr>\n<td>2. \u8bbe\u7f6e NAT<\/td>\n<td>iptables -t nat -A POSTROUTING &#8230;<\/td>\n<td>\u8ba9\u8bbe\u5907\u901a\u8fc7 Wi-Fi \u4e0a\u7f51<\/td>\n<\/tr>\n<tr>\n<td>3. \u914d\u7f6e DHCP<\/td>\n<td>isc-dhcp-server<\/td>\n<td>\u81ea\u52a8\u5206\u914d IP<\/td>\n<\/tr>\n<tr>\n<td>4. \u8bbe\u5907\u8fde\u63a5<\/td>\n<td>\u624b\u52a8\u6216\u81ea\u52a8\u83b7\u53d6 IP<\/td>\n<td>\u786e\u4fdd\u7f51\u5173\u6307\u5411 192.168.2.2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u6837&#xff0c;\u4f60\u7684\u8bbe\u5907\u5c31\u80fd\u901a\u8fc7 Ubuntu \u7684 Wi-Fi \u4e0a\u7f51\u4e86&#xff01;&#x1f680;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb921\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8fd9\u6837\uff0c\u4f60\u7684\u8bbe\u5907\u5c31\u80fd\u901a\u8fc7 Ubuntu \u7684 Wi-Fi \u4e0a\u7f51\u4e86\uff01\uff08Wi-Fi\uff09\u8bbf\u95ee\u4e92\u8054\u7f51\u3002\uff0c\u901a\u8fc7 Wi-Fi \u4e0a\u7f51\uff0c\u5e76\u7ed9\u8fde\u63a5\u5230\u3002\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u662f\u4ece Ubuntu \u7684\u3002\uff08\u5916\u7f51\uff09\u8f6c\u53d1\u65f6\uff0c\u81ea\u52a8\u4fee\u6539\u6570\u636e\u5305\u7684\u3002\u7684\u6838\u5fc3\u89c4\u5219\uff0c\u7528\u4e8e\u8ba9\u8fde\u63a5\u5230\u3002\uff08\u6709\u7ebf\u7f51\u7edc\uff09\u7684\u8bbe\u5907\u901a\u8fc7\u3002<\/p>\n","protected":false},"author":2,"featured_media":41400,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,44],"topic":[],"class_list":["post-41403","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/41403.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb921\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8fd9\u6837\uff0c\u4f60\u7684\u8bbe\u5907\u5c31\u80fd\u901a\u8fc7 Ubuntu \u7684 Wi-Fi \u4e0a\u7f51\u4e86\uff01\uff08Wi-Fi\uff09\u8bbf\u95ee\u4e92\u8054\u7f51\u3002\uff0c\u901a\u8fc7 Wi-Fi \u4e0a\u7f51\uff0c\u5e76\u7ed9\u8fde\u63a5\u5230\u3002\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u662f\u4ece Ubuntu \u7684\u3002\uff08\u5916\u7f51\uff09\u8f6c\u53d1\u65f6\uff0c\u81ea\u52a8\u4fee\u6539\u6570\u636e\u5305\u7684\u3002\u7684\u6838\u5fc3\u89c4\u5219\uff0c\u7528\u4e8e\u8ba9\u8fde\u63a5\u5230\u3002\uff08\u6709\u7ebf\u7f51\u7edc\uff09\u7684\u8bbe\u5907\u901a\u8fc7\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/41403.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-01T23:15:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250601231554-683cdf2a581cf.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/41403.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/41403.html\",\"name\":\"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-01T23:15:55+00:00\",\"dateModified\":\"2025-06-01T23:15:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/41403.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/41403.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/41403.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/41403.html","og_locale":"zh_CN","og_type":"article","og_title":"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb921\u6b21\uff0c\u70b9\u8d5e26\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u8fd9\u6837\uff0c\u4f60\u7684\u8bbe\u5907\u5c31\u80fd\u901a\u8fc7 Ubuntu \u7684 Wi-Fi \u4e0a\u7f51\u4e86\uff01\uff08Wi-Fi\uff09\u8bbf\u95ee\u4e92\u8054\u7f51\u3002\uff0c\u901a\u8fc7 Wi-Fi \u4e0a\u7f51\uff0c\u5e76\u7ed9\u8fde\u63a5\u5230\u3002\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u662f\u4ece Ubuntu \u7684\u3002\uff08\u5916\u7f51\uff09\u8f6c\u53d1\u65f6\uff0c\u81ea\u52a8\u4fee\u6539\u6570\u636e\u5305\u7684\u3002\u7684\u6838\u5fc3\u89c4\u5219\uff0c\u7528\u4e8e\u8ba9\u8fde\u63a5\u5230\u3002\uff08\u6709\u7ebf\u7f51\u7edc\uff09\u7684\u8bbe\u5907\u901a\u8fc7\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/41403.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-01T23:15:55+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250601231554-683cdf2a581cf.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/41403.html","url":"https:\/\/www.wsisp.com\/helps\/41403.html","name":"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-01T23:15:55+00:00","dateModified":"2025-06-01T23:15:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/41403.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/41403.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/41403.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Ubuntu20.04\u670d\u52a1\u5668\u5f00\u542f\u8def\u7531\u8f6c\u53d1\u8ba9\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u7535\u8111\u901a\u8fc7\u8be5\u670d\u52a1\u5668\u8fde\u63a5\u5916\u7f51"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/41403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=41403"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/41403\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/41400"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=41403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=41403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=41403"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=41403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}