Linux service management and network configuration text / heiyeluren
This section explains the simple management configuration of services and networks under Linux, and gives yourself a chance to explain the problem. (The following operation is based on redhat9)
First, the service management of the Winnt operating system is relatively strong, and it has a service manager built-in, which can be very convenient to manage the service within the operating system. Linux also has a unique way of management services. Linux service is running in a script, and all scripts in /etc/rc.d/init.d are our service script, which has two functions, one is capable of starting in the system. The program that is automatically started in those scripts is automatically started, and we can also control the service through this script, such as start, stop, and so on.
Let's take a look at there are those services below:
# Ls /etc/rc.d/init.danacron cups iptables killall nfslock random single ypbindapmd firstboot irda kudzu nscd rawdevices sshdatd functions isdn netfs ntpd rhnsd syslogautofs gpm kdcrotate network pcmcia saslauthd xfscrond halt keytable nfs portmap sendmail xinetd
What is listed in it is that all of our service scripts in our current system, starting every time the system is started. We open a script to see:
# Cat /etc/rc.d/init.d/smbcase "$ 1" in start) start ;; stop) stop ;; status) status rpc.mountd status nfsd ;; restart $ 0 $ 0 start ;; reload) / usr / sbin / limitedfs -r touch / var / limited / subsys / nfs ;; *) echo $ "usage: nfs {start | stop | status | restart | reload}" EXIT 1ESACEXIT 0
We can see that there are basically several services, start, stop, restart, status, etc., let's take a look at the table below:
Service script operation ----------------------------------------------- -------------------------- - Operation --------------------- -------------------------------------------------- --- Start Launch Service, equivalent to the start command stop service in the service script, equivalent to the secondary long script stop command RESTART closes the service, then restart, equivalent to the script restart command Reload makes the service do not restart and reread Profile, equivalent and service script's Reload Command Status provides the current state of the service, the STATUS command for the service script, if the service is locked, this is turned off, then start, equivalent to the condrestart command ---- -------------------------------------------------- -------------------- For example, we have to restart Samba, you can use the root user to run the following two commands, the effect is the same:
# /etc/rc.d/init.d/smb restart # service SMB Restart
Then you understand here, if we have to start the service automatically when the system is started, then configure a service script, put it in /etc/rc.d/init.d, it is OK, corresponding, If you want to delete the service, you can remove the script.
Second, network configuration
1. Configure the IP address to configure N methods of IP, using the GUI interface, configure, modify the configuration file configuration, use the console graphical interface when installing:
# setup
You can configure IP
Then use the IFConfig command to match IP, using ifconfig to specify IP addresses, hardware ports, network mask, etc., of course, the most important function of this command is to view current network configuration.
# Ifconfigeth0 Link encap: Ethernet HWaddr 00: E0: 4C: 3A: AA: 34 inet addr: 192.168.5.140 Bcast: 192.168.5.255 Mask: 255.255.254.0 UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1 RX packets: 1172088 errors: 0 Dropped: 0 TX Packets: 3799 Erro Packets: 3799 ErroPpped: 0 overruns: 0 Carrier: 0 Collisions: 0 TXQuelelen: 100 rx bytes: 821967132 (783.8 MB) TX bytes: 392720 (383.5 KB) Interrupt: 11 Base Address: 0x9000 Eth1 Link Encap: Ethernet Hwaddr 00: E0: 4D: 01: 3B: 87 Up Broadcast Running Multicast MTU: 1500 Metric: 1 RX Packets: 1168522 Errors: 0 Dropped: 0 overruns: 0 Frame: 0 TX Packets : 3 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0 Collisions: 0 TXQuelelen: 100 rx bytes: 821556337 (783.4 MB) TX bytes: 180 (180.0 B) Interrupt: 5 Base Address: 0xB000 Lo Lo Link ENCAP: Local Loopback inet Addr: 127.0.0.1 Mask: 255.0.0.0 Up loopback Running MTU: 16436 Metric : 1 RX Packets: 82 Errors: 0 Dropped: 0 Overruns: 0 Frame: 0 TX Packets: 82 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0 Collisions: 0 TXQUEUELEN: 0 RX BYTES: 11547 (11.2 KB) TX bytes : 11547 (11.2 KB) We see the above information, Eth0 and Eth1 are NIC, with two network cards, LO is loop.
We specify a new IP address to the NIC. The following command specifies the new IPv4 address to Eth1:
# ify # ifconfig eth1 219.238.215.36
So before it is an intranet IP, now we give it an external IP, we can also specify the subnet mask:
# i10255.254.0 219.238.215.36
In the past, sometimes the IRQ port and I / O address of the network card specified by the NIC will encounter conflicts, we can change the IRQ and IO address by the following command:
# iffonfig eth1 IRQ 9 # ifconfig eth1 o_addr 0x300
At the same time, we can freeze and activate the network card, for use with Windows and enable the network difference. When you pay attention, if you are remotely connected to Linux, don't just freeze the network card, otherwise you will be "locked outside", Be careful, this operation is only suitable for local. / * Frozen NIC (Disabled) * / # ifconfig EHT1 Down
/ * Activate NIC * / # ifconfig Eth1 Up
2. Host configuration commands There are many commands in Linux to list computer names in the network, such as HostName to display computer names, and can also modify the computer name.
Host name command ------------------------------------------------------------------------------------------- -------------- Command function ---------------------------------- -------------------------- Hostname lists or sets the hostname DomainName on the local computer to list or set the NIS domain name DNSDOMAINNAME listing the network The DNS server's fully qualified domain name NisDomainName is the same as DomainName YpDomianName is the same as DomainName ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------
3, network configuration file
There are many profiles, including /etc/host//etc/resolv.conf ,/etc/host.conf, etc., but after reusing from redhat9, put most of the profiles in / etc / sysconfig directory .
(1) Static hostname --- / etc / hosts / etc / hosts is files for the IP address and computer name of the computer on the network under early UNIX. Although there is already less used, a small network is still able to meet the requirements. This file is relatively simple, there is an IP address in each line, a fully qualified domain name and a host name, if you want to add a modification, it is simple:
# Do not remove the following line, or various program # That Require network functionality will fail.127.0.0.1 rh_test localhost.localdomain localhost
(2) DNS server --- /etc/resolv.conf If you do not need / etc / hosts, use the domain name server, in Linux, you save the domain name server by passing /etc/resolv.conf:
Nameserver 202.112.112.100
It is also convenient to add modifications to add multiple domain servers to help us resolve the URL.
(3) Search order --- /etc/host.conf If there are two host names and IP addresses database, / etc / hosts, and DNS servers, the order is determined by /etc/host.conf. Usually, this file is only one line:
ORDER HOSTS, BIND
(4) Basic Network Settings --- / etc / sysconfig / network The data of the basic network settings is placed in / etc / sysconfig / network. If the network encounters a problem, you can check this file. The file starts can see NetWorking = YES, and other variables are displayed as follows. Not all of these variables appear in this configuration. If you use a DHCP server, some variables are unnecessary, some variables may be located in the / etc / sysconfig / networking / devices directory specific file. / etc / sysconfig / network variable ------------------------------------------- ------------------------------------- Variable Description ----------- -------------------------------------------------- ------------------- NetWorking Take the value of YES / NO, let the redhat run the network, you have to get the gateway IP address of the YESHOSTNAME computer gateway IP address GatewayDev Connect the network device, such as Eth1, if there are multiple network cards on your computer, you need this network device NisDomain NIS system domain name, if you have any words ------------------------------------------------------------------------------------------------ -------------------------------------------------- ----------------
Let's take a look at my computer configuration: # cat /etc/sysconfig/networknetworking=yeshostname=dougateway=192.168.5.1
Well, if you want to change the configuration, you will modify the corresponding value, but you should pay attention to nothing.
Writetime: 2004-12-16 13:00 noon