1 静态网络配置
1.1 备份配置文件
sudo cp interfaces interfaces.bak
1.2 配置IP地址、子网掩码、网关地址
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.214.110
netmask 255.255.255.0
gateway 192.168.214.2
# The loopback network interface
auto lo
iface lo inet loopback
1.3 配置DNS
sudo vim /etc/resolv.conf
nameserver 114.114.114.114
1.4 重启网络服务
/etc/init.d/networking restart
2 配置SSH远程登录
2.1 验证是ssh服务是否安装,是否启动
# 是否启动
sudo netstat -nltp | grep 22
# 是否安装
sudo ps -ef | grep ssh
# 安装、启动
apt-get install openssh-server
/etc/init.d/ssh start
3 防火墙的处理
3.1 配置防火墙
apt-get install ufw
ufw enable
ufw allow
3.2 相关防火墙的处理
# 不开放的端口禁止访问
sudo ufw default deny
# 安装ubuntu防火墙
sudo apt-get install ufw
# 防火墙状态
sudo ufw status
# 防火墙启用/重启/禁用
sudo ufw enable
sudo ufw reload
sudo ufw disable
# 不开放的端口禁止访问
sudo ufw default deny
# 开放任意协议端口
sudo ufw allow 22
sudo ufw delete allow 21
# 开放指定协议端口
sudo ufw allow 8001/tcp
sudo ufw delete allow 8001/tcp
# 开放指定ip访问任意端口
sudo ufw allow from 192.168.121.1
sudo ufw delete allow from 192.168.121.1
# 开放指定ip访问指定端口
sudo ufw allow from 192.168.121.2 to any port 3306
sudo ufw delete allow from 192.168.121.2 to any port 3306
标签:sudo,配置,端口,Debain,192.168,网络,allow,防火墙,ufw
From: https://www.cnblogs.com/tudou-xihongshi/p/16753127.html