linux下配置临时IP

临时配置ip
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
缩略:ifconfig eth0 192.168.1.1

停止网卡: ifconfig eth1 down 启动网卡: ifconfig eth1 up

临时配置子接口: ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0 up


永久配置子接口:
修改配置文件:vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

重启网开生效: service network restart

查看
1.ifconfig

2.eth0

3.eth0:0
192.168.1.128/26 ----192.168.1.128/26-192.168.1.191/26

********************************************************************************************************************************
配置主机名:
查看主机名:
hostname
uname -n
临时配置:
hostname helloworld
永久配置
vim /etc/sysconfig/network
HOSTNAME=helloword
********************************************************************************************************************************
添加路由:
查看:route

route -n ---- -n参数不做域名解析
[root@Jasmine Desktop]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 172.16.13.254 0.0.0.0 UG 0 0 0 eth0


********************************************************************************************************************************
添加网关: (添加,默认路由)

route add default gw 172.16.13.254

添加静态路由:
route add -net 192.168.8.0 netmask 255.255.255.0 gw 192.168.1.1

---如果想找到192.168.8.0/24 网段内的IP,可以从192.168.1.1这个网卡接口出去
删除静态路由:
route del -net 192.168.8.0 netmask 255.255.255.0 gw 192.168.1.1
route del default gw 172.16.13.254

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值