Ubuntu Server Guide Changes, errors and bugs
Note The Serial Number of your zone file will probably be different. Quick temporary query logging
Download 1.27 Mb. Pdf ko'rish
|
ubuntu-server-guide
- Bu sahifa navigatsiya:
- Anonymous FTP Configuration
- User Authenticated FTP Configuration
- References • See the vsftpd website for more information. File Servers
- Domain Name Service (DNS) TBD iSCSI Initiator (or Client) Wikipedia iSCSI Definition: iSCSI an acronym for Internet Small Computer Systems Interface
- Network Interfaces Configuration
Note The Serial Number of your zone file will probably be different. Quick temporary query logging With the rndc tool, you can quickly turn query logging on and off, without restarting the service or changing the configuration file. To turn query logging on, run: sudo rndc q u e r y l o g on Likewise, to turn it off, run: sudo rndc q u e r y l o g o f f The logs will be sent to syslog and will show up in /var/log/syslog by default: Jan 20 1 9 : 4 0 : 5 0 new−n1 named [ 8 1 6 ] : r e c e i v e d c o n t r o l c h a n n e l command ’ q u e r y l o g on ’ Jan 20 1 9 : 4 0 : 5 0 new−n1 named [ 8 1 6 ] : query l o g g i n g i s now on Jan 20 1 9 : 4 0 : 5 7 new−n1 named [ 8 1 6 ] : c l i e n t @0x7f48ec101480 1 9 2 . 1 6 8 . 1 . 1 0 # 3 6 1 3 9 ( ubuntu . com ) : query : ubuntu . com IN A +E( 0 )K ( 1 9 2 . 1 6 8 . 1 . 1 0 ) Note The amount of logs generated by enabling querylog could be huge! 159 Logging BIND9 has a wide variety of logging configuration options available, but the two main ones are channel and category, which configure where logs go, and what information gets logged, respectively. If no logging options are configured the default configuration is: l o g g i n g { c a t e g o r y d e f a u l t { d e f a u l t _ s y s l o g ; de f a u l t _ d e b u g ; } ; c a t e g o r y unmatched { n u l l ; } ; } ; Let’s instead configure BIND9 to send debug messages related to DNS queries to a separate file. We need to configure a channel to specify which file to send the messages to, and a category. In this example, the category will log all queries. Edit /etc/bind/named.conf.local and add the following: l o g g i n g { c h a n n e l query . l o g { f i l e ”/ var / l o g /named/ query . l o g ” ; s e v e r i t y debug 3 ; } ; c a t e g o r y q u e r i e s { query . l o g ; } ; } ; Note The debug option can be set from 1 to 3. If a level isn’t specified, level 1 is the default. • Since the named daemon runs as the bind user the /var/log/named directory must be created and the ownership changed: sudo mkdir / var / l o g /named sudo chown bind : bind / var / l o g /named • Now restart BIND9 for the changes to take effect: sudo s y s t e m c t l r e s t a r t bind9 . s e r v i c e You should see the file /var/log/named/query.log fill with query information. This is a simple example of the BIND9 logging options. For coverage of advanced options see More Information. References Common Record Types This section covers some of the most common DNS record types. • A record: This record maps an IP Address to a hostname. www IN A 1 9 2 . 1 6 8 . 1 . 1 2 • CNAME record: Used to create an alias to an existing A record. You cannot create a CNAME record pointing to another CNAME record. web IN CNAME www • MX record: Used to define where email should be sent to. Must point to an A record, not a CNAME. 160 @ IN MX 1 m a i l . example . com . m a i l IN A 1 9 2 . 1 6 8 . 1 . 1 3 • NS record: Used to define which servers serve copies of a zone. It must point to an A record, not a CNAME. This is where Primary and Secondary servers are defined. @ IN NS ns . example . com . @ IN NS ns2 . example . com . ns IN A 1 9 2 . 1 6 8 . 1 . 1 0 ns2 IN A 1 9 2 . 1 6 8 . 1 . 1 1 More Information • Upstream BIND9 Documentation • Bind9.net has links to a large collection of DNS and BIND9 resources. • DNS and BIND is a popular book now in it’s fifth edition. There is now also a DNS and BIND on IPv6 book. • A great place to ask for BIND9 assistance, and get involved with the Ubuntu Server community, is the #ubuntu-server IRC channel on freenode. FTP Server File Transfer Protocol (FTP) is a TCP protocol for downloading files between computers. In the past, it has also been used for uploading but, as that method does not use encryption, user credentials as well as data transferred in the clear and are easily intercepted. So if you are here looking for a way to upload and download files securely, see the OpenSSH documentation instead. FTP works on a client/server model. The server component is called an FTP daemon. It continuously listens for FTP requests from remote clients. When a request is received, it manages the login and sets up the connection. For the duration of the session it executes any of commands sent by the FTP client. Access to an FTP server can be managed in two ways: • Anonymous • Authenticated In the Anonymous mode, remote clients can access the FTP server by using the default user account called “anonymous” or “ftp” and sending an email address as the password. In the Authenticated mode a user must have an account and a password. This latter choice is very insecure and should not be used except in special circumstances. If you are looking to transfer files securely see SFTP in the section on OpenSSH-Server. User access to the FTP server directories and files is dependent on the permissions defined for the account used at login. As a general rule, the FTP daemon will hide the root directory of the FTP server and change it to the FTP Home directory. This hides the rest of the file system from remote sessions. vsftpd - FTP Server Installation vsftpd is an FTP daemon available in Ubuntu. It is easy to install, set up, and maintain. To install vsftpd you can run the following command: sudo apt i n s t a l l v s f t p d 161 Anonymous FTP Configuration By default vsftpd is not configured to allow anonymous download. If you wish to enable anonymous download edit /etc/vsftpd.conf by changing: anonymous_enable=YES During installation a ftp user is created with a home directory of /srv/ftp. This is the default FTP directory. If you wish to change this location, to /srv/ files /ftp for example, simply create a directory in another location and change the ftp user’s home directory: sudo mkdir −p / s r v / f i l e s / f t p sudo usermod −d / s r v / f i l e s / f t p f t p After making the change restart vsftpd: sudo s y s t e m c t l r e s t a r t v s f t p d . s e r v i c e Finally, copy any files and directories you would like to make available through anonymous FTP to /srv/ files /ftp, or /srv/ftp if you wish to use the default. User Authenticated FTP Configuration By default vsftpd is configured to authenticate system users and allow them to download files. If you want users to be able to upload files, edit /etc/vsftpd.conf: w r i t e _ e n a b l e=YES Now restart vsftpd: sudo s y s t e m c t l r e s t a r t v s f t p d . s e r v i c e Now when system users login to FTP they will start in their home directories where they can download, upload, create directories, etc. Similarly, by default, anonymous users are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line, and restart vsftpd: anon_upload_enable=YES Warning Enabling anonymous FTP upload can be an extreme security risk. It is best to not enable anonymous upload on servers accessed directly from the Internet. The configuration file consists of many configuration parameters. The information about each parameter is available in the configuration file. Alternatively, you can refer to the man page, man 5 vsftpd.conf for details of each parameter. Securing FTP There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting: c h r o o t _ l o c a l _ u s e r=YES You can also limit a specific list of users to just their home directories: 162 c h r o o t _ l i s t _ e n a b l e=YES c h r o o t _ l i s t _ f i l e =/ e t c / v s f t p d . c h r o o t _ l i s t After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line. Then restart vsftpd: sudo s y s t e m c t l r e s t a r t v s f t p d . s e r v i c e Also, the /etc/ftpusers file is a list of users that are disallowed FTP access. The default list includes root, daemon, nobody, etc. To disable FTP access for additional users simply add them to the list. FTP can also be encrypted using FTPS. Different from SFTP, FTPS is FTP over Secure Socket Layer (SSL). SFTP is a FTP like session over an encrypted SSH connection. A major difference is that users of SFTP need to have a shell account on the system, instead of a nologin shell. Providing all users with a shell may not be ideal for some environments, such as a shared web host. However, it is possible to restrict such accounts to only SFTP and disable shell interaction. To configure FTPS, edit /etc/vsftpd.conf and at the bottom add: s s l _ e n a b l e=YES Also, notice the certificate and key related options: r s a _ c e r t _ f i l e =/ e t c / s s l / c e r t s / s s l −c e r t −s n a k e o i l . pem r s a _ p r i v a t e _ k e y _ f i l e=/ e t c / s s l / p r i v a t e / s s l −c e r t −s n a k e o i l . key By default these options are set to the certificate and key provided by the ssl-cert package. In a production environment these should be replaced with a certificate and key generated for the specific host. For more information on certificates see Security - Certificates. Now restart vsftpd, and non-anonymous users will be forced to use FTPS: sudo s y s t e m c t l r e s t a r t v s f t p d . s e r v i c e To allow users with a shell of /usr/sbin/nologin access to FTP, but have no shell access, edit /etc/ shells adding the nologin shell: # / e t c / s h e l l s : v a l i d l o g i n s h e l l s / b i n / c s h / b i n / sh / u s r / b i n / e s / u s r / b i n / ksh / b i n / ksh / u s r / b i n / r c / u s r / b i n / t c s h / b i n / t c s h / u s r / b i n / e s h / b i n / dash / b i n / bash / b i n / rb a sh / u s r / b i n / s c r e e n / u s r / s b i n / n o l o g i n This is necessary because, by default vsftpd uses PAM for authentication, and the /etc/pam.d/vsftpd con- figuration file contains: auth r e q u i r e d pam_shells . s o 163 The shells PAM module restricts access to shells listed in the /etc/ shells file. Most popular FTP clients can be configured to connect using FTPS. The lftp command line FTP client has the ability to use FTPS as well. References • See the vsftpd website for more information. File Servers If you have more than one computer on a single network. At some point you will probably need to share files between them. In this section we cover installing and configuring FTP, NFS, and CUPS. Domain Name Service (DNS) TBD iSCSI Initiator (or Client) Wikipedia iSCSI Definition: iSCSI an acronym for Internet Small Computer Systems Interface , an Internet Protocol (IP)-based storage networking standard for linking data storage facilities. It provides block-level access to storage devices by carrying SCSI commands over a TCP/IP network. iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances. It can be used to transmit data over local area networks (LANs), wide area networks (WANs), or the Internet and can enable location-independent data storage and retrieval. The protocol allows clients (called initiators) to send SCSI commands (CDBs) to storage devices (targets) on remote servers. It is a storage area network (SAN) protocol, allowing organizations to consolidate storage into storage arrays while providing clients (such as database and web servers) with the illusion of locally attached SCSI disks. It mainly competes with Fibre Channel, but unlike traditional Fibre Channel, which usually requires dedicated cabling, iSCSI can be run over long distances using existing network infras- tructure. Ubuntu Server can be configured as both: iSCSI initiator and iSCSI target. This guide provides com- mands and configuration options to setup an iSCSI initiator (or Client). Note: It is assumed that you already have an iSCSI target on your local network and have the appropriate rights to connect to it. The instructions for setting up a target vary greatly between hardware providers, so consult your vendor documentation to configure your specific iSCSI target. Network Interfaces Configuration Before start configuring iSCSI, make sure to have the network interfaces correctly set and configured in order to have open-iscsi package to behave appropriately, specially during boot time. In Ubuntu 20.04 LTS, the default network configuration tool is netplan.io. 164 For all the iSCSI examples bellow please consider the following netplan configuration for my iSCSI initiator: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg { c o n f i g : d i s a b l e d } /etc/netplan/50-cloud-init.yaml network : e t h e r n e t s : enp5s0 : match : macaddress : 0 0 : 1 6 : 3 e : a f : c4 : d6 s e t −name : e t h 0 dhcp4 : t r u e dhcp− i d e n t i f i e r : mac enp6s0 : match : macaddress : 0 0 : 1 6 : 3 e : 5 0 : 1 1 : 9 c s e t −name : i s c s i 0 1 dhcp4 : t r u e dhcp− i d e n t i f i e r : mac dhcp4−o v e r r i d e s : r o u t e −m e t r i c : 300 enp7s0 : match : macaddress : 0 0 : 1 6 : 3 e : b3 : c c : 5 0 s e t −name : i s c s i 0 2 dhcp4 : t r u e dhcp− i d e n t i f i e r : mac dhcp4−o v e r r i d e s : r o u t e −m e t r i c : 300 v e r s i o n : 2 r e n d e r e r : networkd With this configuration, the interfaces names change by matching their mac addresses. This makes it easier to manage them in a server containing multiple interfaces. From this point and beyond, 2 interfaces are going to be mentioned: iscsi01 and iscsi02. This helps to demonstrate how to configure iSCSI in a multipath environment as well (check the Device Mapper Multipath session in this same Server Guide). If you have only a single interface for the iSCSI network, make sure to follow the same instructions, but only consider the iscsi01 interface command line examples. iSCSI Initiator Install To configure Ubuntu Server as an iSCSI initiator install the open-iscsi package. In a terminal enter: $ sudo apt i n s t a l l open− i s c s i Once the package is installed you will find the following files: • /etc/iscsi/iscsid.conf • /etc/iscsi/initiatorname.iscsi 165 iSCSI Initiator Configuration Configure the main configuration file like the example bellow: /etc/iscsi/iscsid.conf ### s t a r t u p s e t t i n g s ## w i l l be c o n t r o l l e d by systemd , l e a v e a s i s i s c s i d . s t a r t u p = / u s r / s b i n / i s c s i d n o d e . s t a r t u p = manual ### chap s e t t i n g s # node . s e s s i o n . auth . authmethod = CHAP ## a u t h e n t i c a t i o n o f i n i t i a t o r by t a r g e t ( s e s s i o n ) # node . s e s s i o n . auth . username = username # node . s e s s i o n . auth . password = password # d i s c o v e r y . s e n d t a r g e t s . auth . authmethod = CHAP ## a u t h e n t i c a t i o n o f i n i t i a t o r by t a r g e t ( d i s c o v e r y ) # d i s c o v e r y . s e n d t a r g e t s . auth . username = username # d i s c o v e r y . s e n d t a r g e t s . auth . password = password ### t i m e o u t s ## c o n t r o l how much time i s c s i t a k e s t o p r o p a g a t e an e r r o r t o t h e ## upper l a y e r . i f u s i n g multipath , having 0 h e r e i s d e s i r a b l e ## s o m u l t i p a t h can h a n d l e path e r r o r s a s q u i c k l y a s p o s s i b l e ## ( and d e c i d e t o queue o r not i f m i s s i n g a l l p a t h s ) node . s e s s i o n . timeo . replacement_timeout = 0 node . conn [ 0 ] . timeo . l o g i n _ t i m e o u t = 15 node . conn [ 0 ] . timeo . l o g o u t _ t i m e o u t = 15 ## i n t e r v a l f o r a NOP−Out r e q u e s t ( a p i n g t o t h e t a r g e t ) node . conn [ 0 ] . timeo . noop_out_interval = 5 ## and how much time t o w a i t b e f o r e d e c l a r i n g a t i m e o u t node . conn [ 0 ] . timeo . noop_out_timeout = 5 ## d e f a u l t t i m e o u t s f o r e r r o r r e c o v e r y l o g i c s ( l u & t g t r e s e t s ) node . s e s s i o n . err_timeo . abort_timeout = 15 node . s e s s i o n . err_timeo . l u _ r e s e t _ t i m e o u t = 30 node . s e s s i o n . err_timeo . t g t _ r e s e t _ t i m e o u t = 30 ### r e t r y node . s e s s i o n . i n i t i a l _ l o g i n _ r e t r y _ m a x = 8 ### s e s s i o n and d e v i c e queue depth node . s e s s i o n . cmds_max = 128 node . s e s s i o n . queue_depth = 32 166 ### p e r f o r m a n c e node . s e s s i o n . x m i t _ t h r e a d _ p r i o r i t y = −20 and re-start the iSCSI daemon: $ s y s t e m c t l r e s t a r t i s c s i d . s e r v i c e This will set basic things up for the rest of configuration. The other file mentioned: /etc/iscsi/initiatorname.iscsi I n i t i a t o r N a m e=i q n .1993 −08. o r g . d e b i a n : 0 1 : 6 0 f 3 5 1 7 8 8 4 c 3 contains this node’s initiator name and is generated during open-iscsi package installation. If you modify this setting, make sure that you don’t have duplicates in the same iSCSI SAN (Storage Area Network). iSCSI Network Configuration Before configuring the Logical Units that are going to be accessed by the initiator, it is important to inform the iSCSI service what are the interfaces acting as paths. A straightforward way to do that is by: • configuring the following environment variables $ i s c s i 0 1 _ i p=$ ( i p −4 −o addr show i s c s i 0 1 | s e d −r ’ s : . * ( ( [ 0 − 9 ] { 1 , 3 } \ . ) { 3 } [ 0 − 9 ] { 1 , 3 } ) / . * : \ 1 : ’ ) $ i s c s i 0 2 _ i p=$ ( i p −4 −o addr show i s c s i 0 2 | s e d −r ’ s : . * ( ( [ 0 − 9 ] { 1 , 3 } \ . ) { 3 } [ 0 − 9 ] { 1 , 3 } ) / . * : \ 1 : ’ ) $ i s c s i 0 1 _ m a c=$ ( i p −o l i n k show i s c s i 0 1 | s e d −r ’ s : . * \ s+l i n k / e t h e r (([0 − f ] { 2 } ( \ : | ) ) { 6 } ) . * : \ 1 : g ’ ) $ i s c s i 0 2 _ m a c=$ ( i p −o l i n k show i s c s i 0 2 | s e d −r ’ s : . * \ s+l i n k / e t h e r (([0 − f ] { 2 } ( \ : | ) ) { 6 } ) . * : \ 1 : g ’ ) • configuring iscsi01 interface $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 1 −−op=new New i n t e r f a c e i s c s i 0 1 added $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 1 −−op=update −n i f a c e . hwaddress −v $ i s c s i 0 1 _ m a c i s c s i 0 1 updated . $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 1 −−op=update −n i f a c e . i p a d d r e s s −v $ i s c s i 0 1 _ i p i s c s i 0 1 updated . • configuring iscsi02 interface $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 2 −−op=new New i n t e r f a c e i s c s i 0 2 added $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 2 −−op=update −n i f a c e . hwaddress −v $ i s c s i 0 2 _ m a c i s c s i 0 2 updated . 167 $ sudo i s c s i a d m −m i f a c e −I i s c s i 0 2 −−op=update −n i f a c e . i p a d d r e s s −v $ i s c s i 0 2 _ i p i s c s i 0 2 updated . • discovering the targets $ sudo i s c s i a d m −m d i s c o v e r y −I i s c s i 0 1 −−op=new −−op=d e l −−type s e n d t a r g e t s −−p o r t a l s t o r a g e . i s c s i 0 1 1 0 . 2 5 0 . 9 4 . 9 9 : 3 2 6 0 , 1 i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c 0 8 4 c 8 3 2 0 c a $ sudo i s c s i a d m −m d i s c o v e r y −I i s c s i 0 2 −−op=new −−op=d e l −−type s e n d t a r g e t s −−p o r t a l s t o r a g e . i s c s i 0 2 1 0 . 2 5 0 . 9 3 . 9 9 : 3 2 6 0 , 1 i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c 0 8 4 c 8 3 2 0 c a • configuring automatic login $ sudo i s c s i a d m −m node −−op=update −n node . conn [ 0 ] . s t a r t u p −v a u t o m a t i c $ sudo i s c s i a d m −m node −−op=update −n node . s t a r t u p −v a u t o m a t i c • make sure needed services are enabled during OS initialization: $ s y s t e m c t l e n a b l e open− i s c s i S y n c h r o n i z i n g s t a t e o f open− i s c s i . s e r v i c e with SysV s e r v i c e s c r i p t with / l i b / systemd / systemd−sysv− i n s t a l l . E x e c u t i n g : / l i b / systemd / systemd−sysv− i n s t a l l e n a b l e open− i s c s i Created s y m li n k / e t c / systemd / system / i s c s i . s e r v i c e → / l i b / systemd / system / open− i s c s i . s e r v i c e . Created s y m li n k / e t c / systemd / system / s y s i n i t . t a r g e t . wants / open− i s c s i . s e r v i c e → / l i b / systemd / system / open− i s c s i . s e r v i c e . $ s y s t e m c t l e n a b l e i s c s i d S y n c h r o n i z i n g s t a t e o f i s c s i d . s e r v i c e with SysV s e r v i c e s c r i p t with / l i b / systemd / systemd−sysv− i n s t a l l . E x e c u t i n g : / l i b / systemd / systemd−sysv− i n s t a l l e n a b l e i s c s i d Created s y m li n k / e t c / systemd / system / s y s i n i t . t a r g e t . wants / i s c s i d . s e r v i c e → / l i b / systemd / system / i s c s i d . s e r v i c e . • restarting iscsid service $ s y s t e m c t l r e s t a r t i s c s i d . s e r v i c e • and, finally, login in discovered logical units $ sudo i s c s i a d m −m node −− l o g i n a l l=a u t o m a t i c Logging i n t o [ i f a c e : i s c s i 0 2 , t a r g e t : i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c084c8320ca , p o r t a l : 1 0 . 2 5 0 . 9 3 . 9 9 , 3 2 6 0 ] ( m u l t i p l e ) Logging i n t o [ i f a c e : i s c s i 0 1 , t a r g e t : i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c084c8320ca , p o r t a l : 1 0 . 2 5 0 . 9 4 . 9 9 , 3 2 6 0 ] ( m u l t i p l e ) Login t o [ i f a c e : i s c s i 0 2 , t a r g e t : i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c084c8320ca , p o r t a l : 1 0 . 2 5 0 . 9 3 . 9 9 , 3 2 6 0 ] s u c c e s s f u l . Login t o [ i f a c e : i s c s i 0 1 , t a r g e t : i q n .2003 −01. o r g . l i n u x − i s c s i . s t o r a g e . x8664 : sn . 2 c084c8320ca , p o r t a l : 1 0 . 2 5 0 . 9 4 . 9 9 , 3 2 6 0 ] s u c c e s s f u l . Download 1.27 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling