Linux 网络原理及基础设置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 网络原理及基础设置相关的知识,希望对你有一定的参考价值。
临时配置网络(ip,网关,dns)+永久配置
设置IP和掩码
ifconfig eth0
192.168.2.2 netmask
255.255.255.0
设置网关
route add default gw
192.168.2.10
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEVICE=eth0
IPADDR=
192.168.2.2
NETMASK=
255.255.255.0
GATEWAY=
192.168.2.10
DNS1=
192.168.16.254
ONBOOT=yes
[[email protected] ~]# cat /etc/resolv.conf
nameserver
192.168.16.254
为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式
设置IP和掩码
ifconfig eth0


设置网关
route add default gw

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEVICE=eth0
IPADDR=

NETMASK=

GATEWAY=

DNS1=

ONBOOT=yes
[[email protected] ~]# cat /etc/resolv.conf
nameserver

为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式
修改主机名:
hostname python_web1
cat /etc/hostname
python_web1
修改host文件:
[[email protected]_web1 ~]# cat /etc/hosts
192.168.2.3 python_web1
[[email protected]_web1 ~]# ping python_web1
ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试
[[email protected]_web1 ~]# cat /etc/hosts

[[email protected]_web1 ~]# ping python_web1
ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试
修改ssh的服务端口:
[[email protected]_web1 ~]# cat /etc/ssh/sshd_config |grep Port
Port 52000
[[email protected]_web1 ~]# systemctl restart sshd.service
Port 52000
[[email protected]_web1 ~]# systemctl restart sshd.service
ssh登录
ssh秘钥登录
[[email protected]_web1 ~]# ssh-keygen
[[email protected]_web1 ~]# ssh-copy-id -i ./.ssh/id_rsa.pub

[[email protected]_web1 ~]# ssh -p 52000

bash命令类型,验证寻找一个命令的优先级
命令分为:
==> alias(别名)
==> Compound Commands()
==> function
==> build_in
==> hash
==> $PATH
==> error: command not found
以上是关于Linux 网络原理及基础设置的主要内容,如果未能解决你的问题,请参考以下文章