How assign static ip to centOS 7? - bash

I am using centOS 7 and my machine is changing IP randomly on restart. So, I want to assign IP static to get-rid from further changes on other areas.
For example I have to change ip address again and again in putty settings. etc

Please follow the following steps to assign static IP in CentOs7
vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.7.203
NETMASK=255.255.255.0
BROADCAST=192.168.7.255
NETWORK=192.168.7.0
GATEWAY=192.168.7.245
DNS1=8.8.8.8
DNS2=8.8.4.4
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="eth0"
UUID="696cc3d6-ac01-453b-967c-7decf10e6e6a"
DEVICE="eth0"
ONBOOT="yes"
ZONE=public
Now restart network interface by "service network restart"
its all done.

First you can check your IP and subnetmask details from your machine with command
ifconfig
1st Solution :
Create a file named /etc/sysconfig/network-scripts/ifcfg-eth0 as follows:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
PREFIX=24
IPADDR=192.004.6.123
Restart network service: systemctl restart network
2nd Solution :
Open default file vi /etc/sysconfig/network-scripts/ifcfg-ens33
and modify you settings according to below settings
IPADDR=192.004.6.123
NETMASK=255.255.255.0
BROADCAST=192.169.7.255
BOOTPROTO="static"

Related

Use a domain like name to access a test site instead of an IP address

I'm currently testing a few websites on Ubuntu Server installed on Oracle VM Virtual Box on a Windows 11 machine.
I need to type an IP address to access these sites (eg: 192.168.xxx.xxx).
Is it possible to use something like a domain name to access them instead of using an IP address? Like mysite1.com, mysite2.com etc.
I'm not using domain names booked on godaddy or some place like that. Just names for local testing. How can it be done in this scenario? Everything is installed on the same machine.
Add your sites to /etc/hosts file like this:
192.168.... mysite.domain
Yes, you can go to /etc/hosts and apply IP you are using and the domain name you want:
Example.
Open with:
sudo nano /etc/hosts
apply:
192.168.x.x mysite.com
And restart server.
TRY CLEAN CACHE
sudo apt-get install nscd
AND NOW
sudo service nscd restart
or
sudo service dns-clean
To restate your setup, you have one Ubuntu server guest VM (in VirtualBox) running on Windows 11. Because you mentioned the 192.168.x.x IP range I will assume the guest VM is on a "bridged" vbox network adapter that any device on your local network can ping. I also have to assume the IP address(es) you are using are successfully connecting you from your Windows 11 host to your Ubuntu guest. Is all this correct? Does your VM have a desktop and a web application that can reach popular sites on the internet? Does the Ubuntu OS use DHCP or a static IP assignment?
The short answer is yes, you can use domain names instead of IP addresses. If you are not successful connecting to the IP address, switching to domain names will not help you. You have to have all the network dependencies satisfied first.
To choose a domain name for testing;
You should take a look at RFC 6761. Specifically at secion 6; 6.1 - 6.5
https://www.rfc-editor.org/rfc/rfc6761.html
.in-addr.arpa.
10.in-addr.arpa. 21.172.in-addr.arpa. 26.172.in-addr.arpa.
16.172.in-addr.arpa. 22.172.in-addr.arpa. 27.172.in-addr.arpa.
17.172.in-addr.arpa. 30.172.in-addr.arpa. 28.172.in-addr.arpa.
18.172.in-addr.arpa. 23.172.in-addr.arpa. 29.172.in-addr.arpa.
19.172.in-addr.arpa. 24.172.in-addr.arpa. 31.172.in-addr.arpa.
20.172.in-addr.arpa. 25.172.in-addr.arpa. 168.192.in-addr.arpa.
.test.
.localhost.
.invalid.
.example.com.
.example.net.
.example.org.
You may have to create/modify the \windows\system32\drivers\etc\hosts file that Windows uses to intercept asking DNS for IP/host mapping. If you are using a linux/unix client, the /etc/nsswitch.conf AND /etc/hosts files could override DNS for you. This may or may not be in the same location on Windows 11 but as of Windows 10 21H2 it was still there.

Can't ping window vm from Centos vm. How can i fix this?

I have added the window's vm ip address in /etc/hosts and similary placed hostname and ip address under C//Windows/System32/etc/hosts folder but yet on pinging the packets is not receiving.
Hi I can't to do comments that's why I writing here. Do you use cloud provider or other virtualization tool (virtualbox for exampele)?
If you don't have curl instal it use
sudo yum install curl
Try to use curl command and then look to the log file
curl google.com
And then look to the log file at log file. You can read here about log file
After that please check your mistakes.
needed to disable the windows defender on windows vm to enable communication.

Can not SSH to Raspberry Pi 3 from Putty

I am not able to SSH to Raspberry Pi 3 from Putty. I can ping the 192.168.137.1 IP address assigned by sharing Internet connection.
The problem I realized that SSH is not enabled by default in Pi3 and saw the posts which suggest to enable SSH by creating 'ssh' file inside /boot folder. I got the SD card which has pre-installed Noobs so when I open SD card it shows only /recovery folder. How to enable SSH in this case ? Please help to resolve it .
Enable SSH like:
documentation
Or start it manually sudo service ssh start - note that manual option will require startup scrip to run at each startup.
Additional settings like port configuration should be done insshd_config. Do it with your favorite editor sudo nano /etc/ssh/sshd_config. Anyway your post should be opened at raspberry forum not at SO...
you can take a look at this thread
How can I get connection with Raspberry without access of its shell?
it mentions about PiBakery which will install rasbian with ssh support. by default ssh is disabled but this might help.

Error in Cloudera Cluster installation process?

I have installed Cloudera manager successfully. It shows Currently managed hosts as 127.0.0.1 and it is active.
When I search and install cluster using the cloudera manager after the loads it shows the following error.
Installation failed. Failed to receive heartbeat from agent.
Ensure that the host's hostname is configured properly.
Ensure that port 7182 is accessible on the Cloudera Manager server (check firewall rules).
Ensure that ports 9000 and 9001 are free on the host being added.
Check agent logs in /var/log/cloudera-scm-agent/ on the host being added (some of the logs can be found in the installation details).
The following image clearly shows the problem while installing my cluster on cloudera manager.
I had a similar problem and it turned out the issue was conveniently skipping (unfortunately) the ...password-less SSH key ... step
After several hours breaking my head over it, I realised this.
At the terminal do,
ls -al ~/.ssh
You must see files like,
abc
abc.pub
These are you public/private key pairs. [Not necessarily the same names as mine above].The file name you used in Setting up SSH public/private keys step for your machine.
You need to copy the data in abc.pub to a file authorized_keys in this same folder. If its not there, create authorized_keys.
Incase you don't have you public/private key pair see here
For ubuntu, the problem is usually because of the association of "ubuntu 127.0.1.1." in your /etc/hosts file. For me, after changing it to "ubuntu 127.0.0.1", which is the standard local loopback, I can add the cluster successfully. Hope this helps!
I was struggling with this problem for two days. Fixing /etc/hosts as suggested by "khoadoan" worked for me.
/etc/hosts was looking like this when I had the problem
127.0.0.1 localhost
127.0.1.1 ubuntu
I changed it like this:
127.0.0.1 localhost
127.0.0.1 ubuntu
Restarted the machine.
sudo init 6
Launched the Cloudera Manager Admin page. This time the host status was already showing up "Managed = Yes". And I got an additional tab "Currently Managed Hosts(1)", where the local host was listed.

How to generate a resolv.conf from every DHCP lease on Mac?

I just want to use a generated resolv.conf file from DHCP lease other than system's /etc/resolv.conf, how can I make a script that every time when DHCP lease then generate a resolv.conf?
Your question is very hard to understand, but I'll give it a shot...
/etc/resolv.conf is not canonical on OS X. If you want to change the system DNS settings then you need to use the System Configuration framework (from code), or networksetup or scutil (from the command line). There's an article about using scutil here.

Resources