快捷搜索:   nginx

ubuntu 共享 无线上网

root@ubuntu-T61:~# echo "1" >/proc/sys/net/ipv4/ip_forward
root@ubuntu-T61:~# iptables -F
root@ubuntu-T61:~#
root@ubuntu-T61:~# iptables -P INPUT ACCEPT
root@ubuntu-T61:~#
root@ubuntu-T61:~# iptables -P FORWARD ACCEPT
root@ubuntu-T61:~#
root@ubuntu-T61:~# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
root@ubuntu-T61:~#
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         192.168.10.1    0.0.0.0         UG    0      0        0 eth0
[root@localhost ~]# ping 211.100.255.1
PING 211.100.255.1 (211.100.255.1) 56(84) bytes of data.
64 bytes from 211.100.255.1: icmp_seq=1 ttl=248 time=10.0 ms

--- 211.100.255.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.053/10.053/10.053/0.000 ms
[root@localhost ~]#

asher@ubuntu-T61:~$ route -n
内核 IP 路由表
目标            网关            子网掩码        标志 跃点   引用 使用 接口
172.31.12.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
0.0.0.0         172.31.12.1     0.0.0.0         UG    0      0        0 wlan0
asher@ubuntu-T61:~$

asher@ubuntu-T61:~$ ifconfig
eth0      Link encap:以太网 硬件地址 00:1c:25:78:1d:3e
          inet 地址:192.168.10.1 广播:192.168.10.255 掩码:255.255.255.0
          inet6 地址: fe80::21c:25ff:fe78:1d3e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
          接收数据包:462 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:714 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000
          接收字节:61295 (61.2 KB) 发送字节:65910 (65.9 KB)
          Memory:fe200000-fe220000

lo        Link encap:本地环回
          inet 地址:127.0.0.1 掩码:255.0.0.0
          inet6 地址: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 跃点数:1
          接收数据包:322 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:322 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:0
          接收字节:24032 (24.0 KB) 发送字节:24032 (24.0 KB)

wlan0     Link encap:以太网 硬件地址 00:1f:3b:03:6c:6b
          inet 地址:172.31.12.174 广播:172.31.12.255 掩码:255.255.255.0
          inet6 地址: fe80::21f:3bff:fe03:6c6b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
          接收数据包:8412 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:3042 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000
          接收字节:2628167 (2.6 MB) 发送字节:522975 (522.9 KB)

wmaster0 Link encap:未指定 硬件地址 00-1F-3B-03-6C-6B-63-36-00-00-00-00-00-00-00-00
          UP RUNNING MTU:0 跃点数:1
          接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000
          接收字节:0 (0.0 B) 发送字节:0 (0.0 B)

在终端继续输入

iptables -F

iptables -P INPUT ACCEPT

iptables -P FORWARD ACCEPT

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

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论