首页 > 其他分享 >Debian11.5 最小化安装后更改主机名、安装桌面、设置默认语言、时区、静态IP、局域网DNS等

Debian11.5 最小化安装后更改主机名、安装桌面、设置默认语言、时区、静态IP、局域网DNS等

时间:2022-12-07 20:33:34浏览次数:80  
标签:Debian11.5 apt 主机名 网卡 etc dnsmasq 192.168 安装

最小化安装,指的是采用 debian-11.5.0-amd64-netinst.iso 382.0 MiB 2022-09-10 20:40 这个只有 382M的镜像,仅安装了 ssh 服务的状态,只占了 900多M磁盘空间。

如果使用Live CD安装,通常在终端输入 sudo 即可进入root权限,然后设置root账户密码即可获得最大权限。

目录

0.更改主机名

1.命令行装桌面

1.2.纯粹的命令行安装,这里仅仅以xfce4的安装为示例

2.设置时区

3. 设置默认语言

3.2 注意: 如果在上一步安装了xfce4,并选择了中文,可能会存在中文菜单显示乱码的问题,这是因为没有装字体

4. 设置静态IP

4.2 多网卡和一个网卡多个ip

4.3 设置网桥

4.4 无线网络的配置

5. 允许 Root账户ssh登录

5.2 通过 SSH Keys 登录

6.设置为局域网DNS服务器

6.1 修改主配置文件

6.2 修改服务器默认的DNS服务器地址

6.3 增加上游DNS服务器地址

6.4 指定虚拟解析地址

6.5 设置完后,重启dnsmasq服务,并将客户机的首选DNS设置为本服务器

7. 安装web化的管理界面 cockpit

8. 安装高版本的内核

0.更改主机名
hostnamectl
hostnamectl set-hostname mail.test.com
1.命令行装桌面
tasksel


1.2.纯粹的命令行安装,这里仅仅以xfce4的安装为示例
apt install x-window-system xfce4
reboot

# Debian11 安装最轻量化的lxde桌面
apt install lxde-core
1.3 进一步轻量化安装 lightdm + xfce4 仅消耗800M空间
apt update
apt install lightdm
apt install xfce4
reboot
2.设置时区
timedatectl list-timezones |more #然后使用空格键翻页
timedatectl set-timezone Asia/Shanghai
3. 设置默认语言
dpkg-reconfigure locales


3.2 注意: 如果在上一步安装了xfce4,并选择了中文,可能会存在中文菜单显示乱码的问题,这是因为没有装字体
apt install ttf-wqy-zenhei # 这里是装入了一字体,其他可以自行搜索
apt install ibus ibus-gtk ibus-pinyin #安装了输入法
apt install firefox-esr #重装了火狐浏览器,因为后装的桌面环境,浏览器存在打不开的问题

# 登出图形界面,在登录进来即可
4. 设置静态IP
ip addr # 查看网卡名称
vim /etc/network/interfaces # 静态ip的配置文件
vim /etc/resolv.conf # 默认dna server的配置文件

4.2 多网卡和一个网卡多个ip
先看效果,enp0s9 是dhcp获得地址,

 

配置代码:

 

# 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 loopback network interface
auto lo
auto enp0s17
auto enp0s8
auto enp0s9

iface lo inet loopback

# The primary network interface
auto enp0s17 enp0s17:1 enp0s17:2
allow-hotplug enp0s17 enp0s17:1 enp0s17:2
iface enp0s17 inet static
address 192.168.1.230
netmaks 255.255.255.0
gateway 192.168.1.1
iface enp0s17:1 inet static
address 192.168.1.234
netmask 255.255.255.0
iface enp0s17:2 inet static
address 192.168.1.233
netmask 255.255.255.0

auto enp0s8
allow-hotplug enp0s8
iface enp0s8 inet static
address 192.168.1.50
netmask 255.255.255.0
gateway 192.168.1.1

auto enp0s9
allow-hotplug enp0s9
iface enp0s9 inet dhcp # dhcp 一定要是小写字母

4.3 设置网桥
# 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 loopback network interface
auto lo
auto enp0s17
iface lo inet loopback

# The bridge network interface
iface br0 inet static
address 192.168.1.230
netmaks 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 223.5.5.5
bridge_stp off
bridge_ports enp0s17
auto br0

4.4 无线网络的配置
# 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 loopback network interface
auto lo
auto wlp5s0 #wlp5s0 是我的无线网卡的名称
iface lo inet loopback

#下面是无线网卡的配置

allow-hotplug wlp5s0
#iface wlp5s0 inet dhcp
iface wlp5s0 inet static
wpa-ssid Wifi-Nane
wpa-psk Woshimima0!
address 192.168.1.230
netmaks 255.255.255.0
gateway 192.168.1.1

4.1 设置以dhcp方式获得ipv6
在对应的网卡配置内容最下方,增加以下内容:
iface ens3(网卡端口号) inet6 dhcp
对于KVM虚拟机,一般先要对宿主机的 虚拟网卡进行如上配置,然后分别对各个虚拟机的网卡进行配置。

5. 允许 Root账户ssh登录
vim /etc/ssh/sshd_config


5.2 通过 SSH Keys 登录
关于 SSH keys 的生成,可以看我之前的博客:Fedora CoreOS 的裸机安装方法_lggirls的博客-CSDN博客

重点是在你要使用的账户的家目录中的 ".ssh"文件夹下新建文件 authorized_keys,并将生成的 公钥,添加到authorized_keys文件;可以添加多个

例如,要用root 账户通过 ssh keys 登录, 则 vim /root/.ssh/authorized_keys ;复制公钥,也就是后缀是 .pub 的文件内容到里面,保存,reboot

注意: /root/.ssh/ 这个文件夹,权限设置为0755,authorized_keys 设置为0600

然后使用私钥登录: ssh -i /home/keys/私钥文件名 [email protected]

5.3 禁止使用密码登录ssh
vim /etc/ssh/sshd_config #设定如下两条
PasswordAuthentication no
PubkeyAuthentication yes
6.设置为局域网DNS服务器
这里使用dnsmasq,只解析内部局域网的虚拟域名和虚拟邮件服务器

apt install dnsmasq
systemctl enable dnsmasq
主要是对4个文件进行修改和配置: /etc/dnsmasq.conf、/etc/resolv.conf、/etc/resolv.dnsmasq.conf、/etc/dnsmasq.hosts

6.1 修改主配置文件
vim /etc/dnsmasq.conf
要修改的配置项:

no-hosts # 去掉前面的“#”,意义是不使用本机的 /etc/hosts 文件进行解析

resolv-file=/etc/resolv.dnsmasq.conf # 去掉前面的“#”,意义是设置上游DNS服务器地址

strict-order # 去掉前面的“#”,意义是按照解析文件的条目顺序进行逐行匹配

listen-address=192.168.1.230,127.0.0.1 # 去掉前面的“#”,意义是DNS服务器要监听的网卡,也就是服务器本身网卡的ip

addn-hosts=/etc/dnsmasq.hosts # 去掉前面的“#”,意义是指定用于记录手动指向的dns地址的文件
6.2 修改服务器默认的DNS服务器地址
vim /etc/resolv.conf
要修改的内容

#nameserver 192.168.1.1 #一般默认以网关作为首选解析地址,这里将其注释掉
nameserver 127.0.0.1 # 让dnsmasq服务器本身也监听自身的lo网络,
6.3 增加上游DNS服务器地址
vim /etc/resolv.dnsmasq.conf
要修改的内容,填入你想用的公共DNS服务器地址即可

nameserver 223.5.5.5
nameserver 8.8.4.4
nameserver 114.114.114.114
nameserver 8.8.8.8
6.4 指定虚拟解析地址
vim /etc/dnsmasq.hosts
# 这个文件一般需要自己新建,可选的方法是,把/etc/hosts 复制为改文件,再增加自己的内容
cp /etc/hosts /etc/dnsmasq.hosts
要修改的内容示例

127.0.0.1 localhost
127.0.1.1 mail.test.com

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.1.251 www.test.com
192.168.2.252 www.test.cn
192.168.1.230 mail.test.com
6.5 设置完后,重启dnsmasq服务,并将客户机的首选DNS设置为本服务器


7. 安装web化的管理界面 cockpit
启用 backports repository:
echo 'deb http://deb.debian.org/debian buster-backports main' > \
/etc/apt/sources.list.d/backports.list

apt update
#下面是正式的安装
apt install -t buster-backports cockpit
访问地址: http://service-ip:9090

 

8. 安装高版本的内核
因为最近安装2.5G网卡,驱动始终装不了,提示不支持 PCI 模式,所以更新核心模块

# 添加 buster-backports源。
add-apt-repository 'deb http://deb.debian.org/debian buster-backports main'
#注:如果不能命令添加,手动添加到 sources.list 中也可以
echo "deb http://deb.debian.org/debian buster-backports main" /etc/apt/sources.list

#更新
apt update
#查看有哪些核心可以用
apt-cache search linux-image


#安装新核心
apt install linux-image-5.9.0-0.bpo.5-amd64-unsigned
#重启
reboot
9. 挂栽windows 系统的 NTFS格式的硬盘分区

apt-get install ntfs-3g -y
mount -t ntfs-3g /dev/sdc1 /home/windows/disk1
————————————————
版权声明:本文为CSDN博主「lggirls」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lggirls/article/details/112326734

标签:Debian11.5,apt,主机名,网卡,etc,dnsmasq,192.168,安装
From: https://www.cnblogs.com/Thenext/p/16964461.html

相关文章

  • 绿色版MySQL8.0.26安装流程
    下载 5.7 8.0 官网 https://dev.mysql.com/downloads/mysql/ 国内镜像网站 https://developer.aliyun.com/mirror/ ​ windows安装数据库 安装版: .......
  • 全网最详细elasticsearch7.10.2安装手册
    前言网上关于elasticsearch的安全教程很多,但是只是局限在最基础的启动就成功就完了。今天给大家分享elasticsearch7.10.2最全安装手册,记录自己踩过的一些坑。一、环境说明服......
  • 5分钟,使用yum方式完成mysql安装
    跟着老万,教你5分钟使用yum方式安装mysql。最近打算写一些关于mysql的系列文章,作为第一篇,来教大家如何快速的使用yum命令在线安装mysql。安装的linux环境是7.5,mysql安装的5.7......
  • Postman(一): postman介绍和安装,发送带参数的GET请求
    Postman(1):postman的介绍和安装Postman的介绍Postman是一款谷歌开发的接口测试工具,使API的调试与测试更加便捷。它提供功能强大的WebAPI&HTTP请求调试。它能够发......
  • 除了Ubuntu以外的Linux系统可以安装Tensorflow/Pytorch的GPU版本吗???
    废话:平时没事有用到的Linux系统有Centos/Redhat/Ubuntu/UOS/Deepin,其中Ubuntu系统主要是用来工作生产的,UOS就是看看国家队的进展如何,Deepin就是看看民营企业的力量,同时也......
  • elasticsearch安装和使用
    下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch    https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-......
  • WSL安装到非C盘
     https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-6---install-your-linux-distribution-of-choice  Invoke-WebRequest-Urihttps://aka.ms......
  • 怎样使用eclipse创建.cld文件 画类图 AmaterasUML安装
    下载 https://zh.osdn.net/projects/amateras/downloads/56447/AmaterasUML_1.3.4.zip/ 三个jar包将下载下来的三个jar包放到eclipse安装目录  如果你的eclipse中......
  • charles 手机端安装证书无法下载问题
    charles开启后手机端也按照要求配置了代理,发现在手机端访问的时候用chrome浏览器无法打开chls.pro.ssl地址,电脑是win10,默认是开启了防火墙  在手机访问的时候总是打......
  • miniconda的安装及配置
    1.下载conda官方网站2.安装全部按默认一直点击下一步即可,安装路径可自定义。3.使用在windows开始菜单中打开AnacondaPrompt(miniconda3)工具。3.1配置清华镜像源An......