Ubuntu下让Linux开发板通过笔记本上网
2016-06-13 00:05
537 查看
Configure the LAN and WLAN general description
Configure the LAN in terminal
restart the network interface
Configure WIFI internet access Ethernet share internet access to Dev board
Why this is important
Network manager configuration
Check eth0 configuration
大多数情况下我们让Linux嵌入式开发板通过LAN口连接笔记本来达到两者之间的通信,这里更进一步,介绍在此基础上,让开发板能共享笔记本的无线网来达到直接上互联网的目的。我使用的开发板是飞凌公司的OK335xD,笔记本操作系统是Ubuntu 12.04。
Configure the WLAN to dhcp and automatic and LAN with a static ip address
Here if this cannot restart successfully, then try stop/start seperately, and the problem might be:
and even in the network application in ubuntu, the Wireless configuration is also disabled, it means that at the moment, the /etc/network/interfaces cannot correctly configure the network, here the solution is to use network manager service to configure the network:
change the line managed=false to managed=true (normally NetworkManager does not manage interfaces that appear in /etc/network/interfaces), then restart this service:
Another method is you can keep managed=false, and just delete all the self-defined configurations in /etc/network/interfaces(keep the first 2 lines for the auto lo), and use the above command to restartd the network manager, because if network manager finds out that there is no configuration in the interfaces file, it will still handle the network configurations even it is set to false.
In Ubuntu, I suggest that we use this method to configure the network, the Network-Manager will make less errors than setting manually on the /e/n/interfaces files, and it can automatically switch when ehternet is connected.
In windows, I can use the bridge connection mode, in this mode, the eth0 and wlan0 will be set in the same subnet and eth0 shares the internet access of wifi. Ubuntu 12.04 does not support this function by default. If I set manually the eth0 and wlan0 in the same subnet, only one connection (internet wlan0 access or dev board eth0 access) will be available at a time (depends on the value of the metric, you can check the value by typing “ip route show” in terminal).
So to achieve the goal above without using bridge mode, the subnet of wifi and the subnet of ethernet must be different. The easiest way is stil using netwwork manager to configure.
connect the laptop with dev board by ethernet (if necessary restart network manager to make sure that Wired connection is active)
Open “Network” application -> Options -> Tab IPv4 Settings
In “Method” list, choose option “Shared to other computers”
Then click save
Restart network manager (terminal: sudo service network-manager restart)
Here is the automatically generated eth0 configuration on my laptop
So the eth0 is assigned to 10.42.0.1, then on the other side, the dev board should set eth0 also in the same subnet and netmask. Here I assigned eth0 in dev board to 10.42.1.75 (here you should find another way to configure the dev board, I used serial port to configure it)
In /etc/network/interfaces in dev board, here is my configuration:
Then restart the network interface in dev board
Then it is done. Now laptop can talk to dev board (example: telnet 10.42.0.75), and the dev also have access to the internet, bingo !
987b
Configure the LAN in terminal
restart the network interface
Configure WIFI internet access Ethernet share internet access to Dev board
Why this is important
Network manager configuration
Check eth0 configuration
大多数情况下我们让Linux嵌入式开发板通过LAN口连接笔记本来达到两者之间的通信,这里更进一步,介绍在此基础上,让开发板能共享笔记本的无线网来达到直接上互联网的目的。我使用的开发板是飞凌公司的OK335xD,笔记本操作系统是Ubuntu 12.04。
Configure the LAN and WLAN (general description)
Configure the LAN in terminal
$ sudo nano /etc/network/interfaces
Configure the WLAN to dhcp and automatic and LAN with a static ip address
auto lo iface lo inet loopback # The primary network interface auto wlan0 iface wlan0 inet dhcp # The second eth0 auto eth0 iface eth0 inet static address 192.168.1.73
restart the network interface
$ sudo /etc/init.d/networking restart
Here if this cannot restart successfully, then try stop/start seperately, and the problem might be:
stop: Unknown instance: networking stop/waiting
and even in the network application in ubuntu, the Wireless configuration is also disabled, it means that at the moment, the /etc/network/interfaces cannot correctly configure the network, here the solution is to use network manager service to configure the network:
sudo nano /etc/NetworkManager/NetworkManager.conf
change the line managed=false to managed=true (normally NetworkManager does not manage interfaces that appear in /etc/network/interfaces), then restart this service:
sudo service network-manager restart
Another method is you can keep managed=false, and just delete all the self-defined configurations in /etc/network/interfaces(keep the first 2 lines for the auto lo), and use the above command to restartd the network manager, because if network manager finds out that there is no configuration in the interfaces file, it will still handle the network configurations even it is set to false.
In Ubuntu, I suggest that we use this method to configure the network, the Network-Manager will make less errors than setting manually on the /e/n/interfaces files, and it can automatically switch when ehternet is connected.
Configure WIFI (internet access) + Ethernet (share internet access to Dev board)
Here I want to keep laptop the internet access to the internet while at the same time, the laptop can also communicate with dev board through ethernet, and also make the dev board have the internet access.Why this is important ?
My dev board only has ehternet port and runs kernel linux system, so it does not support usb wifi yet, and since the new module needs to be cross compiled through my laptop, so I need the communication between the laptop and dev board (only ehternet works), and I don’t want my laptop lose the internet access because of the ethernet connection. (In Ubuntu 12.04, when it detects that ehternet is connected, it will set the priority of eth0 higher than wlan0), so by default configuration, as soon as laptop has connected with dev board, the internet access is lost.In windows, I can use the bridge connection mode, in this mode, the eth0 and wlan0 will be set in the same subnet and eth0 shares the internet access of wifi. Ubuntu 12.04 does not support this function by default. If I set manually the eth0 and wlan0 in the same subnet, only one connection (internet wlan0 access or dev board eth0 access) will be available at a time (depends on the value of the metric, you can check the value by typing “ip route show” in terminal).
So to achieve the goal above without using bridge mode, the subnet of wifi and the subnet of ethernet must be different. The easiest way is stil using netwwork manager to configure.
Network manager configuration
make sure that wlan0 has internet accessconnect the laptop with dev board by ethernet (if necessary restart network manager to make sure that Wired connection is active)
Open “Network” application -> Options -> Tab IPv4 Settings
In “Method” list, choose option “Shared to other computers”
Then click save
Restart network manager (terminal: sudo service network-manager restart)
Check eth0 configuration
ip route show
Here is the automatically generated eth0 configuration on my laptop
default via 192.168.1.254 dev wlan0 proto static 10.42.0.0/24 dev eth0 proto kernel scope link src 10.42.0.1 metric 1 169.254.0.0/16 dev wlan0 scope link metric 1000 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.39 metric 2
So the eth0 is assigned to 10.42.0.1, then on the other side, the dev board should set eth0 also in the same subnet and netmask. Here I assigned eth0 in dev board to 10.42.1.75 (here you should find another way to configure the dev board, I used serial port to configure it)
In /etc/network/interfaces in dev board, here is my configuration:
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.42.0.75 netmask 255.255.255.0 gateway 10.42.0.1
Then restart the network interface in dev board
$ sudo /etc/init.d/networking restart
Then it is done. Now laptop can talk to dev board (example: telnet 10.42.0.75), and the dev also have access to the internet, bingo !
987b
huangt@huangt-HP-ProBook-4431s:~$ telnet 10.42.0.75 Trying 10.42.0.75... Connected to 10.42.0.75. Escape character is '^]'. _____ _____ _____ _ _ __ _ __ __ | ___| / _ | _ | | | | | | | / / | |__ | | | | | |_| | | | | | | | | / / | __| | | | | | _ / | | | | | | | } { | | | |_| | | | | |___ | | | | | / / |_| _____/ |_| _ |_____| |_| |_| _| /_/ _ ok335x login: root root@ok335x:~# ping google.fr PING google.fr (173.194.45.79): 56 data bytes 64 bytes from 173.194.45.79: seq=0 ttl=51 time=39.767 ms ^C --- google.fr ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 39.767/39.767/39.767 ms root@ok335x:~#
相关文章推荐
- Ubuntu 默认壁纸历代记
- Ubuntu Remix Cinnamon 20.04 评测:Ubuntu 与 Cinnamon 的完美融合
- Linux socket 初步
- 关于Ubuntu 11.10启动提示waiting for the network configuration的问题
- 在 Ubuntu 桌面中使用文件和文件夹
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- ubuntu下chrome无法同步问题解决
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验