这个问题我有一个很大的问题。
我希望能够通过我的有线接口( eth0 )通过我的WIFI接口( wlan0 )来ping和访问TFTP,
pc1_eth-> LTdhcps2_eth0-> LTdhcps2_wlan0-> pc2_wlan
而相反
pc2_wlan-> LTdhcps2_wlan0-> LTdhcps2_eth0-> pc1_eth
起初,我认为这将是简单的,因为我认为我只需要设置我的eth0的网关与我的wlan0的IP。
我错了,我无法做到这一点。
让痛苦开始吧
1)我认为从pc1和pc2的configuration并不重要,因为它只涉及LTdhcps2接口,对吗?
服务器LTdhcps2
为eth0
cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 #iface eth0 inet dhcp auto eth0 iface eth0 inet static address 192.168.2.10 netmask 255.255.255.0
为wlan0
是由networkingpipe理器configurationDHCP(我想不出如何使用wpa_supplicantconfiguration它)
开始服务后
service network-manager start service networking start
这个结果
[root@LTdhcps2:~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:1e:c9:24:c9:d1 inet addr:192.168.2.10 Bcast:192.168.2.255 Mask:255.255.255.0 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) Interrupt:44 Base address:0xc000 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:16436 Metric:1 RX packets:20 errors:0 dropped:0 overruns:0 frame:0 TX packets:20 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1348 (1.3 KiB) TX bytes:1348 (1.3 KiB) wlan0 Link encap:Ethernet HWaddr 00:24:2b:c7:74:7e inet addr:10.0.2.218 Bcast:10.0.3.255 Mask:255.255.252.0 inet6 addr: fe80::224:2bff:fec7:747e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:24154 errors:0 dropped:0 overruns:0 frame:37468 TX packets:677 errors:8 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1670308 (1.5 MiB) TX bytes:140171 (136.8 KiB) Interrupt:19 [root@LTdhcps2:~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.1.2 0.0.0.0 UG 0 0 0 wlan0 10.0.0.0 0.0.0.0 255.255.252.0 U 0 0 0 wlan0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 [root@LTdhcps2:~]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 10.0.1.2 0.0.0.0 UG 0 0 0 wlan0 10.0.0.0 0.0.0.0 255.255.252.0 U 0 0 0 wlan0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
我试过做什么
[root@LTdhcps2:~]# route add -net 10.0.0.0 gw 10.0.2.218 dev eth0 SIOCADDRT: Invalid argument [root@LTdhcps2:~]#
奇怪的错误,这意味着什么= | 我GOOGLE了,并find这个职位: http : //www.adminsehow.com/2011/09/gateway-on-a-different-subnet-on-linux/
它说,你必须添加一个主机所需的网关IP,因为网关是在一个不同的子网。
[root@LTdhcps2:~]# route add -host 10.0.2.218/32 dev eth0 [root@LTdhcps2:~]# route add default gw 10.0.2.218
(如果我把开发eth0在第二个命令的末尾)它给了SIOCADDRT:没有这样的过程错误。
结果:
[root@LTdhcps2:~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.0.2.218 0.0.0.0 UG 0 0 0 wlan0 default 10.0.1.2 0.0.0.0 UG 0 0 0 wlan0 10.0.0.0 * 255.255.252.0 U 0 0 0 wlan0 10.0.2.218 * 255.255.255.255 UH 0 0 0 eth0 192.168.2.0 * 255.255.255.0 U 0 0 0 eth0 [root@LTdhcps2:~]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 10.0.2.218 0.0.0.0 UG 0 0 0 wlan0 0.0.0.0 10.0.1.2 0.0.0.0 UG 0 0 0 wlan0 10.0.0.0 0.0.0.0 255.255.252.0 U 0 0 0 wlan0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
但是我无法使用eth0接口或其网关(10.0.1.2)ping / traceroute wlan0,
[root@LTdhcps2:~]# ping -I eth0 10.0.2.218 PING 10.0.2.218 (10.0.2.218) from 192.168.2.10 eth0: 56(84) bytes of data. From 192.168.2.10 icmp_seq=1 Destination Host Unreachable From 192.168.2.10 icmp_seq=2 Destination Host Unreachable [root@LTdhcps2:~]# ping -I eth0 10.0.1.2 PING 10.0.1.2 (10.0.1.2) from 192.168.2.10 eth0: 56(84) bytes of data. From 192.168.2.10 icmp_seq=1 Destination Host Unreachable From 192.168.2.10 icmp_seq=2 Destination Host Unreachable [root@LTdhcps2:~]# traceroute -i eth0 10.0.2.218 traceroute to 10.0.2.218 (10.0.2.218), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * 4 * * *
对不起,长的职位和糟糕的英语。 我正面临这个圣周= |的问题
我解决了这个问题。
ping -I接口或traceroute -i接口
他们不是检查它的工作方式,你不需要指定接口,因为如果你做的内核不使用路由表(我猜)。