CentOS7服务器连接nas拷贝文件

1. 给nas配置固定ip并用网线直接连接到nas上

先把nas连接到局域网里,在局域网里用windows下的nas厂商提供的工具查找到了nas的ip,进去web页面将ip设置为固定ip 192.168.3.3。 CentOS服务器有两个网卡,em1正在使用(dhcp分配的ip)不可变动,em2没在使用。

用网线将em2和nas的网口直连。配置em2网卡的IP为192.168.3.5。配置centos路由,先查看route。

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.31.0.1      0.0.0.0         UG    100    0        0 em1
172.31.0.0      0.0.0.0         255.255.255.0   U     100    0        0 em1
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

如果发现有em2的route,先route del -net x.x.x.x netmask x.x.x.x dev em2 删掉。
添加到192.168.3.3的route。

route add -host 192.168.3.3 dev em2
[root@localhost ~]# route        
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.31.0.1      0.0.0.0         UG    100    0        0 em1
172.31.0.0      0.0.0.0         255.255.255.0   U     100    0        0 em1
192.168.3.3     0.0.0.0         255.255.255.255 UH    0      0        0 em2
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

这样再ping 192.168.3.3就可以ping通了。

2. 安装SmbClient,把nas的文件夹mount到/mnt/smb下。

yum install samba samba-client samba-swat
mkdir /mnt/smb
smbclient -L 198.168.3.3 -U username%password  #列出该IP地址所提供的共享文件夹
mount -o username=username,password=123456 //192.168.3.3/tmp /mnt/smb/ #mount

这样就可以到/mnt/smb访问nas了。