suse-linux:~ # cat /etc/issue
Welcome to SUSE Linux Enterprise Server 12 SP3 (x86_64) - Kernel \r (\l).
suse-linux:~ # uname -a
Linux suse-linux 4.4.73-5-default #1 SMP Tue Jul 4 15:33:39 UTC 2017 (b7ce4e4) x86_64 x86_64 x86_64 GNU/Linux
suse-linux:~ # cd /etc/sysconfig/network/
suse-linux:/etc/sysconfig/network # ll
total 60
-rw-r--r-- 1 root root 9692 Nov 24 04:30 config
-rw-r--r-- 1 root root 11495 Nov 24 04:30 dhcp
drwxr-xr-x 1 root root 40 Nov 24 04:30 if-down.d
drwxr-xr-x 1 root root 66 Nov 24 04:30 if-up.d
-rw-r--r-- 1 root root 206 Nov 30 21:45 ifcfg-eth0
-rw------- 1 root root 147 Nov 24 04:30 ifcfg-lo
-rw-r--r-- 1 root root 21738 Oct 14 2016 ifcfg.template
drwx------ 1 root root 0 Jun 27 2017 providers
drwxr-xr-x 1 root root 206 Nov 24 04:30 scripts
配置ip,dns,网关
配置ip
suse-linux:/etc/sysconfig/network # cat ifcfg-eth0
BOOTPROTO='static' # 网络模式:dhcp(自动获取)、static(静态,或者none也可以)
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='192.168.10.150/24' # IP地址
MTU=''
NAME=''
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto' # 开机启动网卡
DHCLIENT_SET_DEFAULT_ROUTE='yes'
PREFIXLEN=''
配置网关
suse-linux:/etc/sysconfig/network # vim ifroute-eth0 # 这个文件需要自己创建
default 192.168.10.2 - eth0
配置dns
suse-linux:/etc/sysconfig/network # cat /etc/resolv.conf
#
#
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
# NETCONFIG_DNS_STATIC_SEARCHLIST
# NETCONFIG_DNS_STATIC_SERVERS
# NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
# NETCONFIG_DNS_POLICY=''
#
#
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
nameserver 192.168.10.2
验证
suse-linux:~ # systemctl restart network
suse-linux:~ # ping www.baidu.com -w 1
PING www.a.shifen.com (180.101.49.12) 56(84) bytes of data.
64 bytes from 180.101.49.12: icmp_seq=1 ttl=128 time=27.6 ms
--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 27.625/27.625/27.625/0.000 ms
hostname
# 之所以提到hostname,是因为最近使用的时候,因为是自己测试使用,没有配置静态ip,导致机器重启,hostname变了,强迫症不喜欢,百度了好多,都是修改hosts文件,就自己尝试了修改dhcp配置文件后,得到了解决,因此更新一下
# 静态IP
suse-linux:~ # hostnamectl set-hostname suse-linux --static
# dhcp IP // dhcp获取的ip,当机器重启的时候,hostname会变成bogon,导致修改的hostname会不生效,但是/etc/HOSTNAME文件中,hostname依旧是设置的hostname,有以下解决方法
suse-linux:~ # vim /etc/sysconfig/network/dhcp
DHCLIENT_HOSTNAME_OPTION="" # 默认是AUTO,会影响hostname
ssh
suse-linux:~ # vim /etc/ssh/sshd_config # 下面两项打开注释,改为yes即可
PermitRootLogin yes # 允许root用户登录
PasswordAuthentication yes # 开启密码验证
suse-linux:~ # systemctl restart sshd
关闭防火墙
'suse里面的防火墙名称是SuSEfirewall2,和centos不一样'
suse-linux:~ # systemctl disbale SuSEfirewall2 --now
suse-linux:~ # systemctl status SuSEfirewall2
● SuSEfirewall2.service - SuSEfirewall2 phase 2
Loaded: loaded (/usr/lib/systemd/system/SuSEfirewall2.service; disabled; vendor preset: disabled)
Active: inactive (dead)
总结
初次使用suse很不习惯,虽然有很多命令和centos是一样的,但是极个别的还是不太一样:
1、suse的软件安装方式使用的是zypper,而centos是yum(很多服务只好选择编译或者二进制的方式部署了)
2、suse的静态网卡配置也和centos不一样(当时配的我有点蒙圈)
3、suse的firewalld服务器名称和centos不一样
4、suse默认关闭selinux(这点很赞啊,centos如果disabled掉还需要重启机器,贼烦)
5、suse有的时候命令行会有小bug,会导致命令不存在(多敲几次回车就好了~~~)
6、suse终端默认显示的红色挺好看的(颜狗只看外表,不看其他的)
慢慢和suse磨合磨合