配置静态网络:https://blog.csdn.net/qq_46237746/article/details/124532376
02.查看ip[root@hadoop100 ~]# hostname -i 192.168.10.100
[root@hadoop100 ~]# ifconfig docker0: flags=416303.拼接别的网络mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 fe80::42:3aff:fe6a:334a prefixlen 64 scopeid 0x20 ether 02:42:3a:6a:33:4a txqueuelen 0 (Ethernet) RX packets 106775 bytes 32705809 (31.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 106785 bytes 34201827 (32.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163 mtu 1500 inet 192.168.10.50 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::4858:ffc9:dee5:1904 prefixlen 64 scopeid 0x20 ether 00:0c:29:27:4d:95 txqueuelen 1000 (Ethernet) RX packets 1163694 bytes 86105685 (82.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1830739 bytes 513445790 (489.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 //TODO
[root@hadoop100 ~]# ping www.baidu.com PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data. 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=11.5 ms 64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=11.4 ms04.防火墙操作 查看防火墙状态
[root@hadoop100 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 二 2022-05-03 20:36:45 CST; 56min ago # running说明防火墙正在打开
Docs: man:firewalld(1)
Main PID: 783 (firewalld)
Memory: 30.1M
CGroup: /system.slice/firewalld.service
└─783 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
临时关闭防火墙
[root@hadoop100 ~]# systemctl stop firewalld开启防火墙
[root@hadoop100 ~]# systemctl start firewalld重启防火墙
[root@hadoop100 ~]# systemctl restart firewalld.service查看防火墙开机启动状态
[root@hadoop100 ~]# systemctl enable firewalld.service Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service. Created symlink from /etc/systemd/system/basic.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.设置开机时关闭防火墙
[root@hadoop100 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.05.端口操作 查看当前监听的所有端口/端口占用情况
[root@hadoop100 ~]# netstat -ntulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3472/docker-proxy tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 3430/docker-proxy tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN 3679/docker-proxy
参数说明:
- -t (tcp) 仅显示tcp相关选项
- -u (udp)仅显示udp相关选项
- -n 拒绝显示别名,能显示数字的全部转化为数字
- -l 仅列出在Listen(监听)的服务状态
- -p 显示建立相关链接的程序名
[root@hadoop100 ~]# netstat -ntulp |grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3164/docker-proxy tcp6 0 0 :::3306 :::* LISTEN 3170/docker-proxy永久打开端口
[root@hadoop100 ~]# firewall-cmd --add-port=801/tcp --permanent success重新载入配置
[root@hadoop100 ~]# firewall-cmd --reload success查看端口是否开启
[root@hadoop100 ~]# firewall-cmd --query-port=801/tcp yes
注意:打开端口并不意味着端口被监听或者被占用,若端口只打开未被监听,则查看端口监听情况依旧为空,具体如下:
[root@hadoop100 ~]# netstat -ntulp |grep 801 [root@hadoop100 ~]#永久关闭端口
[root@hadoop100 ~]# firewall-cmd --permanent --remove-port=801/tcp success



