Почему
$ ping ya.ru
ping: unknown host ya.ru
Комп1 (принимающий инет)
$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr b8:03:05:c9:3e:c5
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::ba03:5ff:fec9:3ec5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33086 errors:0 dropped:0 overruns:0 frame:0
TX packets:62823 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2797459 (2.7 MB) TX bytes:90723494 (90.7 MB)
и так делал
$ ip route
default via 192.168.0.2 dev wlan0 scope link metric 100
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.2 metric 9
и так делал
$ ip route
default via 192.168.0.1 dev wlan0 scope link metric 100
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.2 metric 9
$ sudo iptables-save
:пусто
$ nslookup ya.ru
;; connection timed out; no servers could be reached
$ ping 8.8.8.8
connect: Network is unreachable
Комп2 (раздающий 3g)
$ ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:88:e3:67:d4:45
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:5976 errors:0 dropped:0 overruns:0 frame:0
TX packets:5976 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:547759 (547.7 KB) TX bytes:547759 (547.7 KB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.225.20.196 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:14699 errors:0 dropped:0 overruns:0 frame:0
TX packets:13627 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:11287729 (11.2 MB) TX bytes:2950024 (2.9 MB)
wlan0 Link encap:Ethernet HWaddr 50:b7:c3:2a:68:31
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52b7:c3ff:fe2a:6831/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1000 errors:0 dropped:0 overruns:0 frame:0
TX packets:1021 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:148348 (148.3 KB) TX bytes:108966 (108.9 KB)
wwan0 Link encap:Ethernet HWaddr 58:2c:80:13:92:63
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
$ ip route
default via 10.64.64.64 dev ppp0 metric 100
10.64.64.64 dev ppp0 proto kernel scope link src 10.225.20.196
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.1 metric 9
net.ipv4.ip_forward = 1
Даже после команды :
$ sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 10.0.0.0/24 -o ppp0 -j MASQUERADE
в iptables пусто
$ sudo iptables -L -v -n --line
Chain INPUT (policy ACCEPT 11498 packets, 8572K bytes)
num pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 2 packets, 112 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 11183 packets, 2394K bytes)
num pkts bytes target prot opt in out source destination
$ sudo iptables-save
# Generated by iptables-save v1.4.21 on Fri Aug 12 21:04:53 2016
*nat
:PREROUTING ACCEPT [437:43281]
:INPUT ACCEPT [389:28232]
:OUTPUT ACCEPT [1207:218579]
:POSTROUTING ACCEPT [66:9831]
-A POSTROUTING -o ppp0 -j MASQUERADE
COMMIT
# Completed on Fri Aug 12 21:04:53 2016
# Generated by iptables-save v1.4.21 on Fri Aug 12 21:04:53 2016
*filter
:INPUT ACCEPT [29340:31886316]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [21601:3071749]
-A FORWARD -s 192.168.0.0/24 -i wlan0 -o ppp0 -j ACCEPT
-A FORWARD -d 192.168.0.0/24 -i ppp0 -o wlan0 -j ACCEPT
COMMIT
# Completed on Fri Aug 12 21:04:53 2016
$ nslookup ya.ru
Server: 127.0.1.1
Address: 127.0.1.1#53
Non-authoritative answer:
Name: ya.ru
Address: 93.158.134.3
Name: ya.ru
Address: 213.180.193.3
Name: ya.ru
Address: 213.180.204.3
Сделал :
iptables -F
iptables -X
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o ppp0 -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -i ppp0 -o wlan0 -d 192.168.0.0/24 -j ACCEPT
Получил
$ sudo iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 72 packets, 4357 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 65 packets, 3965 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 88 packets, 13008 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 5 packets, 890 bytes)
pkts bytes target prot opt in out source destination
90 12510 MASQUERADE all -- * ppp0 0.0.0.0/0 0.0.0.0/0
Но маскарад так и не работает.
В итоге на комп2 есть инет и пингуется комп1. А на комп1 нет инета,хотя и пингуется комп2. Почему нет интернета ?(
Ответ
На обоих компах прописал в файл /etc/resolv.conf
nameserver 8.8.8.8
Спасибо @alexander-barakin
Сделал на компе2(с 3g инетом):
iptables -F
iptables -X
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o ppp0 -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -i ppp0 -o wlan0 -d 192.168.0.0/24 -j ACCEPT
Спасибо @nobody
И заработало. Всем спасибо!)
Комментариев нет:
Отправить комментарий