案例一:将一个地方里的所有差异数据同步到另一个地方
# rsync -avDogp <source directory>/* <target directory>
案例二:将一个地方里的所有差异数据同步到另一个地方,并且被同步的地方有的数据而原地方没有的数据都将被删除
# rsync -avDogp --delete <source directory>/* <target directory>
# rsync -avDogp <source directory>/* <target directory>
# rsync -avDogp --delete <source directory>/* <target directory>
# vim /etc/hosts
添加以下内容:
......
<IP address> <domain name>
(注意:/etc/hosts 里记录的 DNS 优先级要比 /etc/resolv.conf 里的高)
# vim /etc/hosts
添加以下内容:
......
192.154.240.64 eternalcenter.com
(补充:这里以将 192.154.240.64 解析为 eternalcenter.com 为例)
(注意:/etc/hosts 里记录的 DNS 优先级要比 /etc/resolv.conf 里的高)
# vim /etc/resolv.conf
添加以下内容:
......
nameserver <IP address of DNS server>
(注意:/etc/hosts 里记录的 DNS 优先级要比 /etc/resolv.conf 里的高)
# nmcli connection modify <network card name> ipv4.dns <IP address of DNS server>
(补充:不将 /etc/NetworkManager/NetworkManager.conf 里的 [main] dns=none 参数修改为 none 的话,此参数会覆盖 /etc/resolv.conf 里的设置)
(
注意:
1) 此方法只对 CentOS8&RHEL8 适用
2) /etc/hosts 里记录的 DNS 优先级要比使用 nmcli 命令的高
)
# nmcli connection modify <network card name> ipv4.dns "<first IP address of DNS server>,<second IP address of DNS server>,<third IP address of DNS server>......"
(补充:不将 /etc/NetworkManager/NetworkManager.conf 里的 [main] dns=none 参数修改为 none 的话,此参数会覆盖 /etc/resolv.conf 里的设置)
(
注意:
1) 此方法只对 CentOS8&RHEL8 适用
2) /etc/hosts 里记录的 DNS 优先级要比使用 nmcli 命令的高
)
# vim /etc/resolv.conf
添加以下内容:
......
nameserver 8.8.8.8
(补充:这里以使用 8.8.8.8 DNS 服务器为例)
(注意:/etc/hosts 里记录的 DNS 优先级要比 /etc/resolv.conf 里的高)
# nmcli connection modify eth0 ipv4.dns 8.8.8.8
(
补充:
1) 这里以给 eth0 网卡添加 8.8.8.8 DNS 服务器为例
2) 不将 /etc/NetworkManager/NetworkManager.conf 里的 [main] dns=none 参数修改为 none 的话,此参数会覆盖 /etc/resolv.conf 里的设置
)
(注意:/etc/hosts 里记录的 DNS 优先级要比使用 nmcli 命令的高)
# nmcli connection show | grep -i ipv4.dns
# ping <domain name>
# ping eternalcenter.com
PING eternalcenter.com (192.154.240.64) 56(84) bytes of data.
64 bytes from v144-48-142.ap-east.sugarhosts.net (192.154.240.64): icmp_seq=1 ttl=50 time=144 ms
64 bytes from v144-48-142.ap-east.sugarhosts.net (192.154.240.64): icmp_seq=3 ttl=50 time=70.8 ms
64 bytes from v144-48-142.ap-east.sugarhosts.net (192.154.240.64): icmp_seq=4 ttl=50 time=81.3 ms
64 bytes from v144-48-142.ap-east.sugarhosts.net (192.154.240.64): icmp_seq=5 ttl=50 time=103 ms
......
# host <domain name>
# host eternalcenter.com
eternalcenter.com has address 192.154.240.64
(补充:这里以解析 etenalcenter.com 域名为例)
# nslookup <domain name>
# nslookup eternalcenter.com
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: eternalcenter.com
Address: 192.154.240.64
(补充:这里以解析 etenalcenter.com 域名为例)
# getenforce
# vim /etc/selinux/config
将以下内容:
......
SELINUX=disabled
......
修改为:
......
SELINUX=enforcing
......
# reboot
# setenfoce 1
(补充:系统重启后失效)
# semanage boolean -l
# setsebool <boolean value> 1
或者:
# setsebool <boolean value> on
# setsebool httpd_can_network_connect 1
或者:
# setsebool httpd_can_network_connect on
# setsebool -P <boolean value> 1
或者:
# setsebool -P <boolean value> on
# setsebool -P httpd_can_network_connect 1
或者:
# setsebool -P httpd_can_network_connect on
# setsebool <boolean value> 0
或者:
# setsebool <boolean value> off
# setsebool httpd_can_network_connect 0
或者:
# setsebool httpd_can_network_connect off
# setsebool -P <boolean value> 0
或者:
# setsebool -P <boolean value> off
# setsebool -P httpd_can_network_connect 0
或者:
# setsebool -P httpd_can_network_connect off
# lspci | grep -i fibre
# ls /sys/class/fc_host/
host1 host2 host3 host4
# cat /sys/class/fc_host/host[1-4]/port_name
# cat /sys/class/fc_host/host5/port_state
online
# cat /sys/class/fc_host/host7/port_state
linkdown
名称:只对某个 IP 地址开放 TCP 22 端口
作用:只对某个 IP 地址开放 TCP 22 端口
1. 给此脚本添加执行权限
2. 执行此脚本
ipaddress=192.168.1.1 #要开放 TCP 22 端口的 IP 地址
#!/bin/bash
####################### Separator ########################
ipaddress=192.168.1.1
####################### Separator ########################
systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services
zypper -n install iptables
systemctl enable iptables
systemctl start iptables
sysctl -w net.ipv4.ip_forward=1
iptables -t filter -F
iptables -t nat -F
iptables -P OUTPUT ACCEPT
#iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -t filter -A INPUT -j ACCEPT -s $ipaddress -p tcp --destination-port 22
iptables -t filter -A INPUT -j DROP -p tcp --destination-port 22
service iptables save
systemctl restart iptables