I decided to make a guide about TCP/IP configuration in Linux, and you may ask: well, what Linux distribution in specific? I know!, there are hundreds of Linux distribution, but for this guide, I’m only going to cover the two most used Linux distribution: Ubuntu and Fedora. Ubuntu is a Debian derivative, so the Ubuntu portion of TCP/IP configuration applies to any distro based on Debian. And the same goes for Fedora, which is based on RedHat Linux.
First, you want to find out what interfaces you have, and what ip address, “if any,” was assigned to your computer. For this use the “ifconfig” command:
ifconfig #will list all enabled interfaces
if you are looking for a specific interface:
ifconfig eth0 #will only display the configuration for eth0 interface
If you get no interfaces other than the loopback address, it is time to do some troubleshooting and find out whether your network card was detected by Linux or not.
sudo lspci | grep -i ethernet #displaying all your ethernet cards
if you’re troubleshooting a wireless card just change “ethernet” for “wireless.”
other useful command when troubleshooting network card and drivers is “lsmod”
By default Ubuntu starts in automatic TCP/IP configuration, this means that once Ubuntu starts, it will ask the DHCP server for an ip address. However, if you are using a distro that is not enabling the eth0 (network interface) at startup, you can do so manually.
sudo ifconfig eth0 up #enabling the network interface
After you enable the interface, it is time to start the network service. This will contact the DHCP server and negotiate and ip address.
sudo /etc/init.d/networking start #start networking all interfaces
And that’s all there is for dynamic ip configuration in Ubuntu.
Now, if you need to use static ip, you need to edit the “/etc/network/interfaces” file:
sudo gedit /etc/network/interfaces #edit the network interfaces file
auto lo iface lo inet loopback iface eth0 inet static address 192.168.10.200 netmask 255.255.255.0 gateway 192.168.10.1 broadcast 192.168.10.255 network 192.168.10.0 nameserver 192.168.10.1
if you don’t know what is the correct network mask for your network or ip address, check out this article on calculating netmask.
Once you have finished adding your ip configuration, then proceed to reset your network srervice.
sudo /etc/init.d/networking restart #restarting networking
If your Fedora distribution is set to get a dynamic ip; then, you probably don’t have to do anything; however, if the os starts and you don’t get an ip, a good rule of thumb is to start by enabling the ethernet card.
need root access!
ifconfig eth0 up #bringing eth0 up
After enabling the interface, you should start the network service.
service network start #starting network service
The file that contains the TCP/IP configuration in Fedora is different from its counterpart Ubuntu. In Fedora the file is: /etc/sysconfig/network-scripts/ifcfg-eth0
need root access!
vi /etc/sysconfig/network-scripts/ifcfg-eth0 #edit TCP/IP configuration
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes HWADDR=00:1b:21:47:5d:c2 BROADCAST=192.168.10.255 IPADDR=192.168.10.5 NETMASK=255.255.255.0 GATEWAY=192.168.10.1 NETWORK=192.168.10.0 DNS1=192.168.10.1 DNS2=192.168.10.2
Usually, the resolve.conf file, which contains the DNS server ip address, gets its setting from “ifcfg-eth0″ file, but if that’s not the case, you can update it.
vi /etc/resolv.conf #DNS configuration file
# Generated by NetworkManager nameserver 192.168.10.1 nameserver 192.168.10.2
Hello from Russia!
Can I quote a post in your blog with the link to you?
sure, no problem!