我想通过交叉电缆连接我的两台在 2.6 内核中运行的 Linux PC。为此,我在 Google 搜索后进行了以下设置:
在 PC1
ifconfig eth0 10.10.11.16 netmask 255.255.255.0 up
route add default gw 10.10.11.13 eth0
(默认网关是 pc2 的 ip )在 PC2
ifconfig eth0 10.10.11.13 netmask 255.255.255.0 up
route add default gw 10.10.11.16 eth0
(默认网关是 pc1 的 ip )然后我尝试 ping 我无法连接。以上这些设置是否足够或我缺少任何东西?
为您提供更多信息
在 PC1
ifconfig 输出
eth0 Link encap:Ethernet HWaddr 00:16:76:A1:33:37
inet addr:10.10.11.16 Bcast:10.10.11.255 Mask:255.255.255.0
inet6 addr: fe80::216:76ff:fea1:3337/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:49984 errors:6 dropped:0 overruns:0 frame:6
TX packets:17221 errors:0 dropped:0 overruns:0 carrier:0
collisions:439 txqueuelen:1000
RX bytes:14295749 (13.6 MiB) TX bytes:2684625 (2.5 MiB)
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:511 errors:0 dropped:0 overruns:0 frame:0
TX packets:511 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:62780 (61.3 KiB) TX bytes:62780 (61.3 KiB)
Run Code Online (Sandbox Code Playgroud)
路由 -n 输出
Destination Gateway Genmask Flags Metric Ref Us Iface
10.10.11.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 1002 0 0 eth0
0.0.0.0 10.10.11.13 0.0.0.0 UG 0 0 0 eth0
Run Code Online (Sandbox Code Playgroud)
在 PC2
ifconfig 输出
eth0 Link encap:Ethernet HWaddr 00:40:CA:A1:C7:1B
inet addr:10.10.11.13 Bcast:10.10.11.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:705 errors:0 dropped:0 overruns:0 frame:0
TX packets:97 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:63557 (62.0 KiB) TX bytes:9973 (9.7 KiB)
Interrupt:11 Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:112 errors:0 dropped:0 overruns:0 frame:0
TX packets:112 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:12400 (12.1 KiB) TX bytes:12400 (12.1 KiB)
Run Code Online (Sandbox Code Playgroud)
路由 -n 输出
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 10.10.11.16 0.0.0.0 UG 0 0 0 eth0
Run Code Online (Sandbox Code Playgroud)
小智 5
我连接了两台 Fedora 机器。在这里,我使用 A 和 B 作为机器名称。
编辑文件
vim /etc/sysconfig/network-scripts/ifcfg-eth0
Run Code Online (Sandbox Code Playgroud)
并输入机器 A 的详细信息
DEVICE="eth0"
HWADDR="<Machine A NIC HW ADDR CAN BE ENTERED USING ifconfig>"
BOOTPROTO="static"
ONBOOT="yes"
NM_CONTROLLED="yes"
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.1.1
BROADCAST=192.168.1.255
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
Run Code Online (Sandbox Code Playgroud)
编辑文件
vim /etc/sysconfig/network-scripts/ifcfg-eth0
Run Code Online (Sandbox Code Playgroud)
并输入机器 B 的详细信息
DEVICE="eth0"
HWADDR="<Machine B NIC HW ADDR CAN BE ENTERED USING ifconfig>"
BOOTPROTO="static"
ONBOOT="yes"
NM_CONTROLLED="yes"
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.1.2
BROADCAST=192.168.1.255
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
Run Code Online (Sandbox Code Playgroud)
使用以太网交叉电缆连接两台机器。
可选重启。
ping 192.168.1.1
从机器 B 和ping 192.168.1.2
机器 A
如果您仍然无法ping通,请执行以下步骤。可能由于网卡的速度差异,您的机器无法 ping 通。将两台机器的速度设置为恒定。那么它可能会起作用。
- On Machine A enter command:
ethtool -s eth0 speed 10 duplex half
- On Machine B enter command:
ethtool -s eth0 speed 10 duplex half
Run Code Online (Sandbox Code Playgroud)
然后重复步骤 5。 如果您的机器仍然无法互相 ping 通,请执行以下操作:
[root@localhost ravidborse]# lspci
00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 03)
00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 03)
00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 03)
00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 03)
00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 03)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d3)
00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 03)
00:1f.2 IDE interface: Intel Corporation 82801FBM (ICH6M) SATA Controller (rev 03)
00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 03)
06:08.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
06:09.0 CardBus bridge: Texas Instruments PCI7420 CardBus Controller
06:09.2 FireWire (IEEE 1394): Texas Instruments PCI7x20 1394a-2000 OHCI Two-Port PHY/Link-Layer Controller
06:09.3 Mass storage controller: Texas Instruments PCI7420/7620 Combo CardBus, 1394a-2000 OHCI and SD/MS-Pro Controller
06:0a.0 Network controller: Intel Corporation PRO/Wireless 2200BG [Calexico2] Network Connection (rev 05)
Run Code Online (Sandbox Code Playgroud)
检查 dmesg 中加载了哪些驱动程序 | grep 以太网 lsmod | grep 8139
我输入了lspci
命令并查看了哪个以太网控制器正在使用您的机器。
我的 A 机器正在使用RTL8101E/8102E
,上面的lspci
输出是机器 B。下载以太网卡的相应 Linux 驱动程序并安装它们。这些驱动程序很容易安装。阅读readme
驱动程序文件夹中的 。
归档时间: |
|
查看次数: |
23014 次 |
最近记录: |