Você está na página 1de 5

1. Open Terminal.

2. Open network configuration file. In this example, it’ll configure on interface eth0. Type

vi /etc/sysconfig/network-scripts/ifcfg-eth0

3. The current configuration is DHCP.

4. Modify the file by press ‘i’ to enter insert mode. Change BOOTPROTO to static and add IP Address and Net mask as new lines
if they’re not existed yet..

BOOTPROTO=static
IPADDR=192.168.125.10
NETMASK=255.255.255.0
Save the configuration file by press ESC + ‘:’ and type ‘wq’ to write and quit the editor.

5. You can added these configuration to the config file. Replace [number] with your actual value.

GATEWAY=[number]
TYPE=Ethernet
NETWORK=[number]
BROADCAST=[number]
6. Restart the network interface card. Type

service network restart

7. Review the configuration. Type

ifconfig

. The IP Address has been changed permanently.

Method #3: Edit configuration files stored in /etc/sysconfig/network-scripts/


You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/directory. First change
directory to /etc/sysconfig/network-scripts/:
# cd /etc/sysconfig/network-scripts/
You need to edit / create files as follows:
 /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file
 /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file
To edit/create first NIC file, type command:
# vi ifcfg-eth0
Append/modify as follows:

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)


DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes
Save and close the file. Define default gateway (router IP) and hostname in /etc/sysconfig//network file:
# vi /etc/sysconfig/network
Append/modify configuration as follows:
NETWORKING=yes
HOSTNAME=www1.nixcraft.in
GATEWAY=10.10.29.65
Save and close the file. Restart networking:
# /etc/init.d/network restart
Make sure you have correct DNS server defined in /etc/resolv.conf file:
# vi /etc/resolv.conf
Setup DNS Server as follows:
nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222
Save and close the file. Now you can ping the gateway/other hosts:
$ ping 10.0.80.12
Output:

PING 10.0.80.12 (10.0.80.12) 56(84) bytes of data.

64 bytes from 10.0.80.12: icmp_seq=1 ttl=251 time=0.972 ms

64 bytes from 10.0.80.12: icmp_seq=2 ttl=251 time=1.11 ms

You can also check for Internet connectivity with nslookup or host command:
$ nslookup cyberciti.biz
Output:

Server: 10.0.80.11

Address: 10.0.80.11#53
Non-authoritative answer:

Name: cyberciti.biz

Address: 75.126.43.232

You can also use host command:


$ host nixcraft.in
Output:

nixcraft.in has address 75.126.43.232

nixcraft.in mail is handled by 10 mail.nixcraft.in.

I am not an iptables expert by any means and nor do I claim to be (which explains the limited scope of this document). This
tutorial describes the steps for a basic configuration for the iptables firewall on RedHat Linux 9. I will only give instructions for
opening certain ports on a single ethernet adapter and conclude with blocking IP's of hosts you want to disallow access. Iptables
allows for much more than mentioned here, but this should be enough to get you started in opening ports for specific services and
protecting your server from unauthorized access. I will not be going into the details of installing iptables, so it is assumed you
already have it since the RedHat 9 installation includes it typically by default.

The first thing we want to do is make sure iptables is running and that it will always start at bootup. If you are not root then
become root and issue the following command.

/etc/init.d/iptables start

You should see something similar to this.

Now we will make sure it starts at bootup. In my previous tutorials I have used chkconfig, but this time I will use the RedHat Text
Mode Setup Utility. Issue the following command.

setup

The RedHat Text Mode Setup Utility should start.


Scroll down to System Services and press enter. Then scroll down the list of services till you reach iptables. If it is not selected,
press the spacebar to select it.
Tab to the OK button then press enter. Tab to the Quit button and press enter. Iptables will now start everytime you boot up.

Next we will create some rules for our firewall.

Você também pode gostar