2014年7月16日 星期三

[CentOS 7.0] Configure Networking

[1] Set static IP address to the server. ( Replace the section 'ifcfg-***' to your own interface name )

# install the package below which includes ifconfig, netstat and so on first

[root@dlp ~]#yum -y install net-tools

[root@dlp ~]#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

HWADDR="00:0C:29:CD:9C:2D"
TYPE="Ethernet"


# change
BOOTPROTO="none"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="3eb052b5-f8f2-4609-b70b-e44a050f6524"
ONBOOT="yes"
# add like follows
# this server's IP address
IPADDR="10.0.0.30"

# subnet mask
NETMASK="255.255.255.0"

# default gateway
GATEWAY="10.0.0.1"

# DNS server's IP address
DNS1="10.0.0.1"

[root@dlp ~]#systemctl stop NetworkManager

[root@dlp ~]#systemctl disable NetworkManager

rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'

[root@dlp ~]#systemctl restart network

[root@dlp ~]#chkconfig network on

[root@dlp ~]#ifconfig

eno16777736: flags=4163  mtu 1500
        inet 10.0.0.30  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::20c:29ff:fecd:9c2d  prefixlen 64  scopeid 0x20
        ether 00:0c:29:cd:9c:2d  txqueuelen 1000  (Ethernet)
        RX packets 5978  bytes 7634267 (7.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3256  bytes 287222 (280.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



[2] Disable IPv6 if you do not need it.

[root@dlp ~]#vi /etc/default/grub

# line 6: add
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=fedora/swap rd.md=0.....

# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg

[root@dlp ~]#reboot

[3] if you'd like to use the network interface name as ethX, configure like follows.

[root@dlp ~]#vi /etc/default/grub

# line 6: add
GRUB_CMDLINE_LINUX="net.ifnames=0 rd.lvm.lv=fedora/swap rd.md=0.....

# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg

[root@dlp ~]#reboot

沒有留言: