Thứ Hai, 23 tháng 9, 2013

// // Leave a Comment

Linux - CentOS

gán ip tĩnh
chạy lệnh 
Code:
ifconfig
để xem tên card mạng muốn sửa.

Vào card mạng muốn sửa:
vi /etc/sysconfig/network-scripts/ifcfg-eth0

Thiết lập IP tĩnh khi không muốn nhận địa chỉ từ DHCP cấp
[root@server1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Gõ vào:
DEVICE=eth0
HWADDR=00:0C:29:A2:A0:4F
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.100.110
NETMASK=255.255.255.0
TYPE=Ethernet
GATEWAY=192.168.100.2
DNS1=192.168.100.110
DNS2=8.8.8.8
IPV6INIT=no
USERCTL=no
Restart card mạng
[root@server1 ~]# /etc/rc.d/init.d/network restart 
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@server1 ~]#
[root@server1 ~]# chkconfig network on
Gõ lệnh ifconfig để kiểm tra địa chỉ IP
[root@server1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:A2:A0:4F
inet addr:192.168.100.110 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea2:a04f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:193 errors:0 dropped:0 overruns:0 frame:0
TX packets:187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18564 (18.1 KiB) TX bytes:20387 (19.9 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:172 (172.0 b) TX bytes:172 (172.0 b)

[root@server1 ~]#

* Disable IPv6

[root@server1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:A2:A0:4F
inet addr:192.168.100.110 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea2:a04f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:193 errors:0 dropped:0 overruns:0 frame:0
TX packets:187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18564 (18.1 KiB) TX bytes:20387 (19.9 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:172 (172.0 b) TX bytes:172 (172.0 b)
[root@server1 ~]# echo "install ipv6 /bin/true" > /etc/modprobe.d/disable-ipv6.conf
[root@server1 ~]#reboot
[root@server1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:A2:A0:4F
inet addr:192.168.100.110 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:31 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3553 (3.4 KiB) TX bytes:4865 (4.7 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:172 (172.0 b) TX bytes:172 (172.0 b)

Gõ lệnh Ping để kiểm tra kết nối
[root@server1 ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=140 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=140 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=141 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=140 ms

0 nhận xét:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.