Lost internet connectivity: IP address using CentOS - linux

I changed the IP address of my linux machine so that I can communicate with a device. I modified the IP address in the ifconfig-eth0 file to the necessary IP address (IPADDR=192.XXX.X.XXX). I can successfully communicate with my device, but when I rewire my computer to the internet, I cannot connect.
I tried to change the IP address in ifconfig-eth0 back to what google told me my IP address is (130.XXX.XX.XXX), and ran
service network restart
But I am still unable to connect. Any ideas?

I solved the problem by configuring /etc/sysconfig/network-scripts/ifcfg-eth0 (as root) to contain only the following:
DEVICE="eth0"
BOOTPROTO="dchp"
ONBOOT="yes"
Upon restarting the machine, a new IP address was obtained and I was able to connect to the internet.

Related

change ip address for my computer every x times python windows 7

i use python 3.6 and windows 7
i try to use wmi but not working every time i try to change the ip address
no connection happen with the net
and give me this error DHCP is not enabled for local area connection
my code to change the ip address :
def change_ip_address():
nic_configs = wmi.WMI().Win32_NetworkAdapterConfiguration(IPEnabled=True)
try:
nic=nic_configs[0]
except:
raise Exception("error in change ip address")
ip= u'192.168.43.99'
subnetmask=u'255.255.0.0'
gateway = u'15.0.0.254'
nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
nic.SetGateways(DefaultIPGateway=[gateway])
is there any library for windows to do that
I assume that your local network has a DHCP server. This server assigns your PC an IP adress, which it then routes packets to. If you change the IP adress of the nic in your PC, then your PC and the DHCP server no longer agree on the IP adress that you are using. Consequently, packets cannot be routed to your PC, and the PC will report that you do not have an internet connection. There are ways to negotiate a specific IP, assuming that it is available.
If your local network does not have a DHCP server, then there is a server-side configuration that specifies a static IP adress for your MAC adress or the ethernet wall port. In this case, the change must be made on that server.
What you are currently doing, is similar to making up an adress and putting that on your business card and front door. If you were to use a made-up adress, would you expect your mail to arrive to the right door? You would need to at least talk to some civil servant or government official to get it done.

How to write a Node.js server if my pc's ip address changes daily

I am owning a Windows PC. I have written a Web application that runs fine. But the problem is my PC's IP changes periodically. I want that application to be accessible in the network (from other pc's) without changing client side code . My client side code is in angular js.
The web server of your web application cannot bind to the correct IP if it doesn't know it in advance.
You can make your IP address static by following these steps:
In Windows, go to the Network and Sharing center
In the left pane, choose "Change adapter settings"
Right click your ethernet or wifi connection (the one connected to your router) and choose Properties
Double click Internet Protocol Version 4 (TCP / IPv4)
As an IP address, choose the one your computer already has (or try another IP address starting with the first same 3 numbers, i.e. xxx.xxx.xxx.yyy)
The default gateway is the IP address of your router
The subnet mask is typically 255.255.255.0
For the DNS server choose Google's 8.8.8.8 and/or your router's IP address
You have several choices depending upon your configuration.
If this is the public dynamic IP you get from your ISP, you can go to your ISP (whoever you get internet service from) and upgrade your service to a static IP address so it won't change.
If this is the public dynamic IP you get from your ISP, you can use a dynamic DNS service to attach a hostname to your IP address and then use that hostname to access the server. The dynamic DDNS app you put on your server will keep the DNS updated whenever your dynamic IP address changes.
If this is just a local IP address on your LAN (a 192.x.x.x or 10.x.x.x address), then you can pick an IP address that your router supports, but is above the range being used for DHCP and set that computer to use that IP address and not DHCP. In Windows, you can go to the networking configuration and choose the IP address instead of using DHCP. Then, the IP address won't ever change. It is important that you pick an address outside the range used for DHCP to avoid any conflicts. On my own LAN where the router is allocating addresses like 192.168.0.x, I manually assign addresses like 192.168.1.250.
This is something that your router handles through a protocol known as DHCP. Basically, the answer is to keep your IP from changing.
Many routers allow you to reserve an IP for certain MAC addresses. I would recommend that you access your router over your local network and work with the GUI it provides to try to configure this... if you're successful, then your IP will no longer change, and problem solved :-) If it's not intuitive, then of course refer to the documentation for your router.

How to connect to a computer not the modem using internet IP address?

I configured IIS in my windows 7, and when I enter 'http://localhost' in address bar; I can see my web site. Now, when I want to see my web site by entering internet IP address in address bar, I connect to the ADSL modem (it opens the page which we use to configure the modem!).
It seems that because the modem connects to the internet an gets the IP, not the PC, so the internet IP connects me to the modem. So, I think, I must change some settings of my modem.
I use a D-Link modem.
How can I fix that?
Thanks in advance
Unless you have a "server" or "business" configuration from your ISP which provides you a full subnet of public IP addresses, you've been allocated a single external IP address and the router attached to it does Network Address Translation for all the devices connected behind it. You can confirm this by using ipconfig or Windows Settings (ifconfig on Unix-like machines) to get your IP address. If using NAT, it will start with "10.", "172.16." through "172.31.", or "192.168.". These are "private" addresses and cannot be reached through the public internet.
For someone on the public internet to reach your computer, you need to set up Port Forwarding that redirects incoming traffic on your public, external IP to that port to a machine on the private network. The configuration pages for your router will have this configuration somewhere.
Note that if your router's configuration page is running on port #80 and you really want outside viewers to connect to you without giving an explicit port number, you will probably need to turn off or restrict modem configuration, move it to a another port, or go SSL only (port 443) so as to not cause a conflict with the port you're forwarding.
D-Link is a very common brand of router and there are pages dedicated to configuring port forwarding on them.
Also, just to complicate things, you almost certainly haven't been given a Static IP Address (they are usually quite expensive) which means that your external IP address will change from time to time (perhaps yearly, perhaps daily) making it difficult to tell others how to connect to your page. Your router configuration likely has support for Dynamic DNS (some free, some paid) where the router automatically updates the DNS entry whenever your public IP address changes.

Troubles accessing the VirtualHost on a local net

Hi I have a Huawei ADSL modem with a dynamic IP. I set up a dynamic dns with freedns and I can easily access my Virtual host on apache from outside my private network, from internet.
So trying to access it from a local network I get a modems login page.
I have the rule in my modems NAT to connect port 80 to my server but it seems it doesnt work from internal net.
My server hosting the virtual host is 192.168.0.1 , the modem has the 192.168.0.254 address.
I tried to put my external domain name into the /etc/hosts file, but if I do that then asterisk server gets confused.
What could be the cause of the problem ? And what would be the best solution to this problem ?
Should I set up a caching DNS on the private side of the net ?
Hugger is half right... Its because your router is blocking loopbacks. The easiest way around this is to edit the hosts file (See the Wiki page) on the computer that is behind the network to see the local IP of the computer as the virtual host your going for. For example if your server is on 192.168.0.1 and the virtual hostname is www.imrad.com then insert
192.168.0.1 www.imrad.com
into your hosts file. If your computer leaves the local network (like a laptop you take to work) and joins a network not behind your router you need to comment out the line in the hosts file.
well actually to access that you must find the local ip address of the server by going into command line/prompt and typing ipconfig /all then you will find ipv4 address. Take note of that.
Go to another computer and your that ip and it will show.
The reason that was happening is because the router/modem knows you are in its network so it will think you ar trying to go top the login page of it. That happens to me too.

dns not working on embedded device?

DNS is not working on my embedded device, I can do ping to 74.125.77.147, but ping to google 's ip address 209.85.231.104 works but ping google.com is not working.
embedded device runs embedded linux, It is able to get its ip from dhcp, board is connected to network via Ethernet connection.
What can be the reason?
Look at the file /etc/resolv.conf. The DHCP client should have put the nameserver's IP in there. If not, then your DHCP server may not be passing a DNS address or the client may be ignoring it?
If there's nothing in your /etc/resolv.conf then try adding the line:
nameserver dns-ip-address
Confirm that DNS resolution works by pinging google.com. Then get your DHCP server to send a DNS IP as part of it's configuration to the client.

Resources