代码改变世界

linux链接外网手动设置

2015-02-09 23:45  hf_sun  阅读(352)  评论(0编辑  收藏  举报

/etc/sysconfig/network-scripts/ifcfg-eth0  设置IP网关等参数

DEVICE=eth0
HWADDR=00:0C:29:C5:43:34
TYPE=Ethernet
UUID=c3d6f295-096b-4f80-a314-0cec776d1cdf
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
BROADCAST=192.168.138.255
IPADDR=192.168.138.100
NETMASK=255.255.255.0
NETWORKING_IPV6=no
GATEWAY=192.168.138.2
DNS1=202.106.0.20
DOMAIN=202.106.46.151

 

 

/etc/resolv.conf  设置DNS服务器地址

nameserver 202.106.0.20
nameserver 8.8.4.4
nameserver 144.144.144.144
search 202.106.46.151

 

临时设置所用的参数:

ifconfig eth0 192.168.1.1 netmask 255.255.255.0 设置IP以及mask地址

route add default gw 192.168.1.1  设置网关

route del default 删除默认网关

route -n 查看网关