简单的网络共享方案

推店365app下载安装 2026-07-02 00:24:58 admin 6513 224
简单的网络共享方案

如果 A 有互联网连接,并希望让其他设备通过 A 上网,则需要:

操作步骤:

启用网络共享:

在 Windows 中:

打开 网络和共享中心 > 更改适配器设置。

右键 AAA 上的互联网连接(例如以太网或 Wi-Fi),选择 属性 > 共享,勾选 允许其他网络用户通过此计算机的 Internet 连接连接。

在 Linux 中:

启用 IP 转发:编辑 /etc/sysctl.conf 文件,确保 net.ipv4.ip_forward=1。

使用 iptables 配置 NAT 转发规则,例如:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

(eth0 是连接到互联网的网卡。)

netsh interface ip set address name="网络适配器名" source=dhcp

netsh interface set interface "网络适配器名" enable

netsh routing ip nat install

netsh routing ip nat add interface "共享的网络适配器名" mode=full

2. 配置其他设备:

在 B 的网络设置中,将默认网关设置为 A 的局域网 IP 地址。

相关推荐