How to configure DHCP address for a specific network card
In order to configure DHCP address you will need to edit the 'interfaces' file /etc/network/interfaces .
sudo vi /etc/network/interfaces |
# The primary network interface use DHCP to find our address auto eth0 iface eth0 inet dhcp |
sudo /etc/init.d/networking restart |
Note: Replace eth0 with your own network interface card. Also learn vi commands to edit/save files - here.
How to configure Static IP address for your network card
In order set static IP address you need to edit the /etc/network/interfaces.
sudo vi /etc/network/interfaces |
# The primary network interface auto eth0 iface eth0 inet static address 192.168.1.7 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 |
sudo /etc/init.d/networking restart |
DNS configuration of the Ubuntu is similar to that of other linux flavors or distributions. For static lookup you will need to add hostname and corresponding IP address to the file /etc/hosts as explained in next section.
In order to use a particular domain name server for name lookup you simply need to add its IP address to the file /etc/resolv.conf. For example if we want to use a domain name server, with IP address 192.168.1.10, for domain name lookup we will have to edit resolv.conf file. Open the file with the following command.
sudo vi /etc/resolv.conf |
search test.com nameserver 192.168.1.10 |
Hostname can be very easily manipulated in Ubuntu. You can directly query, or set the hostname with the hostname command.
To see the current hostname use the following command.
sudo /bin/hostname |
sudo /bin/hostname newhostname |
How to setup second IP address or virtual IP address in Ubuntu
Sometimes you may need to setup a second IP address for your computer, specially if you are a server administrator. To do this you need to edit the /etc/network/interfaces file.
sudo vi /etc/network/interfaces |
auto eth0:1 iface eth0:1 inet static address 192.168.1.60 netmask 255.255.255.0 network x.x.x.x broadcast x.x.x.x gateway x.x.x.x |
sudo /etc/init.d/networking restart
No comments:
Post a Comment