In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you what are the relevant knowledge points about the basic commands of LINUX network services. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's learn about it.
one。 Network Services (basic commands)
1. View network interface information: ifconfig
Ifconfig Network Interface name
two。 View hostname: hostname
Hostname hostname (modify hostname)
3. View route entries
Router [- n] (- n: displays the address information in the route record as a number)
4. Check the network connection: netstat
Netstat+ option
-a: show all active connections
-n: display in the form of digital information
-p: displays process information
-t: view information about TCP protocol
-u: view information about UDP protocol
5. Test the network connection
Ping:+ option + target host
Traceroute: tests the network node that passes from the current host to the destination host
Traceroute destination host address
6. Domain name resolution: nslookup
Nslookup destination host address [dns server address]
7. Set network interface parameters
Ifconfig interface name ip address [netmask subnet mask]
Ifconfig network interface IP address [/ mask length]
Disable or reactivate the network card
Ifconfig network interface up
Ifconfig network interface down
Set up a virtual network interface
Ifconfig API name: serial number IP address
8. Set up routing record
Delete the default gateway record in the routing table: route del default gw ip address
Add a default gateway record to the routing table: route add default gw ip address
Route record added to the specified network segment: route add-net network address gw IP address
Delete the route record to the specified network segment: route del-net segment address
9. Network interface profile
/ etc/sysconfig/network-scripts/ directory:
Ifcfg-eth0: the configuration file of the first Ethernet
Ifcfg-eth2: configuration file for the second block of Ethernet
Service network restart: restart network services
/ etc/sysconfig/network file: saves global network settings, including hostname information
Hostname= http://www.benet.com
/ etc/resolv.conf file: the ip address of the dns server you need to use to save this machine
/ etc/host file: save the mapping address of the hostname and ip address
two。 DHCP server
2.1 flowchart built by dhcp
2.2 main files of the dhcp software package
Main configuration file: / etc/dhcpd.conf
Execute the program: / usr/sbin/dhcp, / usr/sbin/dhcrelay
Service script: / etc/init.d/dhcpd, / etc/init.d/dhcrelay
Perform parameter configuration: / etc/sysconfig/dhcpd
DHCP trunk configuration: / etc/syscnfig/dhcrelay
2.3 View and install dhcp server
# rpm-qa | grep dhcp*
# rpm-ivh / media/Packages/dhcp-4.1.1-38.P1.el6.x86_64.rpm
2.4 establish a profile
# vi / etc/dhcp/dhcp.conf
Ddns-update-style none; / / do not update the settings of DDNS
Default-lease-time 21600; / / the default lease is 3 days
Max-lease-time 43200; / / maximum lease is 6 days
Option routers 192.168.1.1; / / default route
Option domain-name-servers 192.168.1.25
Subnet 192.168.1.0 netmask 255.255.255.0 {
Range 192.168.1.26 192.168.1.100; / / assigned IP range
Option subnet-mask 255.255.255.0; / / assigned ip address subnet mask
Bind a specific ip address
Host vbird-inside {
Hardware ethernet 0040 9530 43mm B4; / / client network card MAC
Fixed-address 192.168.1.27; / / give a fixed IP
}
# service dhcpd start / / start dhcp
# netstat-anpu | grep ": 67" / / check whether port 67 of UDP protocol is listening
# less / var/lib/dhcpd/dhcpd.leases / / View DHCP assignment
# dhclient-d eth0
# chkconfig-- level 35 dhcpd on
# chkconfig-list dhcpd
# ntpdate-u ntp.api.bz / / time synchronization
# service dhcpd start / / start dhcpd service
View the lease file / var/lib/dhcpd/dhcpd.lease
three。 File sharing Server (samba)
3.1 flow chart built by samba
3.2 install the samba server
# rpm-qa | grep "^ samba" / / query the installed software package
# rpm-ivh samba-3.6.9-164.el6.x86_64.rpm / / install samba server
# service smb start / / start smb service
# mkconfig-- level 35 smb on / / sets automatic startup
3.3 set shares that can be accessed anonymously
1. Modify the default security level to share
# vi / etc/samba/smb.conf
[global]
Workgroup = WORKGROUP
Security = share
2. Add a shared directory configuration
[share]
Comment = share for a
Path = / media/a / / create a shared file under the media folder
Public= yes / / public=guest ok, set to yes to allow anonymous users to access
Read only = yes
# service smb reload / / restart samba server
3.4 establish a share for user authentication
1. Set up a user database
# useradd jiang
# pdbedit-a-u jiang / / add a specified shared user
# pdbedit-x-u jiang / / Delete the specified sharing user-vL view
# useradd
# pdbedit-a-u
# mkdir / media/a / / create a local test directory
# chmod 777 / media/a
2. Modify the default security level
# vi / etc/samba/smb.conf
[global]
Workgroup = WORKGROUP
Security = user
3. Add a shared directory configuration
[tools]
Comment = You can get software tools from here.
Path = / opt/mytools
Public = no
Read only = yes
Valid users = jiang,
Write list = jiang
Directory mask = 7000
Createmask = 7000
# service smb reload / / restart samba server
# testparm / / profile checking tool
3.5 configure user mapping and access address restrictions
1. Configuration file modification
# cat / etc/samba/smbusers / / View the mapping file of the shared account
# useradd jiang
# pdbedit jiang / / set shared users
# vi / etc/samba/smbusers / / 1. Set alias
Jiang= J
# vi / etc/samba/smb.conf / / 2. Enable mapping account files
[global]
Username map = / etc/samba/smbusers
# service smb reload / / restart samba service
2. Access address restrictions
# vi / etc/samba/smb.conf
[global]
Hosts allow = 192.168.1.27 / / only allowed
Hosts deny = 192.168.1.25 / / rejected IP address only
3.6 Linux client access
# smbclient-L 192.168.1.25 / / query the anonymous shared resource list of target hosts
# smbclient-U jiang / / 192.168.1.25 / a / / Log in to samba to upload and download
Smb:\ >
! Execute local path
Ls: displaying a list of files
Get: downloading a single file
Put: upload a document
Mget: download files in bulk
Mput: upload files in bulk
Mkdir: create a directory
Rmdir: delete directories rm: delete files
Mount mounts a shared folder
# mkdir / media/b
four。 DNS server
4.1 flow chart built by DNS
4.2 query and install DNS server
1. Query whether to install DNS # rpm-qa | grep "^ bind"
2. Install DNS
Install the package:
Bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
4.3 build a cached domain name server
1. Establish the master configuration file
# vim / var/named/chroot/etc/named.conf
Options {
Listen-on port 53 {192.168.37.130;}; / / listening port
Directory "/ var/named"; / / specify the path to the main configuration file
Dump-file "/ var/named/data/cache_dump.db"
Statistics-file "/ var/named/data/named_stats.txt"
Memstatistics-file "/ var/named/data/named_mem_stats.txt"
Query-source port 53; (specify the source port that the client must use when submitting an DNS query)
Allow-query {192.168.1.0 Compact 24;}
Recursion yes
# forwarders {192.168.1.25;}
}
Zone "." IN {
Type hint
File "http://named.ca";
}; / / can be omitted
2. Start the service and view
# service named start
# netstart-anpt | grep named
4.4 build a master and slave domain name server
1. Confirm the network address, host mapping, and default DNS server address of this machine.
# vim / etc/hosts
# vim / etc/resolv.conf
2. Build a primary domain name server
(1) establish the master configuration file
# vim / var/named/chroot/etc/named.conf
Options {
Directory "/ var/named"; / / path to the main configuration file
}
Zone "http://.com"IN{
Type master
File ".com.zone"
Allow-transfer {192.168.1.26;}; (from the server's IP address)
}; / / configured zone file
(2) Establishment of forward regional data file
# cd / var/named/chroot/var/named/
# vim .com.zone
$TTL 86400
@ SOA .com. Admin..com. (
2017020305 Update Serial number
4H refresh time
30m retry delay
12h failure time
1D Life cycle of invalid parsing record
)
@ IN NS a..com.
An IN A 192.168.1.25
3. Build from the domain name server
(1),
Install a new Linux server, close iptables, close SELinux, and change the host name
Change the IP address, change the dns (ip of the primary domain name server)
(2) install the package
Bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
Bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm
(3) establish the main configuration file
# vim / var/named/chroot/etc/named.conf
Options {
Directory "/ var/named"
}
Zone "http://.com" IN {
Type slave
Masters {192.168.1.25;}; / / IP address of the primary domain name server
File "slaves/.com.zone"
}
4. Experimental results:
Start the service to see if the download is successful
# ls-lh / var/named/chroot/var/named/slaves/
Then shut down the primary domain name server to see if it can be resolved
five。 Flowchart of FTP File transfer Service 5.1 FTP
5.2 query and install FTP
1. Query whether vsftpd is installed
# rpm-qa | grep "vsftpd"
2. Install vsftpd
# rpm-ivh / media/cdrom/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm
3. Install ftp
Rpm-ivh ftp-0.17-54.el6.x86_64.rpm
Build a FTP server that can be uploaded anonymously
1. Prepare the directory accessed by anonymous FTP and give write permission
# chown ftp/ var/ftp/pub/ modify directory owner
# ls-ld / var/ftp/pub/ d shows the properties of the directory itself, not the interior)
Anonymous_enable=YES / / allow anonymous users to access
Local_enable=NO / / there is no need to enable local users
Write permissions of write_enable=YES / / development server
Anon_umask=022 / / permission mask for anonymous users to upload data
Anon_upload_enable=YES / / allow anonymous upload of files
Anon_mkdir_write_enable=YES / / allows anonymous users to create directories
Anon_other_write_enable=YES / / allow anonymous deletion
# service vsftpd start / / restart the service
2. Login: ftp 192.168.1.25 /
3. Anonymous users: anonymous or ftp
5.4 build a FTP service for user authentication
# vi / etc/vsftpd/vsftpd.conf
Anonymous_enable=NO / / prohibit anonymous users from accessing
Local_enable=YES
Write permissions of write_enable=YES / / development server
Chroot_local_user=YES / / Local users are trapped in the host directory
# service vsftpd reload
# useradd test / / New user
# passwd 123456
Use the user_list user list file
# useradd jiang
(log in after configuring passwords for these two users)
# vim / etc/vsftpd/user_list clear and add two users
# vim / etc/vsftpd/vsftpd.conf
Userlist_enable=YES
Change userlist_deny=NO / / to yes retest
# service vsftpd reload / / restart vsftpd service
5.5 FTP services based on virtual users
1. Query whether the db4-utils package is installed and provide db_load tools.
# rpm-Q db4-utils
Install db4-utils
# rpm-ivh db4-utils-4.7.25-18.el6_4.x86_64.rpm
2. Create a user / password list file
# vim / etc/vsftpd/vusers.list
Ftp1
one hundred and twenty three
Ftp2
one hundred and twenty three
3. Create a data file in Berkeley DB format
# cd / etc/vsftpd/
# db_load-T-t hash-f vusers.list vusers.db
/ /-T allows other programs to convert DB databases-t hash specifies the basic method of reading data
# file vusers.db
# chmod 600 / etc/vsftpd/vusers.*
# ls-lh / etc/vsftpd/vusers.*
4. Add the mapping account of virtual user and create the FTP root directory
# useradd-d / var/ftproot-s / sbin/nologin test
# chmod 755 / var/ftproot
5. Establish PAM authentication files for virtual users
# vim / etc/pam.d/vsftpd.vu
#% PAM-1.0
Auth required pam_userdb.so db=/etc/vsftpd/vusers
Account required pam_userdb.so db=/etc/vsftpd/vusers
6. Modify the main configuration file
# vim / etc/vsftpd/vsftpd.conf
Local_enable=YES / / Mapping must be enabled for local users
Write_enable=YES / / upload and write
Anon_umask=022
Guest_enable=YES / / enable user mapping
Guest_username=testftp / / user name of the system that is mapped
Pam_service_name=vsftpd.vu / / specify a new PAM authentication file
7. Establish an independent virtual user profile and set different permissions
(1), add the main profile
# vim / etc/vsftpd/vsftpd.conf
User_config_dir=/etc/vsftpd/vusers_dir / / standalone profile path
(2), create configuration folder and virtual user profile
# mkdir / etc/vsftpd/vusers_dir/
# cd / etc/vsftpd/vusers_dir/
# vi ftp1
Anon_upload_enable=YES
Anon_mkdir_write_enable=YES
# touch ftp2
# service vsftpd reload
8. Testing
Virtual user login log / var/log/secure
It's just different permissions.
Be sure to comment out the userlist_enable=NO
Chkconfig-- level 35 vsftpd / / vsftp service is set to start automatically
These are all the contents of this article entitled "what are the basic commands of LINUX Network Services". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.