嵌入式爱好者

嵌入式爱好者 门户 知识库 T507系列产品 Linux 查看内容

OKT507单个网口适配多个静态网段

2023-11-30 10:06| 发布者: xing星| 查看: 192| 评论: 0

类目: T507系列产品  >  Linux     文档编号: 1219

如果网口另一端连接的不是路由器,不能自动分配IP;但是对于网口的网段有要求,需要能够连接不同网段的情况;
可以尝试将配置文件/etc/network/inte**ces按照如下配置,添加上一个192.168.1.1网段的配置,然后重新启动开发板就好了;
auto eth0
iface eth0 inet static
address 192.168.0.232
netmask 255.255.255.0
gateway 192.168.0.1

auto eth0:1
iface eth0:1 inet static
address 192.168.1.232
netmask 255.255.255.0
gateway 192.168.1.1
然后使用ifconfig查看的情况是
root@forlinx:/# ifconfig
eth0     Link encap:Ethernet HWaddr 5E:4A:4B:B9:4D:0A
        inet addr:192.168.0.232 Bcast:192.168.0.255 Mask:255.255.255.0
        inet6 addr: fe80::5c4a:4bff:feb9:4d0a/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
        RX packets:72 errors:0 dropped:0 overruns:0 frame:0
        TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000
        RX bytes:4797 (4.6 KiB) TX bytes:508 (508.0 B)
        Interrupt:64

eth0:1   Link encap:Ethernet HWaddr 5E:4A:4B:B9:4D:0A
        inet addr:192.168.1.232 Bcast:192.168.1.255 Mask:255.255.255.0
        UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
        Interrupt:64

可以和电脑一样同时ping通两个网段

root@forlinx:/# ping 192.168.0.52
PING 192.168.0.52 (192.168.0.52): 56 data bytes
64 bytes from 192.168.0.52: seq=0 ttl=128 time=0.349 ms
64 bytes from 192.168.0.52: seq=1 ttl=128 time=0.268 ms
64 bytes from 192.168.0.52: seq=2 ttl=128 time=0.271 ms
^C
--- 192.168.0.52 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.268/0.296/0.349 ms
root@forlinx:/# ping 192.168.1.52
PING 192.168.1.52 (192.168.1.52): 56 data bytes
64 bytes from 192.168.1.52: seq=0 ttl=128 time=0.593 ms
64 bytes from 192.168.1.52: seq=1 ttl=128 time=0.352 ms
64 bytes from 192.168.1.52: seq=2 ttl=128 time=0.328 ms
^C
--- 192.168.1.52 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.328/0.424/0.593 ms






已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-12-22 18:01

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部