您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 青岛分类信息网,免费分类信息发布

困扰很多人ubuntu连网问题,终于搞定了!

2020/6/7 21:18:08发布169次查看

大家好,今天给大家分享ubuntu里面连网的问题以及搭建tftp服务器进行文件传送,这里面在配置ubuntu连网的问题,之前看到网友遇到过好多次,而且看网上的教程也没有解决了这个问题,在这里我分享一下我在配置网络的时候,出现了网络连不上网的解决方法。
一、在ubuntu搭建tftp服务器:
这里我的ubuntu是14.04的发行版本,新的版本可能在搭建配置过程中有点不一样,这个可以参考网上的教程来搭建,另外也可以在windows下搭建tftp服务器,当然windows本身就有自带的。
1、切换到root目录下:
当然平时学习弄到这个root目录没关系,主要忽略权限问题(但是在公司一般不会复于你这么高的权限,万一一不小心啥的,把啥重要的文件给删除了,那真的就是一首凉凉了),系统宕机了也没事,可以在vmware里面快照一下,当宕机的时候,一键恢复,可能很多网友连快照这么好的功能都没有用上,万一哪天开机,就出现了宕机了,就是死活进入不了登入界面,这个时候很多网友可能会采用比较传统的方法,那就是重新安装系统,这样是比较耗时的,所以快照功能我们要利用好来,如下图图1所以,快照功能在虚拟机下的快照选项,直接点击就行:
图1sudo su root
2、安装服务器:
root@txp-virtual-machine:/# apt-get install tftp-hpa tftpd-hpa xinetd
reading package lists... done
building dependency tree... 0%
3、创建一个服务器的文件交换目tftpboot,并修改其执行权限,免得过程中出现啥问题:
root@txp-virtual-machine:/# mkdir tftpboot
mkdir: cannot create directory ‘tftpboot’: file exists
root@txp-virtual-machine:/# chmod 777 -r tftpboot/
4、修改tftp配置文件,如果没有就创建:
root@txp-virtual-machine:/# vim /etc/xinetd.d/tftp
//该文件里面的配置内容
service tftp

       socket_type = dgram
       protocol = udp
       wait = yes
       user = root
       server = /usr/sbin/in.tftpd
       server_args = -s /home/jly/tftpboot/
       disable = no
       per_source = 11
       cps = 100 2
       flags = ipv4

5、修改inetd.conf文件或xinetd.conf文件:
root@txp-virtual-machine:/# vim /etc/inetd.conf
//该文件里面的配置内容
defaults

# please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. the default is the following :
# log_type = syslog daemon info

#includedir /etc/xinetd.d
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
6、修改tftpd-hpa文件:
root@txp-virtual-machine:/# vim /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
tftp_username="tftp"
tftp_directory="/tftpboot"
tftp_address="0.0.0.0:69"
tftp_options="-l -c -s"
7、重启服务:
root@txp-virtual-machine:/# service tftpd-hpa restart
tftpd-hpa stop/waiting
tftpd-hpa start/running, process 28630
root@txp-virtual-machine:/# /etc/init.d/xinetd reload
root@txp-virtual-machine:/# /etc/init.d/xinetd restart
xinetd stop/waiting
xinetd start/running, process 28658
二、连网问题:
1、很多网友在使用tftp进行传输文件时,比如说在我们的linux开发板上,要下载镜像文件,一般都会采用这种方法,但是这种方法,就要配置ubuntu的网络,因为我们的开发板是有线通信(网线),所以我们ubuntu这边要进行相应的网络的配置,这里我就不介绍在vmware里面的几种网络连接的区别了,直接开干,在虚拟机设置里面进行配置,如下图所示(特别提示一下,这是默认打开就是三个适配器):
2、在虚拟机菜单选项里面点击配置编辑菜单栏下面的虚拟网络编辑器,然后就会出现如下图所示:
image
然后对vmnet01适配器进行配置:
image
3、这个时候,看看网络是啥转态,你会发现是不能ping通的:ping: unknown host baidu.comping: unknown host baidu.com
root@txp-virtual-machine:/# ping baidu.com
ping: unknown host baidu.com
**注:一般我们要和开发板进行通信传输文件时,进行这样配置,把网络连接器配置成桥接模式,使其就上不了网了,这里要注意一下。我这里没有讲原理,只是简单讲了一下实际用法,也是为了方便使用。
4、千万不要把vmet8适配给删除了:
有些网友,可能不明白这其中的原理,然后把这个vmet8适配器给删除了,然后后面就死活怎样去网络按照教程来配置ubuntu,费时费力,后面就是死活ping通,人都快急的着火了,这种情况理解,环境搭建问题一直是学习过程中会遇到的障碍,但是我们必须要克服和战胜它,我们才会进步,为了清晰的给大家演示这个过程,下面我先回复到能够ping通的状态,然后演示把vmet8给删除了,死活就是ping不通的结果:
然后虚拟网络编辑器这边不要把vmet8适配器给删除了,而且网络连接模式是nat模式下,其他两个适配器随你怎么配置,都没问题:
现在的情况是ping的通哈:
root@txp-virtual-machine:/# ping baidu.com
ping baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79: icmp_seq=1 ttl=128 time=49.7 ms
64 bytes from 39.156.69.79: icmp_seq=2 ttl=128 time=48.4 ms
64 bytes from 39.156.69.79: icmp_seq=3 ttl=128 time=44.1 ms
64 bytes from 39.156.69.79: icmp_seq=4 ttl=128 time=43.9 ms
64 bytes from 39.156.69.79: icmp_seq=5 ttl=128 time=51.4 ms
现在我把vmet8这个适配器给删除了(当然虚拟机设置菜单里面网络连接还是nat模式,我没有修改):
现在我们来试试看(会发现是ping通了):
root@txp-virtual-machine:/# ping baidu.com
ping: unknown host baidu.com
5、总结:
(1):在一般情况下要使ubuntu能够连上网,一般虚拟机设置里面的网络连接是nat模式,然后虚拟编辑器里面的vmet8视频器千万不能给删了,不然即使是在nat模式下,你也不能上网。
(2)上面只是以实用性为例,简单实用,不用那么麻烦,为网络问题苦恼。并没有讲解这背后的原理哈。
三、在uboot里面下载镜像文件:
1、把ubuntu和uboot两边设置在同一网段下:
ubuntu这边的ip地址设置:
root@txp-virtual-machine:/# ifconfig eth0 192.168.1.141
root@txp-virtual-machine:/# ifconfig
eth0      link encap:ethernet  hwaddr 00:0c:29:4f:d0:e6
         inet addr:192.168.1.141  bcast:192.168.1.255  mask:255.255.255.0
         inet6 addr: fe80::20c:29ff:fe4f:d0e6/64 scope:link
         up broadcast multicast  mtu:1500  metric:1
         rx packets:37757 errors:0 dropped:0 overruns:0 frame:0
         tx packets:21617 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         rx bytes:26238540 (26.2 mb)  tx bytes:12780955 (12.7 mb)
uboot这边ip地址设置:
x210 # set ipaddr 192.168.1.20
x210 # set serverip 192.168.1.141
x210 # set gatemask  192.168.1.1
x210 # save
saving environment to smdk bootable device...
done
x210 # print
mtdpart=80000 400000 3000000
baudrate=115200
ethaddr=00:40:5c:26:0a:5b
gatewayip=192.168.0.1
netmask=255.255.0.0
bootargs=console=ttysac2,115200 root=/dev/mmcblk0p2 rw init=/linuxrc rootfstype=ext3
bootcmd=movi read kernel 30008000; bootm 30008000
bootdelay=5
ipaddr=192.168.1.20
serverip=192.168.1.141
gatemask=192.168.1.1
我们现在来看一下是否能够ping通ubuntu(是可以ping通的):
x210 # ping 192.168.1.141
dm9000 i/o: 0x88000300, id: 0x90000a46
dm9000: running in 16 bit mode
mac: 00:40:5c:26:0a:5b
operating at 100m full duplex mode
host 192.168.1.141 is alive
最后我们就来下载镜像文件了:
//这里主要下载tftpboot目录下的zimage-qt文件
root@txp-virtual-machine:/tftpboot# ls
test  zimage-qt
//在uboot这边开始下载了,并且下载成功:
load address: 0x30000000
loading: t t t t t t t t t t
retry count exceeded; starting again
tftp from server 192.168.1.141; our ip address is 192.168.1.20
filename 'zimage-qt'.
load address: 0x30000000
loading: #################################################################
        #################################################################
        ################################################transmission timeout
#################
        ####################################################
done
bytes transferred = 3616768 (0x373000)

青岛分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录