SUSE Linux 安装配置

1. OpenSUSE 版本

1.1. Tumbleweed

Tumbleweed 项目是一个 “滚动升级” 的 openSUSE 版本, 俗称 “风滚草”。滚动升级的版本不像 openSUSE 的常规版本 (Leap) 那样受限于版本开发周期, 可以始终使用最新稳定版本的全部软件。该项目适合想使用最新的、稳定的软件的 openSUSE 用户。

Tumbleweed 版本基于 Factory。Tumbleweed 版本虽然很新, 但所含的软件包都是稳定的, 它是一个可以日常使用的版本。

从 2014 年开始, Tumbleweed 和 Factory 合并成为了现在的 Tumbleweed。

1.1.1. 谁应该使用 Leap 而不是 Tumbleweed?

即使我们付出了不少精力去构建这些包, 目前我们不能保证有所有额外的模块在 openSUSE Tumbleweed 中可用, 例如 VMware 和 Virtualbox。虽然 Packman Tumbleweed 基本软件仓库可以尽量地提供这些包, 但不能保证它们总是可工作的, 因为他们很有可能与快速推进的 Linux 内核不兼容。专有图形驱动程序也是类似的, 我们不能保证它们能一直工作, 即使它们现在可以工作。如果你不知道如何编译你自己的额外内核模块, 你不想学习或密切关注正在更新的内容, 请不要使用 Tumbleweed。

2. 配置网络

由于我安装是断网安装的(为了快速安装),所以一开始是没有网络的,需要自己配置。

2.1. 命令行配置

$ sudo ifconfig eth0 192.168.1.15 netmask 255.255.255.0 up
$ sudo route add default gw 192.168.1.0 eth0

上面的 up 需要?

you want to avoid using ifconfig and route that are obsolete you can perform these changes using the following two commands

sudo ip addr add 192.168.1.15/24 dev eth0;
sudo ip route add default via 192.168.1.1 dev eth0;

Please note that the netmask is given in CIDR notation (it is the /24 right after the IP of the device in the ip addr command).

https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

2.2. 文件中配置

需要配置 3 个文件:

# vi /etc/sysconfig/network/ifcfg-eth0 # 编辑配置文件

#TYPE="Ethernet"
#DEVICE="eth0"
STARTMODE="auto"
BOOTPROTO="static"
IPADDR='192.168.1.15/24' # NETMASK and PREFIXLEN will be ignored
BROADCAST='192.168.1.255' # Deprecated IPv4 only variable.
#NETMASK='255.255.255.0'
#NETWORK='192.168.1.0'
USERCONTROL='no' # If an interface may be controlled by a user via qinternet, cinternet or another user interface, you have to set this variable to yes.
# vi /etc/sysconfig/network/routes

default 192.168.1.1
# vi /etc/resolv.conf

nameserver 223.5.5.5
nameserver 119.29.29.29
nameserver 192.168.1.1

重启网络:

sudo rcnetwork restart   #重启网络
sudo service network restart #重启网络
sudo /etc/init.d/network restart #重启网络

2.3. ifconfig 被弃用

ifconfig 这个命令被弃用了, 如果非要使用的话需要安装包 net-tools-deprecated:

$ sudo cnf ifconfig

https://software.opensuse.org/package/net-tools-deprecated

推荐的做法是: $ ip a, 意思是 ip addr

Deprecated commandReplacement command(s)
arpip n (ip neighbor)
ifconfigip a (ip addr), ip link, ip -s (ip -stats)
iptunnelip tunnel
iwconfigiw
nameifip link, ifrename
netstatss, ip route (for netstat-r), ip -s link (for netstat -i), ip maddr (for netstat-g)
routeip r (ip route)

更多请参考: Deprecated Linux networking commands and their replacements

2.4. ifconfig vs ip

The command /bin/ip has been around for some time now. But people continue using the older command /sbin/ifconfig. Let’s be clear: ifconfig will not go away any time soon, but its newer version, ip, is more powerful and will eventually replace it.

The man page of ip may look intimidating at first, but once you get familiar with the command syntax, it is an easy read. This page will not introduce the new features of ip. It rather compares the ifconfig and ip commands to get a quick understanding of the command syntax.

2.4.1. Show network devices and configuration

ifconfig
ip addr show
ip link show

2.4.2. Enable a network interface

ifconfig eth0 up
ip link set eth0 up

A network interface is disabled in a similar way:

ifconfig eth0 down
ip link set eth0 down

2.4.3. Set IP address

ifconfig eth0 192.168.0.77
ip address add 192.168.0.77 dev eth0

This was the simple version of the command. Often, also the network mask or the broadcast address need to be specified. The following examples show the ifconfig and ip variants.

Needless to say that the netmask can also be given in CIDR notation, e.g. as 192.168.0.77/24.

ifconfig eth0 192.168.0.77 netmask 255.255.255.0 broadcast 192.168.0.255
ip addr add 192.168.0.77/24 broadcast 192.168.0.255 dev eth0

2.4.4. Delete an IP address

With ip it is also possible to delete an address:

ip addr del 192.168.0.77/24 dev eth0

2.4.5. Add alias interface

ifconfig eth0:1 10.0.0.1/8
ip addr add 10.0.0.1/8 dev eth0 label eth0:1

2.4.6. ARP protocol

Add an entry in your ARP table.

arp -i eth0 -s 192.168.0.1 00:11:22:33:44:55
ip neigh add 192.168.0.1 lladdr 00:11:22:33:44:55 nud permanent dev eth0

Switch ARP resolution off on one device

ifconfig -arp eth0
ip link set dev eth0 arp off

2.4.7. Show the routing table

route
ip route show

A nice feature of the ip route is that one can query which interface (and gateway) a packet to a given IP address would be routed to.

ip route get 192.168.88.77

2.4.8. Changing the routing table

The commands to add a route on an interface are very similar:

route add -net 192.168.3.0/24 dev eth3
ip route add 192.168.3.0/24 dev eth3

The same applies to removing entries from a routing table:

route del -net 192.168.3.0/24 dev eth3
ip route del 192.168.3.0/24 dev eth3

For completeness, the command to add a gateway:

route add -net 192.168.4.0/24 gw 192.168.4.1
ip route add 192.168.4.0/24 via 192.168.4.1

This can also be combined with a dev eth3 interface.

3. 配置 SSH

由于访问墙的设置, 默认情况下是不能访问 22 端口的, 所以我们需要设置访问墙, SUSE 15 里面的防火墙是 firewalld, 我们可以选择关闭它或者配置它。

关闭: $ sudo service firewalld stop 或者 $ sudo systemctl stop firewalld

注意: 默认 sshd 服务是不会自动启动的,需要我们设置: $ sudo systemctl enable sshd.service

3.1. firewalld 打开 22 端口的方法

3.1.1. 方法 1: firewalld 配置命令 firewall-cmd

注意: 执行 firewall-cmd 命令需要 firewalld 服务正在运行, 我们可以考虑 firewall-offline-cmd 命令,但是这个命令有个缺陷是不能使用 --permanent 参数。如果在防火墙关闭的情况下登录的是普通用户,那防火墙很可能关闭 22 端口造成不能在外执行命令,如果你是 root 用户的话,则网络不会断,所以执行前建议使用 su 命令切换为 root 用户。

  • 添加: firewall-cmd --zone=public --add-port=22/tcp --permanent (–permanent 永久生效, 没有此参数重启后失效)
  • 重新载入: firewall-cmd --reload
  • 查看: firewall-cmd --zone= public --query-port=22/tcp
  • 删除: firewall-cmd --zone= public --remove-port=22/tcp --permanent

3.1.2. 方法 2: 手动修改 firewalld 的配置文件

前面我们提到在防火墙关闭的情况下,在外面的终端是不能进行开启 22 端口操作的,基于 Linux 系统一切皆文件的原则,肯定是可能修改某个配置文件达到开放 22 端口的操作的,这个文件就是:

$ sudo vi /etc/firewalld/zones/public.xml

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="dhcpv6-client"/>
  <port port="22" protocol="tcp"/> // 添加这行即可
</zone>

3.2. firewalld 和 iptables 的关系

firewalld 自身并不具备防火墙的功能, 而是和 iptables 一样需要通过内核的 netfilter 来实现, 也就是说 firewalld 和 iptables 一样, 他们的作用都是用于维护规则, 而真正使用规则干活的是内核的 netfilter, 只不过 firewalld 和 iptables 的结构以及使用方法不一样罢了。

3.3. firewalld 的配置模式

firewalld 的配置文件以 xml 格式为主 (主配置文件 firewalld.conf 例外), 他们有两个存储位置

  • /etc/firewalld/ 用户配置文件
  • /usr/lib/firewalld/ 系统配置文件, 预置文件

我们知道每个 zone 就是一套规则集, 但是有那么多 zone, 对于一个具体的请求来说应该使用哪个 zone(哪套规则) 来处理呢? 这个问题至关重要, 如果这点不弄明白其他的都是空中楼阁, 即使规则设置的再好, 不知道怎样用、在哪里用也不行。

对于一个接受到的请求具体使用哪个 zone, firewalld 是通过三种方法来判断的:

  • source, 也就是源地址 优先级最高
  • interface, 接收请求的网卡 优先级第二
  • firewalld.conf 中配置的默认 zone 优先级最低

这三个的优先级按顺序依次降低, 也就是说如果按照 source 可以找到就不会再按 interface 去查找, 如果前两个都找不到才会使用第三个, 也就是学生在前面给大家讲过的在 firewalld.conf 中配置的默认 zone。

4. 配置更新镜像源

镜像源的配置文件在 /etc/zypp/repos.d, 里面有很多 .repo 的文件就是, 注意不要修改带有 debugsource 的字样的就可以了。

我们这里使用中科大的镜像源, 将 download.opensuse.org 替换为 mirrors.ustc.edu.cn/opensuse :

$ sudo sed -i 's/download.opensuse.org/mirrors.ustc.edu.cn/opensuse/g' /etc/zypp/repos.d/repo-oss.repo
$ sudo sed -i 's/download.opensuse.org/mirrors.ustc.edu.cn/opensuse/g' /etc/zypp/repos.d/repo-update.repo
$ sudo sed -i 's/download.opensuse.org/mirrors.ustc.edu.cn/opensuse/g' /etc/zypp/repos.d/repo-non-oss.repo
$ sudo sed -i 's/download.opensuse.org/mirrors.ustc.edu.cn/opensuse/g' /etc/zypp/repos.d/repo-update-non-oss.repo

修改完成后, 手动刷新软件源:

$ sudo zypper ref

官方已注册镜像站查询: https://mirrors.opensuse.org/

其它镜像站:

  • 上海大学镜像站 (适合上海市内用户): http://mirrors.shu.edu.cn/
  • 浙江大学镜像站 (适合浙江省内用户): http://mirrors.zju.edu.cn/opensuse/
  • 网易镜像站: http://mirrors.163.com/openSUSE/
  • 清华大学镜像站: https://mirrors.tuna.tsinghua.edu.cn/

5. 安装桌面

5.1. 安装 LXDE 桌面

sudo zypper -n in patterns-lxde-lxde
sudo reboot

Uninstall LXDE:

sudo zypper -n rm patterns-lxde-lxde lxde* openbox
sudo reboot

5.1.1. Connect to LXDE desktop environment via XRDP

Install XRDP

sudo zypper -n in xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp
sudo firewall-cmd --add-port=3389/tcp --permanent
sudo firewall-cmd --reload

echo "lxsession -s LXDE -e LXDE" > ~/.xsession

5.2. 安装 XFCE 桌面

sudo zypper -n in patterns-openSUSE-xfce
sudo reboot

Uninstall Xfce:

sudo zypper -n rm patterns-openSUSE-xfce xfce4-* libxfce4*
sudo reboot

6. 使用 YAST 控制系统设置

# yast

在里面可以使用左右键、Tab 键进行操作。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云满笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值