Linux 网络信息配置
修改IP地址
- 转到目录
cd /etc/sysconfig/network-scripts
- 配置如下IP地址
# ifcfg-ens000
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=2100eb08-2643-4bf9-a40f-8b5aaf9c5bad
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.120.160
PREFIX=24
GATEWAY=192.168.120.254
多个网卡配置
# ifcfg-eth0
DEVICE=eth0
HWADDR=30:E1:71:5D:1D:6C
TYPE=Ethernet
UUID=5a7458a8-4508-4f3c-93aa-b2d2b7aac040
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.8.11
NETMASK=255.255.255.0
GATEWAY=192.168.8.254
IPV6INIT=no
USERCTL=no
# ifcfg-eth1
DEVICE=eth1
HWADDR=30:E1:71:5D:1D:6D
TYPE=Ethernet
UUID=5543288b-9b9a-47e4-b466-6af44ec84469
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.11.11
NETMASK=255.255.255.0
IPV6INIT=no
USERCTL=no
- 重启网络服务
sudo systemctl restart network
- 查看网络信息
ip addr show
配置代理上网
- 通过配置文件永久生产
vi /etc/profile
在该配置文件的最后添加代理配置
export http_proxy='http://192.168.169.169:808'
export https_proxy='http://192.168.169.169:808'
使配置文件生效
source /etc/profile
- 命令行,当前生效
export http_proxy='http://ip:port'
export https_proxy='http://ip:port'
- 配置yum工具使用代理
sudo vi /etc/yum.conf
proxy=http://192.168.169.169:808