码迷,mamicode.com
首页 > 系统相关 > 详细

linux配置ip子网dns

时间:2018-11-14 23:16:06      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:editor   ssi   查看   computer   连接   each   alt   ethos   edit   

1)从命令行将Linux主机重启
# reboot
2)从命令行将Linux主机关机
# poweroff



.配置网络
# ifconfig 查看当前网络信息(IP地址、子网掩码)
# route -n 查看网关
# cat /etc/resolv.conf 查看dns地址
# hostnamectl 查看主机名

图形配置网络
Alt+F2
nm-connection-editor
右上角把网络重新激活
验证
hostnamectl -sethostname xxx.xxx.xxx
[root@localhost ~]# hostnamectl
[root@localhost ~]# hostnamectl set-hostname teacher.tedu.cn
[root@localhost ~]# hostnamectl
Static hostname: teacher.tedu.cn
Icon name: computer-vm
Chassis: vm
Machine ID: d3f0970c5308449d950e3453c9a449ba
Boot ID: c5799a77789d47ca9a670064a03655eb
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

命令配置网络
# nmcli device status 列出所有的网卡设备
# nmcli connection show 列出已配置的网络连接
手动设置IP地址/掩码,允许自动连接
nmcli con mod "连接名" ipv4.method manual ipv4.address "IP地址/掩码位数"
# nmcli connection modify eth0 ipv4.method manual ipv4.addresses "10.0.0.10/255.255.255.0"

nmcli con mod "连接名" connection.autoconnect yes
# nmcli connection modify eth0 connection.autoconnect yes

手动指定默认网关、DNS地址
# nmcli con mod "连接名" ipv4.gateway 默认网关地址
# nmcli con mod "连接名" ipv4.dns DNS地址
# nmcli connection modify eth0 ipv4.gateway 10.0.0.254
# nmcli connection modify eth0 ipv4.dns 4.4.4.4

停用指定连接
nmcli con down "连接名"
激活指定连接
nmcli con up "连接名"

# nmcli connection down eth0
# nmcli connection up eth0
# ifconfig *
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.10 netmask 255.255.255.0 broadcast 10.0.0.255

route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.254 0.0.0.0 UG 100 0 0 eno16777736

cat /etc/resolv.conf

Generated by NetworkManager

search tedu.cn
nameserver 4.4.4.4

linux配置ip子网dns

标签:editor   ssi   查看   computer   连接   each   alt   ethos   edit   

原文地址:http://blog.51cto.com/13562306/2317079

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!