ubuntu常用网络服务配置

引言

        本文介绍ubuntu系统的基本网络配置,包括IP配置、ftp服务配置等,实施环境为ubuntu 9.04 Server版。红色标记为重要的命令或过程。

一、ubuntu IP配置

配置ip:

sudo ifconfig eth1 172.20.10.* netmask 255.255.255.0

sudo route add default gw 172.20.10.1

配置dns:

sudo vi /etc/resolv.conf

在其中添加一条:

nameserver 172.20.1.*

配置完成,ping一下网关和g.cn:

ping 172.20.10.1

ping g.cn

如果有反应说明配置成功,eth1 是你的网卡,这里不一定是eth1,一般默认第一块网卡是eth0,可以通过下面的命令查看网络接口名:

netstat -i

Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth1       1500 0  18936348     16     16 0          2160      0      0      0 BMRU
lo        16436 0       734      0      0 0           734      0      0      0 LRU

网络配置文件:

sudo vi /etc/network/interfaces

这里的内容为:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth1
iface eth1 inet static
        address 172.20.10.*
        netmask 255.255.255.0
        network 172.20.10.0
        broadcast 172.20.10.255
        gateway 172.20.10.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 172.20.10.*

 

可以在这个配置文件中手动编辑ip地址和dns服务器,如果手动更改需要重启网络服务:

sudo /etc/init.d/networking restart

网络配置就告一段落,下面是ftp的配置。

二、ubuntu VSFTP服务配置

ftp服务我们用的是开源软件vsftp,可以通过下面命令安装:

sudo apt-get install vsftp

安装完毕后可以通过下面命令管理vsftp服务:

sudo /etc/init.d/vsftp start|stop|restart

首先,我们先明确一下使用ftp的目的,本文是为了方便对ubuntu的管理,上传网站文件,拷贝文件,而且是内部使用,所以我们这里让vsftp开启本地用户登录和上传,并把默认的权限修改为当前用户可读写并可执行的:

sudo vi /etc/vsftpd.conf

里面的配置文件需要修改的地方有:

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES      
#
# Uncomment this to allow local users to log in.
local_enable=NO      
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022

…………

#

# Uncomment this to allow the anonymous FTP user to upload files. This only

# has an effect if the above global write enable is activated. Also, you will

# obviously need to create a directory writable by the FTP user.

anon_upload_enable=YES

#

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

anon_mkdir_write_enable=YES

#

# other write allowed such as delete.

anon_other_write_enable=YES

修改完毕,重启vsftp服务:

sudo /etc/init.d/vsftpd restart

* Stopping FTP server: vsftpd                                            [ OK ]
* Starting FTP server: vsftpd                                             [ OK ]

然后就可以通过ftp客户端访问ubuntu的ftp服务了,vsftp默认匿名用户目录为/srv/ftp,该目录必须是755的权限(sudo chmod 755 /srv/ftp),在其下可以新建ftp:ftp有修改权限的目录下即可完成上传、下载、更改、新建目录、删除等操作。

总结

        本文介绍了ubuntu Server 9.04的网络配置和ftp服务的架设话题,希望能对初次接触ubuntu的新手有所帮助。

posted @ 2009-09-29 03:42  ddr888  阅读(1187)  评论(0编辑  收藏  举报