Kết nối internet và Ethernet với Odroid (qua Switch) và 1 card mạng kết nối internet

Cấu hình tham khảo:

Kết nối internet qua cable, với cổng RJ45 trên máy tính. Với kết nối này, đặt connection là DHCP, ví dụ dải địa chỉ IP là từ 134.59.129.0 ->...255.

Kết nối mạng Lan (Ethernet) với Odroid (qua 1 switch trung gian), dùng card mạng có 1 đầu là kết nối USB, 1 đầu là RJ45 (loại thường dùng cho Macbook. Với kết nối này, đặt fixed IP, ví dụ 192.168.0.20, cho groundstation computer.

Dùng lệnh route sẽ cho kết quả, ví dụ như sau:

lhnguyen@nguyenL520:~$ route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

default 134.59.129.254 0.0.0.0 UG 0 0 0 eth0

134.59.129.0 * 255.255.255.0 U 1 0 0 eth0

192.168.0.0 * 255.255.255.0 U 1 0 0 eth1

Dùng lệnh ifconfig sẽ cho kết qủa, ví dụ như sau:

lhnguyen@nguyenL520:~$ ifconfig

eth0 Link encap:Ethernet HWaddr 04:7d:7b:39:2a:9c

      inet addr:134.59.129.246  Bcast:134.59.129.255  Mask:255.255.255.0

      inet6 addr: fe80::67d:7bff:fe39:2a9c/64 Scope:Link

      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      RX packets:228508 errors:0 dropped:9 overruns:0 frame:0

      TX packets:97172 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1000 

      RX bytes:250192749 \(250.1 MB\)  TX bytes:28255224 \(28.2 MB\)

eth1 Link encap:Ethernet HWaddr 00:1f:f3:8b:ef:ca

      inet addr:192.168.0.20  Bcast:192.168.0.255  Mask:255.255.255.0

      inet6 addr: fe80::21f:f3ff:fe8b:efca/64 Scope:Link

      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      RX packets:1898 errors:0 dropped:0 overruns:0 frame:0

      TX packets:398 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1000 

      RX bytes:300036 \(300.0 KB\)  TX bytes:75978 \(75.9 KB\)

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:5867 errors:0 dropped:0 overruns:0 frame:0

      TX packets:5867 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1 

      RX bytes:1054029 \(1.0 MB\)  TX bytes:1054029 \(1.0 MB\)

Trong trường hợp này, kết nối 2 mạng bình thường.

http://www.ubuntugeek.com/howto-add-permanent-static-routes-in-ubuntu.html

https://www.computerhope.com/unix/route.htm

https://www.thegeekstuff.com/2012/04/route-examples/

Một ví dụ bi lỗi kết nối Internet và cách khắc phục:

lhnguyen@nguyenL520:~$ route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

default nguyenL520 0.0.0.0 UG 0 0 0 eth1

134.59.129.0 * 255.255.255.0 U 1 0 0 eth1

192.168.0.0 * 255.255.255.0 U 1 0 0 eth0

lhnguyen@nguyenL520:~$ ifconfig

eth0 Link encap:Ethernet HWaddr 00:1f:f3:8b:ef:ca

      inet addr:192.168.0.20  Bcast:192.168.0.255  Mask:255.255.255.0

      inet6 addr: fe80::21f:f3ff:fe8b:efca/64 Scope:Link

      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      RX packets:1898 errors:0 dropped:0 overruns:0 frame:0

      TX packets:398 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1000 

      RX bytes:300036 \(300.0 KB\)  TX bytes:75978 \(75.9 KB\)

eth1 Link encap:Ethernet HWaddr 04:7d:7b:39:2a:9c

      inet addr:134.59.129.166  Bcast:134.59.129.255  Mask:255.255.255.0

      inet6 addr: fe80::67d:7bff:fe39:2a9c/64 Scope:Link

      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      RX packets:228508 errors:0 dropped:9 overruns:0 frame:0

      TX packets:97172 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1000 

      RX bytes:250192749 \(250.1 MB\)  TX bytes:28255224 \(28.2 MB\)

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:5867 errors:0 dropped:0 overruns:0 frame:0

      TX packets:5867 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1 

      RX bytes:1054029 \(1.0 MB\)  TX bytes:1054029 \(1.0 MB\)

Nếu quan sát kỹ, sẽ thấy thứ tự eth0 và eth1 bị đảo lộn. Cái này do khi kết nối mạng nào trước thì hệ thống sẽ assign địa chỉ tương ứng theo thứ tự kết nối.

Quan trọng hơn là :

lhnguyen@nguyenL520:~$ route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

default nguyenL520 0.0.0.0 UG 0 0 0 eth1

Gateway không phải là 134.59.129.254 như lúc đầu.

Làm thể nào để biết là gateway cần đặt là dãy số đó? (Cần tìm hiểu thêm)

Gỉả sử số đó là gateway cần đặt, khi đó cần xóa default cũ để thay bằng default mới.

Ví dụ:

sudo route del default gw nguyenL520

sudo route add default gw 134.59.129.254

========================================================

========================================================

Connect auv7530 with Ethernet (over ICY BOX usb-network hub) and Internet (over auv7530's network port)

Check route

auv@auv7530:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         auv7530         0.0.0.0         UG    100    0        0 eno1
default         134.59.129.254  0.0.0.0         UG    101    0        0 enx803f5d11e233
default         10.133.127.253  0.0.0.0         UG    600    0        0 wlp111s0
10.133.96.0     *               255.255.224.0   U     600    0        0 wlp111s0
134.59.129.0    *               255.255.255.0   U     100    0        0 enx803f5d11e233
134.59.131.13   134.59.129.254  255.255.255.255 UGH   100    0        0 enx803f5d11e233
link-local      *               255.255.0.0     U     1000   0        0 eno1
192.168.0.0     *               255.255.255.0   U     100    0        0 eno1

Then, since cannot connect to the Internet

auv@auv7530:~$ sudo route del default gw auv7530
[sudo] password for auv:

Now, check route again

auv@auv7530:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         134.59.129.254  0.0.0.0         UG    101    0        0 enx803f5d11e233
default         t130-mono.prive 0.0.0.0         UG    600    0        0 wlp111s0
10.133.96.0     *               255.255.224.0   U     600    0        0 wlp111s0
134.59.129.0    *               255.255.255.0   U     100    0        0 enx803f5d11e233
diogene.i3s.uni 134.59.129.254  255.255.255.255 UGH   100    0        0 enx803f5d11e233
link-local      *               255.255.0.0     U     1000   0        0 eno1
192.168.0.0     *               255.255.255.0   U     100    0        0 eno1

and connection to the Internet works properly!

Last updated

Was this helpful?