Я установил простой шлюз с Arch Linux:
GATEWAY# ifconfig eth0 172.27.210.221 netmask 255.255.255.0
GATEWAY# ifconfig wlan0 10.8.221.221 netmask 255.255.0.0
GATEWAY# iwconfig wlan0 essid OpenWifi
GATEWAY# echo 1 > /proc/sys/net/ipv4/ip_forward
Это фактическая таблица маршрутизации на шлюзе:
DESTINATION GATEWAY GENMASK FLAGS METRIC REF USE IFACE
10.8.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlan0
172.27.210.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
Я отключил rp_filter на всех интерфейсах.
Eth0 подключен к коммутатору, к которому у меня нет доступа. Когда все заработает, интерфейс будет настроен на доступ в Интернет. Wlan0 подключен к открытой сетевой инфраструктуре.
У меня есть клиентский компьютер на базе Arch Linux, подключенный к той же беспроводной сети со следующей настройкой:
CLIENT# iwconfig wlan0 essid OpenWifi
CLIENT# ifconfig wlan0 10.8.221.222 netmask 255.255.0.0
CLIENT# route add default gw 10.8.221.221 wlan0
Теперь я знаю, что для совместного использования подключения к Интернету мне нужно добавить маршрут по умолчанию и настроить NAT на машине шлюза. Но я полагаю, что я смогу пропинговать интерфейс eth0 шлюза от моего клиента без какой-либо дополнительной настройки:
CLIENT# ping 172.27.210.221
Дело в том, что я не получаю ответа.
Tcpdump на интерфейсе шлюза wlan0 показывает входящие запросы ICMP и ответы с 172.27.210.221 на 10.8.221.222, но на самом деле я ничего не получаю обратно на клиенте (я подтвердил это с помощью tcpdump на клиенте).
Если я воспроизведу эту настройку на двух виртуальных машинах, используя только интерфейсы Ethernet, у меня не будет никаких проблем. Вы хоть представляете, в чем может быть проблема? Может быть, это связано с беспроводной сетью?
ОБНОВЛЕНИЕ 1
Ниже приведены выходные данные iwconfig wlan0, iptables -nvL и tcpdump -npe на клиенте и шлюзе во время эхо-запроса от клиента 10.8.221.222 к шлюзу 172.27.210.221:
Шлюз:
iwconfig wlp2s0b1
wlp2s0b1 IEEE 802.11 ESSID:"OpenWifi"
Mode:Managed Frequency:2.437 GHz Access Point: xxxxxxxxxxxx
Bit Rate=54 Mb/s Tx-Power=11 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=70/70 Signal level=-29 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:79 Invalid misc:772 Missed beacon:0
iptables -nvL
Chain INPUT (policy ACCEPT 172K packets, 22M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1132 packets, 95328 bytes)
pkts bytes target prot opt in out source destination
tcpdump -npe 'icmp'
03:29:23.876193 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 1, length 64
03:29:23.876277 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 1, length 64
03:29:24.893768 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 2, length 64
03:29:24.893842 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 2, length 64
03:29:25.908918 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 3, length 64
03:29:25.908999 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 3, length 64
03:29:26.920903 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 4, length 64
03:29:26.920969 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 4, length 64
03:29:27.933499 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 5, length 64
03:29:27.933618 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 5, length 64
03:29:28.944583 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 6, length 64
03:29:28.944650 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 6, length 64
03:29:29.958243 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 7, length 64
03:29:29.958323 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 7, length 64
03:29:30.971649 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 8, length 64
03:29:30.971744 yyyyyyyyyyyyyy > xxxxxxxxxxxxxx, ethertype IPv4 (0x0800), length 98: 172.27.210.221 > 10.8.221.222: ICMP echo reply, id 13006, seq 8, length 64
Клиент:
iwconfig wlp1s0
wlp1s0 IEEE 802.11 ESSID:"OpenWifi"
Mode:Managed Frequency:2.412 GHz Access Point: xxxxxxxxxxxx
Bit Rate=1 Mb/s Tx-Power=11 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=54/70 Signal level=-56 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:1 Invalid misc:26 Missed beacon:0
iptables -nvL
Chain INPUT (policy ACCEPT 1665 packets, 149K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 765 packets, 64260 bytes)
pkts bytes target prot opt in out source destination
tcpdump -npe 'icmp'
12:29:30.950270 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 1, length 64
12:29:31.968238 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 2, length 64
12:29:32.981538 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 3, length 64
12:29:33.994868 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 4, length 64
12:29:35.008223 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 5, length 64
12:29:36.021575 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 6, length 64
12:29:37.034884 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 7, length 64
12:29:38.048205 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 8, length 64
12:29:39.061533 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 9, length 64
12:29:40.074884 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 10, length 64
12:29:41.088206 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 11, length 64
12:29:42.101534 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 12, length 64
12:29:43.114876 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 13, length 64
12:29:44.128193 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 14, length 64
12:29:45.141535 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 15, length 64
12:29:46.154870 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 16, length 64
12:29:47.168208 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 17, length 64
12:29:48.181573 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 18, length 64
12:29:49.194868 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 19, length 64
12:29:50.208171 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 20, length 64
12:29:51.221531 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 21, length 64
12:29:52.234870 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 22, length 64
12:29:53.248185 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 23, length 64
12:29:54.261521 xxxxxxxxxxxxxx > yyyyyyyyyyyyyy, ethertype IPv4 (0x0800), length 98: 10.8.221.222 > 172.27.210.221: ICMP echo request, id 13006, seq 24, length 64
То, что вы описали, должно работать.
Попробуйте отключить iptables и попробуйте пинг снова.