1. 网络命令
ifconfig:配置/查看网络接口命令
网络配置文件路径:/etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
HWADDR=00:0C:29:AA:02:D6
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
IPADDR=192.168.226.139
NETMASK=255.255.255.0
GATEWAY=192.168.226.2
[root@localhost ~]# service network restart # 重启网络服务
注:
ONBOOT=yes 是否开机启动
BOOTPROTO=static 固定配置IP或DHCP方式
当BOOTPROTO=static时 IPADDR,NETMASK,GATEWAY是必要
当BOOTPROTO=dhcp时 IPADDR,NETMASK,GATEWAY 不需求
域名文件
/etc/resolv.conf
虚拟机需要添加 nameserver
例如:
[root@localhost ~]# vim /etc/resolv.conf
# Generated by NetworkManager
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
nameserver 192.168.1.1
[root@localhost ~]# service network restart
2. Centos代理上网设置
一、centos自带界面设置代理
1. 界面设置
2. firefox设置
设置 ->局域网设置 -> ip:port / username:passwd
二、terminal分别设置代理
临时代理proxy
如果只是暂时使用代理,在命令行输入下面一条命令:
[root@localhost ~]# export http_proxy="http://210.45.72.XX:808"
另外:
/root/.bashrc中加入:
export http_proxy="http://username:password@210.45.72.XX:808"
如果是通过ip或电脑的网卡地址认证,可忽略所有username 和 password .
注:停止使用代理的时候,要把改过的文件改成原样.
尤其是如果使用了export http_proxy="http://210.45.72.XX:808"命令,
要在命令行输入:unset http_proxy ,去除环境变量.
因为export http_proxy=”http://210.45.72.XX:808”这条命令的实质是把export后面的设置写进环境设置文件中.
输入env 可以看所有的环境变量设置.
env >env.txt 可以把环境变量输出到env.txt中,然后打开看也可以.
unset 变量可以取消曾经设过的环境变量.
2. 全局代理proxy
文件目录
[root@localhost ~]# vim /etc/profile
添加如下
http_proxy=http://username:password@yourproxy:8080/
ftp_proxy=http://username:password@yourproxy:8080/
export http_proxy
export ftp_proxy
环境变量
[root@localhost ~]# source /etc/profile 使配置生效
3. yum proxy
文件目录
[root@localhost ~]# vim /etc/yum.conf
添加如下
proxy=http://username:password@yourproxy:8080/
环境变量
[root@localhost ~]# source /etc/profile
4. wget proxy
文件目录
[root@localhost ~]# vim /etc/wgetrc
最后行添加如下
http_proxy=http://username:password@yourproxy:8080
https_proxy=http://username:password@yourproxy:8080
ftp_proxy=http://username:password@yourproxy:8080
环境变量
[root@localhost ~]# source /etc/profile