linux常识:管理IP地址
2014-03-29 01:24
369 查看
方法一:使用命令ifconfig
ifconfig 网络设备 IP地址 hw MAC地址 netmask 掩码地址 broadcast 广播地址 [up/down]//网卡关闭与激活
# ifconfig eth0 down
# ifconfig eth0 up
# ifdown eth0
# ifup eth1
//查看网卡信息
# ifconfig [-a]
# ifconfig eth0
//设置IP信息
# ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
# ifconfig eth0 192.168.10.110 netmask 255.255.255.0 mtu 1412 up
# ifconfig eth1 192.168.10.221 netmask 255.255.255.0 broadcast 192.168.10.255 up
# ifconfig eth1 192.168.10.221 hw ether xx:xx:xx:xx:xx:xx netmask 255.255.255.0 broadcast 192.168.10.255 mtu 1412 up
//添加虚拟网卡
# ifconfig eth0 192.168.10.110 hw ether xx:xx:xx:xx:xx:xx netmask 255.255.255.0 up
方法二:使用命令ip address
//查看ip状态# ip address show
# ip address show dev eth0
//添加ip地址
# ip address add 192.168.10.110/24 brd + dev eth0
# ip address add 192.168.10.221/24 brd + dev eth0 label eth0:0
//删除ip地址
# ip address del 192.168.10.110/24 brd + dev eth0
//清空ip设置
# ip address flush dev eth0
# ip address show dev eth0
//此状态下ifconfig无法查看到第二IP
# ip address add 192.168.10.110/24 brd + dev eth0
# ip address add 192.168.10.221/24 brd + dev eth0
# ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:80:c8:f8:4a:51 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.110/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.221/24 brd 192.168.10.255 scope global secondary eth0
//此状态下ifconfig可以查看到第二IP
# ip address add 192.168.10.110/24 brd + dev eth0
# ip address add 192.168.10.221/24 brd + dev eth0:0
# ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:80:c8:f8:4a:51 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.110/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.221/24 brd 192.168.10.255 scope global secondary eth0:0
注意问题:
ifconfig和ip address添加的IP重启后都会失效,可通过修改/etc/sysconfig/network-scripts/ifcfg-eth0,/etc/sysconfig/network-scripts/ifcfg-eth0:0设置固定IP。
参考链接:
http://linux-ip.net/html/tools-ifconfig.html
http://linux-ip.net/html/tools-ip-address.html
相关文章推荐
- 网络管理之IP地址与子网掩码 Linux详解
- Linux下的用户管理及SSH禁止用户登录和IP连接的配置
- linux查看IP地址
- SpringMVC 接口版本管理/IP访问控制/ANT打包发布到LINUX
- 管理Linux系统下的TCP/IP
- Linux0.11 中对地址的管理
- linux下使用Java获取本机ip地址?
- Linux进程地址管理之mm_struct
- LINUX密码清除及戴尔服务器的管理IP用户密码设置
- Linux下获取本机IP地址
- linux增加/删除虚拟IP地址
- linux 下C实现获取网卡IP和MAC地址
- 如何在 Linux 下大量屏蔽恶意 IP 地址
- 在linux中使用ifconfig不能查看ip地址
- Linux的内存管理主要分为两部分:物理地址到虚拟地址的映射,内核内存分配管理(主要基于slab)。
- Linux编程获取本机IP地址
- Linux下的用户管理总结(含禁止用户和IP登录的方法)
- linux下如何查看主机的外网ip地址
- linux_下IP、网关、DNS地址配置
- Linux进程地址管理之mm_struct