欢迎来到个人简历网!永久域名:gerenjianli.cn (个人简历全拼+cn)
当前位置:首页 > 范文大全 > 实用文>Linux中网络如何设置配置linux操作系统

Linux中网络如何设置配置linux操作系统

2025-01-11 10:10:20 收藏本文 下载本文

“小艺”通过精心收集,向本站投稿了7篇Linux中网络如何设置配置linux操作系统,以下是小编给大家整理后的Linux中网络如何设置配置linux操作系统,欢迎大家前来参阅。

Linux中网络如何设置配置linux操作系统

篇1:Linux中网络如何设置配置linux操作系统

使用linux系统内核的系统有很多,目前比较主流的有centos,fdeora,redha系统,这些有一些收费有一些免费的,但此方法可用于我讲述的三种系统中哦,

安装Linux系统后,登陆进去,修改一下文件:

代码如下复制代码

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=”eth0″

BOOTPROTO=”none”

HWADDR=”00:50:56:BE:7A:D8″

IPADDR=192.168.2.108                          #IP地址,必须设置

GATEWAY=192.168.2.21                        #网关地址,这个很重要,如果不设置这个就智能是局域网无法和外部网络互联了

NBOOT=”yes”                                         #开机启动设置为yes

UUID=”fe45f058-9ce7-42a4-823c-abe472aad9f2″

IPV6INIT=no

NETMASK=255.255.255.0                #子网掩码

设置好之后,编辑域名服务器设置文件

代码如下复制代码

# cat /etc/resolv.conf

nameserver 192.168.2.01              #域名服务器的地址,如果不设置这个,则无法以域名的方式访问网站

search hostname                                #这个相当于你本机的域名

设置好了之后重启network服务

代码如下复制代码

# /etc/init.d/network restart

这样执行以下ifconfig命令就能看到你本机已经联网了,可以使用ping 命令去测试是否联网,

友情提示:

直接修改/etc/resolv.conf这个文件是没用的,网络服务重启以后会根据/etc/sysconfig/network-scripts/ifcfg-eth0来重载配置,如果ifcfg-eth0没有配置DNS,那么resolv.conf会被冲掉,重新变成空值。

怎么办呢?下面有两种解决方法:

1、通过ifcfg-eth0也可以设置DNS服务器地址,并自动修改或生成resolv.conf文件.

2、在ifcfg-eth0中可以通过PEERDNS参数决定是否修改resolv.conf文件,设置PEERDNS=yes(这也是系统的默认配置)则启用该网络设备时,会修改或生成resolv.conf文件,设置PEERDNS=no,则不对resolv.conf做任何变动.

补充的部分:

当有应用需要进行域名解析时(如:ping www.111cn.net),会首先读取resolv.conf文件获取dns服务器地址,然后再向该dns服务器发送域名解析请求,若resolv.conf设置的不对或者没有resolv.conf都会导致域名解析失败.

若ifcfg-eth0被配置为DHCP模式,则系统默认PEERDNS=no,也就是会用DHCP获取的DNS地址修改或生成resolv.conf文件.

我觉得没有特殊情况,不用在resolv.conf中设置DNS,应在ifcfg-eth0中设定DNS服务器地址方便些,即符合正常思维也更便于维护和管理.

注意:设置网络的方法仅限于fedora,redhat,centos之类的以rpm包管理的Linux系统,其他系统可能有点差异

篇2:linux中redis安装配置linux操作系统

MySQL是关系型数据库,并不擅长分布式数据出路,因为它缺乏并行执行查询的能力,这时候,可以使用其他工具。如redis。

redis是非关系型数据库。Nosql的一个开源项目。对于简单的键值存储,在复制严重落后的非常高速的访问场景中可以使用redis替代mysql。

redis安装如下。

1、下载安装包,下载地址是servicestack。如我下载的版本是redis-2.0.2.rar。

2、解压文件到相应目录。可以看到解压后内有文件:

3、其中配置文件需要自己创建,现将源代码附在下面:

代码如下复制代码# Redis configuration file example

# By default Redis does not run as a daemon. Use 'yes' if you need it.

# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.

daemonize no

# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.

# You can specify a custom pid file location here.

pidfile /var/run/redis.pid

# Accept connections on the specified port, default is 6379

port 6379

# If you want you can bind a single interface, if the bind option is not

# specified all the interfaces will listen for connections.

#

# bind 127.0.0.1

# Close the connection after a client is idle for N seconds (0 to disable)

timeout 300

# Set server verbosity to 'debug'

# it can be one of:

# debug (a lot of information, useful for development/testing)

# notice (moderately verbose, what you want in production probably)

# warning (only very important / critical messages are logged)

loglevel debug

# Specify the log file name. Also 'stdout' can be used to force

# the demon to log on the standard output. Note that if you use standard

# output for logging but daemonize, logs will be sent to /dev/null

logfile stdout

# Set the number of databases. The default database is DB 0, you can select

# a different one on a per-connection basis using SELECT where

# dbid is a number between 0 and 'databases'-1

databases 16

################################ SNAPSHOTTING #################################

#

# Save the DB on disk:

#

#  save

#

#  Will save the DB if both the given number of seconds and the given

#  number of write operations against the DB occurred.

#

#  In the example below the behaviour will be to save:

#  after 900 sec (15 min) if at least 1 key changed

#  after 300 sec (5 min) if at least 10 keys changed

#  after 60 sec if at least 10000 keys changed

save 900 1

save 300 10

save 60 10000

# Compress string objects using LZF when dump .rdb databases?

# For default that's set to 'yes' as it's almost always a win.

# If you want to save some CPU in the saving child set it to 'no' but

# the dataset will likely be bigger if you have compressible values or keys.

rdbcompression yes

# The filename where to dump the DB

dbfilename dump.rdb

# For default save/load DB in/from the working directory

# Note that you must specify a directory not a file name.

dir ./

################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of

# another Redis server. Note that the configuration is local to the slave

# so for example it is possible to configure the slave to save the DB with a

# different interval, or to listen to another port, and so on.

#

# slaveof

# If the master is password protected (using the “requirepass” configuration

# directive below) it is possible to tell the slave to authenticate before

# starting the replication synchronization process, otherwise the master will

# refuse the slave request.

#

# masterauth

################################## SECURITY ###################################

# Require clients to issue AUTH

before processing any other

# commands. This might be useful in environments in which you do not trust

# others with access to the host running redis-server.

#

# This should stay commented out for backward compatibility and because most

# people do not need auth (e.g. they run their own servers).

#

# requirepass foobared

################################### LIMITS ####################################

# Set the max number of connected clients at the same time. By default there

# is no limit, and it's up to the number of file descriptors the Redis process

# is able to open. The special value '0' means no limts.

# Once the limit is reached Redis will close all the new connections sending

# an error 'max number of clients reached'.

#

# maxclients 128

# Don't use more memory than the specified amount of bytes.

# When the memory limit is reached Redis will try to remove keys with an

# EXPIRE set. It will try to start freeing keys that are going to expire

# in little time and preserve keys with a longer time to live.

# Redis will also try to remove objects from free lists if possible.

#

# If all this fails, Redis will start to reply with errors to commands

# that will use more memory, like SET, LPUSH, and so on, and will continue

# to reply to most read-only commands like GET.

#

# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a

# 'state' server or cache, not as a real DB. When Redis is used as a real

# database the memory usage will grow over the weeks, it will be obvious if

# it is going to use too much memory in the long run, and you'll have the time

# to upgrade. With maxmemory after the limit is reached you'll start to get

# errors for write operations, and this may even lead to DB inconsistency.

#

# maxmemory

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. If you can live

# with the idea that the latest records will be lost if something like a crash

# happens this is the preferred way to run Redis. If instead you care a lot

# about your data and don't want to that a single record can get lost you should

# enable the append only mode: when this mode is enabled Redis will append

# every write operation received in the file appendonly.log. This file will

# be read on startup in order to rebuild the full dataset in memory.

#

# Note that you can have both the async dumps and the append only file if you

# like (you have to comment the “save” statements above to disable the dumps).

# Still if append only mode is enabled Redis will load the data from the

# log file at startup ignoring the dump.rdb file.

#

# The name of the append only file is “appendonly.log”

#

# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append

# log file in background when it gets too big.

appendonly no

# The fsync call tells the Operating System to actually write data on disk

# instead to wait for more data in the output buffer. Some OS will really flush

# data on disk, some other OS will just try to do it ASAP.

#

# Redis supports three different modes:

#

# no: don't fsync, just let the OS flush the data when it wants. Faster.

# always: fsync after every write to the append only log . Slow, Safest.

# everysec: fsync only if one second passed since the last fsync. Compromise.

#

# The default is “always” that's the safer of the options. It's up to you to

# understand if you can relax this to “everysec” that will fsync every second

# or to “no” that will let the operating system flush the output buffer when

# it want, for better performances (but if you can live with the idea of

# some data loss consider the default persistence mode that's snapshotting).

appendfsync always

# appendfsync everysec

# appendfsync no

############################### ADVANCED CONFIG ###############################

# Glue small output buffers together in order to send small replies in a

# single TCP packet. Uses a bit more CPU but most of the times it is a win

# in terms of number of queries per second. Use 'yes' if unsure.

glueoutputbuf yes

# Use object sharing. Can save a lot of memory if you have many common

# string in your dataset, but performs lookups against the shared objects

# pool so it uses more CPU and can be a bit slower. Usually it's a good

# idea.

#

# When object sharing is enabled (shareobjects yes) you can use

# shareobjectspoolsize to control the size of the pool used in order to try

# object sharing. A bigger pool size will lead to better sharing capabilities.

# In general you want this value to be at least the double of the number of

# very common strings you have in your dataset.

#  www.111cn.net

# WARNING: object sharing is experimental, don't enable this feature

# in production before of Redis 1.0-stable. Still please try this feature in

# your development environment so that we can test it better.

# shareobjects no

# shareobjectspoolsize 1024

4、命令行进入安装目录下(或者配置环境变量),

如图,

5、另开一个cmd,输入redis_cli.exe -h 127.0.0.1 -p 6349。接下来,你就可以玩了。

篇3:linux中iptables 防火墙简单设置linux操作系统

般装好的服务器都是没有设置防火墙的,现在我们假设就设置了ssh,开放20端口,其它的都没有设置,那我们到底应该怎么简单快速的做呢?怎么能够快速的设置好apache的访问呢?

用vim打开/etc/sysconfig/iptables,我们先来看一下最终设置好apache80端口访问是什么样:

代码如下复制代码

1、:RH-Firewall-1-INPUT - [0:0]

这里可以理解为定义了一个链RH-Firewall-1-INPUT

代码如下复制代码2、-A INPUT -j RH-Firewall-1-INPUT和-A FORWARD -j RH-Firewall-1-INPUT

这里是把INPUT和FORWARD的所有包都转发到RH-Firewall-1-INPUT,这是重点,也就意味着,只要定义好RH-Firewall-1-INPUT,就定义好了INPUT和FORWARD两个链

代码如下复制代码3、-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

允许80端口的数据包传输,这里的参数都很简单,去百度查一下就知道了

好了,就这么简单,一个80端口的防火墙设置就弄好了~~

那么如何屏蔽来自某个特定国家的 IP 呢?

方法很容易,先到 IPdeny 下载以国家代码编制好的 IP 地址列表,

比如下载 cn.zone:

# wget www.ipdeny.com/ipblocks/data/countries/cn.zone

有了国家的所有 IP 地址,要想屏蔽这些 IP 就很容易了,直接写个脚本逐行读取 cn.zone 文件并加入到 iptables 中:

代码如下复制代码

#!/bin/bash

# Block traffic from a specific country

# written by vpsee.com

COUNTRY = “cn”

IPTABLES = /sbin/iptables

EGREP = /bin/egrep

if [ “$(id -u)” != “0” ]; then

echo “you must be root” 1>&2

exit 1

fi

resetrules() {

$IPTABLES -F

$IPTABLES -t nat -F

$IPTABLES -t mangle -F

$IPTABLES -X

}

resetrules

for c in $COUNTRY

do

country_file = $c.zone

IPS = $($EGREP -v “^#|^$” $country_file)

for ip in $IPS

do

echo “blocking $ip”

$IPTABLES -A INPUT -s $ip -j DROP

done

done

exit 0

篇4:Linux系统中配置构建Postfix文档linux操作系统

在CentOS中,默认的邮件服务器(SMTP方面)是sendmail,但sendmail有若干的缺点,比如,配置复杂、安全漏洞曾被多次发现并且依然存在隐患、邮件发送速度慢等等,这里就不再一一叙述

而另一个被广泛应用于邮件服务方面的“Postfix”的缺点就少得多,或者说它就是针对于sendmail的缺点,而被设计的,对应sendmail的短处,它在各方面也比较成熟。所以,无特殊要求,这里不推荐用sendmail来构建邮件服务器。本站介绍的邮件服务器配置方法,也将基于Postfix。

确认MX记录的添加是否生效的方法:

代码如下复制代码

[root@sample ~]# host -t mx centospub.com

centospub.com mail is handled by 10 mail.centospub.com. 确认MX记录生效

然后安装postfix

代码如下复制代码

[root@sample ~]# yum -y install postfix  在线安装Postfix

对postfix进行配置

代码如下复制代码

[root@sample ~]# vi /etc/postfix/main.cf  编辑Postfix的配置文件

#myhostname = host.domain.tld 找到此行,将等号后面的部分改写为主机名

myhostname = sample.centospub.com  变为此状态,设置系统的主机名

#mydomain = domain.tld 找到此行,将等号后面的部分改写为域名

mydomain = centospub.com  变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)

#myorigin = $mydomain  找到此行,将行首的#去掉

myorigin = $mydomain  变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)

inet_interfaces = localhost  找到此行,将“localhost”改为“all”

inet_interfaces = all 变为此状态,接受来自所有网络的请求

mydestination = $myhostname, localhost.$mydomain, localhost  找到此行,在行为添加“$mydomain”

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  变为此状态,指定发给本地邮件的域名

#relay_domains = $mydestination  找到此行,将行首的#去掉

relay_domains = $mydestination  变为此状态,定义允许转发的域名

#mynetworks = 168.100.189.0/28, 127.0.0.0/8  找到此行,依照自己的内网情况修改

mynetworks = 168.100.189.0/28, 127.0.0.0/8  变为此状态,指定内网和本地的IP地址范围

#home_mailbox = Maildir/  找到这一行,去掉行首的#

home_mailbox = Maildir/  变为此状态,指定用户邮箱目录

# SHOW SOFTWARE VERSION OR NOT

#

# The smtpd_banner parameter specifies the text that follows the 220

# code in the SMTP server’s greeting banner. Some people like to see

# the mail version advertised. By default, Postfix shows no version.

#

# You MUST specify $myhostname at the start of the text. That is an

# RFC requirement. Postfix itself does not care.

#

#smtpd_banner = $myhostname ESMTP $mail_name

#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  找到这一行,接此行添加如下行:

smtpd_banner = $myhostname ESMTP unknow  添加这一行,不显示SMTP服务器的相关信息

在配置文件的文尾,添加如下行:

smtpd_sasl_auth_enable = yes  服务器使用SMTP认证

smtpd_sasl_local_domain = $myhostname  指定SMTP认证的本地域名(主机名)

smtpd_sasl_security_options = noanonymous   不允许匿名的方式认证

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

message_size_limit = 15728640 规定邮件最大尺寸为15MB

2、配置SMTP认证的相关选项

为了提高安全性,我们不将系统用户的密码作为相应用户SMTP认证的密码,而将在后面为用户建立SMTP认证专用的密码。

代码如下复制代码

[root@sample ~]# vi /usr/lib/sasl2/smtpd.conf  编辑SMTP认证的配置文件

pwcheck_method: saslauthd  找到此行,将“saslauthd”改为“auxprop”

pwcheck_method: auxprop  不使用系统用户密码作为用户的SMTP认证密码

[root@sample ~]# vi /etc/sysconfig/saslauthd

MECH=shadow  找到这一行,在前面加#

#MECH=shadow  不使用shadow机制

FLAGS= 找到此行,在等号后面添加“sasldb”

FLAGS=sasldb   定义认证方式为sasldb2

3、建立用户的邮箱目录

首先建立用户模板下的邮箱目录,以便于建立新用户时,相应用户的邮箱目录自动被建立,

代码如下复制代码

[root@sample ~]# mkdir /etc/skel/Maildir  在用户模板下建立用户邮箱目录

[root@sample ~]# chmod 700 /etc/skel/Maildir  设置用户邮箱目录属性为700

然后再为已经存在的用户创建相应有项目了。 www.111cn.net

代码如下复制代码

[root@sample ~]# mkdir /home/centospub/Maildir 为用户(这里以centospub用户为例)建立邮箱目录

[root@sample ~]# chmod 700 /home/centospub/Maildir  设置该用户邮箱目录属性为700

[root@sample ~]# chown centospub. /home/centospub/Maildir  设置该用户邮箱目录为该用户所有

4、为用户设置smtp认证密码

代码如下复制代码

[root@sample ~]# saslpasswd2 -u sample.centospub.com -c centospub  为centospub用户设置SMTP认证密码

Password: 在这里输入密码(不会显示)

Again (for verification): 再次输入密码

5、改变SALS的属性及归属

代码如下复制代码

[root@sample ~]# chgrp postfix /etc/sasldb2 将数据库归属改为postfix,

[root@sample ~]# chmod 640 /etc/sasldb2   将数据库属性改为640

6、关闭sendmail服务及设置默认MTA

因为在用Postfix作为SMTP服务器的前提下,我们不准备再用sendmail,所以将sendmail服务关掉,以确保安全及节省系统资源。

代码如下复制代码

[root@sample ~]# /etc/rc.d/init.d/sendmail stop  关闭sendmail服务

Shutting down sendmail: [ OK ]

Shutting down sm-client: [ OK ]

[root@sample ~]# chkconfig sendmail off  关闭sendmail自启动

[root@sample ~]# chkconfig –list sendmail 确认sendmail自启动已被关闭(都为off就OK)

sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off

然后再将默认的MTA设置为Postfix。

代码如下复制代码

[root@sample ~]# alternatives –config mta 设置默认MTA

There are 2 programs which provide ’mta’.

Selection Command

———————————————–

1 /usr/sbin/sendmail.sendmail 当前状态:sendmail为默认MTA

2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number:

2 在这里输入2,使Postfix成为默认MTA

启动相应服务

最后,启动SMTP认证及Postfix服务,并设置相应服务为自启动。

代码如下复制代码

[root@sample ~]# chkconfig saslauthd on  将SMTP-Auth设置为自启动

[root@sample ~]# chkconfig –list saslauthd  确认SMTP-Auth服务状态

saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off  确认2~5为on的状态就OK

[root@sample ~]# /etc/rc.d/init.d/saslauthd start  启动SMTP-Auth

Starting saslauthd: [ OK ]

[root@sample ~]# chkconfig postfix on  将Postfix设置为自启动

[root@sample ~]# chkconfig –list postfix  确认Postfix服务状态

postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off  确认2~5为on的状态就OK

[root@sample ~]# /etc/rc.d/init.d/postfix start  启动Postfix

Starting postfix: [ OK ]

至此,就完成了SMTP服务器方面的配置,但目前只具从备客户端通过服务器发送邮件的功能。做为完整的邮件服务器,还需具备从客户端通过POP/IMAP协议接受邮件到本地的功能。

篇5:linux中Virtualmin安装配置教程linux操作系统

我们在上篇文章已经安装Virtualmin的面板,下面我们就是开始进行最简单的配置过程,希望本文章对各位同学会带来帮助哦,

进入后台

你的IP地址或者是主机名:10000/

输入地址进入后是webmin的默认登录界面

帐号:root

密码:你的VPS的密码

进入后需要我们初始化Virtualmin

Introduction

提示一下内容:

This post-installation wizard allows you to configure Virtualmin optimally for your system. You can make selections depending on whether you want to host websites, email or databases, and based on your system's memory and CPU power.

To continue, click the Next button below. To skip it and use the default settings, click Cancel.

我们点击“next”进入下一步

Memory use

这里就是让我们选择是否使用Virtualmin libraries与邮件域名查询服务器,如果不需要默认就好了(默认是不使用的)

接着我们点击“next”

Virus scanning

这里是让我选择是否需要病毒扫描器,也是不需要的。如果你有特别需求可以开启的!

再次点击“next”

Spam filtering

SpamAssassin server是一个垃圾邮件过滤系统,看看你自己要不要搭建邮件服务器,搭建的还是有必要打开的!

依旧是“next”

Database servers

这里就是选择相应的数据库的时候了,其实也可以直接默认的,看看你需不需PostgreSQL数据库了,需要的就打开,不需要则点击“next”

MySQL password

这里就是至关重要的一步了,设置MySQL数据库的密码,

要记住,因为下面我们需要的!

输入要设置的Mysql的密码后,点击“next”

MySQL database size

这里就是让我们选择mysql数据库的占用大小,如果对mysql数据库没有特别大的需要,直接选择默认设置或者是256的那行!

选择好mysql数据库后点击“next”

最后一步就是设置“主域名服务器”,系统会对你设置的主域名服务器进行检查,这里我推荐直接在后面的“Skip check for resolvability”前方打上对勾就可跳过检查!

然后点击“next”进入下一步

最后一步就是选择密码的存储方式,我推荐选择webmin默认的,毕竟跟密码有关,所以还是选择强度大点的好!

我们已经配置好基本的设置,现在只需要点击“next”即可。

最后是我们选择相应的插件查看的两个页面,直接“next”就大功告成了!

让我们来看看virtualmin的界面:

从上面可以看出来,安装后近占用了少量的内存

篇6:Linux中iptables防火墙配置指南linux操作系统

iptables是linux系统中一个很重要的功能,它就windows防火墙了,但iptables比windows防火墙能力要强多了,下面我来给大家介绍一些iptables配置方法,

一、安装软件

我们购买的VPS,一般都已经预装iptables,可以先检查下iptables状态,确认是否安装。

service iptables status若提示为iptables:unrecognized service,则需要安装。yum install iptables  #CentOS系统apt-get install iptables   #Debian系统二、配置规则以下命令我们以CentOS为例,敬请留意。安装好的iptables配置文件在/etc/sysconfig/iptables,默认的iptables我们可以无视之,采用下面的命令,清除默认规则。iptables –Fiptables –Xiptables –Z接下来,添加我们自己的iptalbes规则,开放指定端口,关闭危险端口之类。,以下,是一个简单的规则:#允许本地回环接口(即运行本机访问本机)

iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

# 允许已建立的或相关连的通行

iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

#允许所有本机向外的访问

iptables -A OUTPUT -j ACCEPT

# 允许访问22端口

iptables -A INPUT -p tcp –dport 22 -j ACCEPT

#允许访问80端口

iptables -A INPUT -p tcp –dport 80 -j ACCEPT

#允许FTP服务的21和20端口

iptables -A INPUT -p tcp –dport 21 -j ACCEPT

iptables -A INPUT -p tcp –dport 20 -j ACCEPT

#如果有其他端口的话,规则也类似,稍微修改上述语句就行

#禁止其他未允许的规则访问

iptables -A INPUT -j REJECT (注意:如果22端口未加入允许规则,SSH链接会直接断开。)

iptables -A FORWARD -j REJECT

如果还有需要开启的端口,可以在上面添加,然后,保存规则并重启。

service iptables save   #保存

或者/etc/rc.d/init.d/iptables save

service iptables restart    #重启

在写到iptalbes规则的时候,我这里列出可能涉及的其他规则,譬如禁止单个IP:

-A INPUT -s 1.2.3.4 -j DROP三、查询修改及删除iptables -L –n   #查询规则iptables -L -n --line-numbers #将规则按数字序号显示方便删除iptables -D INPUT 4  #删除第四条规则四、设定开机启动chkconfig iptables on五、其他规则以下部分规则,大家可以做些参考,

# 打开 syncookie (轻量级预防 DOS 攻击)

sysctl -w net.ipv4.tcp_syncookies=1 &>/dev/null

# 设置默认 TCP 连接痴呆时长为 3800 秒(此选项可以大大降低连接数)

sysctl -w net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3800 &>/dev/null

# 设置支持最大连接树为 30W(这个根据内存和 iptables 版本来,每个 connection 需要 300 多个字节)

sysctl -w net.ipv4.ip_conntrack_max=300000 &>/dev/null

# 防止SYN攻击 轻量

iptables -N syn-flood

iptables -A INPUT -p tcp –syn -j syn-flood

iptables -A syn-flood -p tcp -m limit –limit 3/s –limit-burst 6 -j RETURN

iptables -A syn-flood -j REJECT

# 对于不管来自哪里的ip碎片都进行控制,允许每秒通过100个碎片

iptables -A FORWARD -f -m limit –limit 100/s –limit-burst 100 -j ACCEPT

# icmp包通过的控制,防止icmp 攻击

iptables -A FORWARD -p icmp -m limit –limit 1/s –limit-burst 10 -j ACCEPT

# 丢弃坏的TCP包

iptables -A FORWARD -p TCP ! –syn -m state –state NEW -j LOG –log-prefix “New not syn:”

iptables -A FORWARD -p TCP ! –syn -m state –state NEW -j DROP

下面给大家推荐一款更详细的 linux/iptables.htm">linux iptables配置教程 www.111cn.net/sys/linux/iptables.htm

篇7:linux系统中配置vsftpd及用户权限linux操作系统

vsftpd服务器是linux中一个非常实用的文件上传管理工具了,下面我就来给大家介绍在vps中关于vsftpd配置与权限分配方法,希望例子对大家会有所帮助,

先确认下安装上了没,可以使用

代码如下复制代码

[root@localhost sv005-mongodb]# service vsftpd restart

Shutting down vsftpd:                                     [ OK ]

Starting vsftpd for vsftpd:                               [ OK ]

或者使用命令

[root@localhost sv005-mongodb]# chkconfig --list vsftpd

vsftpd         0:off  1:off  2:off  3:off  4:off  5:off  6:off

如果没有安装我们需要先是需要安装:

代码如下复制代码

yum install vsftpd

然后启动vsftpd : /etc/init.d/vsftpd start

vi /etc/vsftpd/vsftpd.conf  修改里面的 这两项:

chroot_local_user=YES (须添加)

chroot_list_enable=NO

然后 保存即可!

创建用户组:

groupadd   用户组

useradd -g webusers -d /路径 用户名

passwd 用户名  修改用户的密码。

chown -R 用户名:用户组 /路径/

刚才由于修改了配置文件 所以要记得重启:service vsftpd restart

OK ! 成功了!

到上面就完成了,如果你还需要加一些虚拟用户,我们可向下看

vsFTPD配置虚拟用户

FTP用户一般是不能登录系统的,这也是为了安全。在系统中,没有权限登录系统的用户一般也被称之为虚拟用户;虚拟用户也是要写进 /etc/passwd中;这只是一种虚拟用户的方法,但说实在的并不是真正的虚拟用户,只是把他登录SHELL的权限去掉了,所以他没有能力登录系统;如果我们想把beinan这个用户目录定位在/opt/beinan这个目录中,并且不能登录系统;我们应该如下操作。

代码如下复制代码[root@localhost ~]# adduser -d /opt/beinan -g ftp -s /sbin/nologin beinan

[root@localhost ~]# passwd beinan

Changing password for user beinan.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@localhost ~]#

其实这还是不够的,还要改一下配置文件vsftpd.conf ,以确保本地虚拟用户能有读写权限;

local_enable=YES

write_enable=YES

local_umask=022

如何实现虚拟路径?

比如:

代码如下复制代码/home/a 映射为 ftp://localhost/a

/home/b/c 则为 ftp://localhost/c

可以通过如下的方法来实现,

[root@localhost ~]# mount –bind [原有的目录] [新目录]

比如我的ftp的默认目录是/var/ftp,我想把/mnt/LinG/WinSoft文件夹,映射到/var/ftp目录中,我就如下操作

我们要先在/var/ftp目录中建一个目录

代码如下复制代码[root@localhost ~]# mkdir /var/ftp/WinSoft

然后执行mount命令

[root@localhost ~]# mount –bind /mnt/LinG/WinSoft /var/ftp/WinSoft

这样就OK了。

打开Linux vsFTPDv服务器的日志功能

把下面xferlog_file前面的#号对掉,也就是把vsftp的log功能打开,这样我们就能在/var/log目录下查看vsftpd.log。这是vsFTP的日志功能,这对于我们来说是极为重要的。xferlog_file=/var/log/vsftpd.log如何让vsFTP服务器限制链接数,以及每个IP最大的链接数?应该改Linux vsFTPD服务器的配制文件vsftpd.conf,加入下面的两行:

max_clients=数字

max_per_ip=数字

举例:我想让我的vsFTP最大支持链接数为100个,每个IP,最多能支持5个链接,所以我应该在vsftpd.conf中加上如下的两行:

max_clients=100

max_per_ip=5

如何限制传输速度?

anon_max_rate=数字

注:这是匿名的速度

local_max_rate=数字

注:这是vsFTP服务器上本地用户的速度

注:这个数字的单位是byte,所以我们要计算一下。

比如我想让匿名用户和vsFTP上的用户都以80KB下载,所以这个数字应该是1024×80=81920

所以我们要在vsftpd.conf中加入下面的两行

anon_max_rate=81920

local_max_rate=81920

下面是一些常用的命令:

管理用户组(group)的工具或命令;

groupadd 注:添加用户组;

groupdel 注:删除用户组;

groupmod 注:修改用户组信息

groups 注:显示用户所属的用户组

用户管理命令

useradd 注:添加用户

userdel 注 :删除用户

adduser 注:添加用户

passwd 注:为用户设置密码

usermod 注:修改用户命令,可以通过usermod 来修改登录名、用户的家目录等等;

【Linux中网络如何设置配置linux操作系统】相关文章:

1.linux中Cent OS SVN 服务配置学习笔记linux操作系统

2.linux中Ubuntu Server安装和配置VNCServer介绍linux操作系统

3.网络摄像机?什么是操作系统

4.tomcat配置ip限制访问实例介绍linux操作系统

5.巧妙配置 用交换机控制网络

6.巧妙设置DNS 网络加速

7.linux系统下rsync文件同步配置工作笔记linux操作系统

8.YY歪歪中频道怎么设置权限?YY频道权限操作教程网络技巧

9.如何备份CISCO路由器的配置网络知识

10.设置ADSLMODEM的路由功能网络知识

下载word文档
《Linux中网络如何设置配置linux操作系统.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度: 评级1星 评级2星 评级3星 评级4星 评级5星
点击下载文档

文档为doc格式

  • 返回顶部