linux基本配置命令,Linux网络基本配置命令(示例代码)

修改方法:

命令方式,大多是立即生效、临时有效;

GUI图形方式,

修改配置文件,重启服务有效

1、修改主机名

hostname查看

hostname name临时修改

hostnamectlset-hostname name永久有效(cnetos7)

centos7/etc/hostname

centos6/etc/sysconfig/network

2、网络接口配置

vi修改配置文件

ifconfig查看或设置网卡的TCP/IP参数

[[email protected] ~]$ ifconfig

enp0s31f6: flags=4163 mtu 1500        enp0/etho第一块物理网卡 mtu分组的最大传送单元 flags网络接口状态up....(活动)inet192.168.1.125 netmask 255.255.255.0 broadcast 192.168.1.255 inet/inet addr网卡的IP地址 netmask/Mask子网掩码 boadcast/bcast广播地址inet6 fe80::c133:9f47:a9f:66 prefixlen 64 scopeid 0x20    ine网卡IPv6ether c8:5b:76:25:af:01 txqueuelen 1000(Ethernet)          ether/Hwaddr网卡的物理地址mac地址 txqueuelen传送队列的长度

RX packets4673305 bytes 3223334449 (3.0GiB)             RX packets接受的数据包总数

RX errors0 dropped 0 overruns 0 frame 0TX packets2439350 bytes 305949223 (291.7MiB)             TX packets发送的数据包总数

TX errors0 dropped 0 overruns 0 carrier 0 collisions 0device interrupt16 memory 0xe1300000-e1320000

lo: flags=73 mtu 65536inet127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10loop txqueuelen1(Local Loopback)

RX packets45571 bytes 3060724 (2.9MiB)

RX errors0 dropped 0 overruns 0 frame 0TX packets45571 bytes 3060724 (2.9MiB)

TX errors0 dropped 0 overruns 0 carrier 0 collisions 0wlp1s0: flags=4099 mtu 1500ether b8:81:98:5a:7f:17 txqueuelen 1000(Ethernet)

RX packets1284454 bytes 1267419395 (1.1GiB)

RX errors0 dropped 0 overruns 0 frame 0TX packets913186 bytes 155893700 (148.6MiB)

TX errors0 dropped 0 overruns 0 carrier 0 collisions 0

当前有3个网络接口信息,一个是enp0是系统的第一块网卡信息;lo代表loopback环回接口,是Linux内部通信的基础,IP始终为127.0.0.1;

ifconfig 网卡名 netmask   此命令会立即生效,但不会修改配置文件。

ifconfig eth0 192.168.1.10 netmask 255.255.255.0  设置网卡

ifconfig eth0:1 192.168.1.10 netmask 255.255.255.0  eth0:1为设置虚拟网卡

mac地址,全球唯一,由网络设备制造商生产时写入网卡内部。mac地址长度为48位的十六进制数,用冒号分割 c8:5b:76:25:af:01,前六为为网卡制造商编号,后六位为系列号。要更改mac地址,需要先禁用该网卡,然后使用ifconfig

ifconfig 网卡名 down禁用网卡

ifconfig 网卡名 hw ether c8:5b:76:25:af:01修改网卡

ifconfig 网卡名 up启用网卡

永久修改网卡配置文件要去/etc/sysconfig/network-scripts/ifcfg-eth0, 然后重启网络服务network

ip addr命令看到的是啥??

此外还有图形配置方法!(菜单; system-config-network命令; system-config-network-tui命令)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值