配置网络参数

配置网络参数

[@more@]配置和查看IP地址

查看IP地址
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:01:02:03:04:05
inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::201:2ff:fe03:405/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9380 errors:0 dropped:0 overruns:0 frame:0
TX packets:9095 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:788518 (770.0 KiB) TX bytes:1299956 (1.2 MiB)
Interrupt:169 Base address:0x2000

配置主接口的IP地址
# ifconfig eth0 up
# ifconfig eth0 10.10.10.10/24

配置子接口的IP地址
# ifconfig eth0:3 11.11.11.11/24

修改网卡的MAC地址
[root@linux-wnt ~]# ifconfig eth0 down
[root@linux-wnt ~]# ifconfig eth0 hw ether 00:01:02:03:04:05
[root@linux-wnt ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:01:02:03:04:05
inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::201:2ff:fe03:405/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5734 errors:0 dropped:0 overruns:0 frame:0
TX packets:4868 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:493686 (482.1 KiB) TX bytes:584824 (571.1 KiB)
Interrupt:169 Base address:0x2000
[root@linux-wnt ~]# ifconfig eth0 up

了解网卡的原MAC地址
# lshal |grep net.address
net.address = '00:0c:29:7c:37:ef' (string)
配置和查看路由

之前需要知道主机当前IP地址的网络地址
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:01:02:03:04:05
inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::201:2ff:fe03:405/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9380 errors:0 dropped:0 overruns:0 frame:0
TX packets:9095 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:788518 (770.0 KiB) TX bytes:1299956 (1.2 MiB)
Interrupt:169 Base address:0x2000

配置主机路由,注意网关地址一定要与当前主机在同一网段
# route add –host 1.1.1.1 gw 10.10.10.1

配置网络地址,注意网关地址一定要与当前主机在同一网段
# route add –net 1.1.1.0/24 gw 10.10.10.1

配置默认路由,注意网关地址一定要与当前主机在同一网段
# route add default gw 10.10.10.1

查看路由表
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
11.0.0.0 10.10.10.1 255.255.255.0 UG 0 0 0 eth0
12.0.0.0 10.10.10.1 255.255.255.0 UG 0 0 0 eth0
10.10.10.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
配置和查看主机名

查看主机名
# hostname
linux

修改主机名
# hostname linux
向导方式配置网络参数

# setup

之后需要重新启动网络服务
# service network restart
使用配置文件配置IP地址

修改接口配置文件
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:01:02:03:04:05
NETMASK=255.255.255.0
IPADDR=10.10.10.10
TYPE=Ethernet
使用配置文件配置路由
# vi /etc/sysconfig/network-scripts/route-eth0
ADDRESS0=11.0.0.0
NETMASK0=255.255.255.0
GATEWAY0=10.10.10.1
ADDRESS1=12.0.0.0
NETMASK1=255.255.255.0
GATEWAY1=10.10.10.1
使用配置文件配置主机名
# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=linux-wnt

对配置文件做的任何修改都应该重启网络服务,好让配置生效
# service network restart

以上所涉及的配置文件的配置格式出处
# vi /usr/share/doc/initscripts-

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23168012/viewspace-1047878/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23168012/viewspace-1047878/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值