CetnOS7网络配置
取消系统网卡自动命名
[[email protected] ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 crashkernel=auto rhgb quiet"
[[email protected] ~]# grub2-mkconfig -o /etc/grub2.cfg #重启生成配置
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-749597373cb946aa90c4209f5895777f
Found initrd image: /boot/initramfs-0-rescue-749597373cb946aa90c4209f5895777f.img
done
[[email protected] ~]# init 6
1 nmcli
[[email protected] ~]# nmcli g status
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled
1.1 nmcli-device
查看接口设备状态
[[email protected] ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
lo loopback unmanaged --
查看eth0接口详细信息
[[email protected] ~]# nmcli device show eth0
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:A7:7A:EC
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/4
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 10.201.106.131/24
IP4.ADDRESS[2]: 10.201.106.130/24
IP4.GATEWAY: 10.201.106.2
IP6.ADDRESS[1]: fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:
1.2 nmcli-connect
显示当前所有可用状态的连接
[[email protected] ~]# nmcli connect show
NAME UUID TYPE DEVICE
eth0 cc0a4203-e54a-4089-8495-52ddf502947d 802-3-ethernet eth0
Wired connection 1 daa49f62-6735-4a92-9fbe-227c9e036110 802-3-ethernet --
ens33 7b110e50-0afe-42e1-862b-f597400a572c 802-3-ethernet --
查看支持的语言
[[email protected] ~]# localectl list-locales | grep en.
修改语言环境
[[email protected] ~]# localectl set-locale LANG=en_US.utf8
重启网络服务(CentOS7)
[[email protected] network-scripts]# systemctl restart NetworkManager[[email protected] network-scripts]# systemctl restart network
添加第二地址
[[email protected] ~]# nmcli c modify eth0 +ipv4.addresses 10.201.106.222/24
禁用并启用网络接口
[[email protected] ~]# nmcli connection down eth0;nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
删除地址,需要重启接口生效
[[email protected] ~]# nmcli connection modify eth0 -ipv4.addresses 10.201.106.222/24
[[email protected] ~]# nmcli connection down eth0; nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/0)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
[[email protected] ~]# nmcli dev show eth0
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:A7:7A:EC
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 10.201.106.133/24
IP4.ADDRESS[2]: 10.201.106.130/24
IP4.GATEWAY: 10.201.106.2
IP4.DNS[1]: 10.201.106.2
IP4.DOMAIN[1]: localdomain
IP6.ADDRESS[1]: fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:
修改网关,修改和增加DNS
[[email protected] ~]# nmcli connection modify eth0 ipv4.gateway 10.201.106.2 ipv4.dns 10.201.106.2 +ipv4.dns 8.8.8.8
[[email protected] ~]# nmcli connection down eth0; nmcli connection up eth0
Connection ‘eth0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
[[email protected] ~]# nmcli dev show eth0
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:A7:7A:EC
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/3
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 10.201.106.133/24
IP4.ADDRESS[2]: 10.201.106.130/24
IP4.GATEWAY: 10.201.106.2
IP4.DNS[1]: 10.201.106.2
IP4.DNS[2]: 8.8.8.8
IP4.DOMAIN[1]: localdomain
IP6.ADDRESS[1]: fe80::20c:29ff:fea7:7aec/64
IP6.GATEWAY:
2 nmtui
3 hostnamectl
查看主机名
[[email protected] ~]# hostnamectl status
Static hostname: CentOS7.2.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 749597373cb946aa90c4209f5895777f
Boot ID: 9be2af2f19f147928f7db61e825111ed
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
修改主机名
[[email protected] ~]# hostnamectl set-hostname qq
[[email protected] ~]# hostname
qq
网络小工具
lftp
登陆文件服务器
[[email protected] tmp]# lftp 10.201.106.128
lftp 10.201.106.128:~> ls
drwxr-xr-x 2 0 0 4096 Jun 16 04:01 pub
lftp 10.201.106.128:/>
下载单个软件和多个软件
lftp 10.201.106.128:/pub> get 110.txt ###下载单个
get: /tmp/110.txt: File exists
lftp 10.201.106.128:/pub>
lftp 10.201.106.128:/pub>
lftp 10.201.106.128:/pub> mget ./* ###下载多个
mget: /tmp/110.txt: File exists
基于ftp链接下载软件
[[email protected] tmp]# lftpget ftp://10.201.106.128/pub/110.txt
get1: 110.txt: File exists
ftp(比lftp还要古老)
匿名登陆
[[email protected] tmp]# ftp 10.201.106.128
Connected to 10.201.106.128 (10.201.106.128).
220 (vsFTPd 2.2.2)
Name (10.201.106.128:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10,201,106,128,35,197).
150 Here comes the directory listing.
drwxr-xr-x 2 0 0 4096 Jun 16 04:01 pub
226 Directory send OK.
ftp>
原文地址:http://blog.51cto.com/zhongle21/2091354
时间: 2024-11-01 20:52:57