I have a Dell laptop running the following version of RedHat Linux:
2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux
It has an Ethernet-over-USB connection to a device under test (DUT). This interface to the DUT is usually configured as follows:
IP address: 104.4.40.2
Netmask: 255.255.255.0
Default gateway: 104.4.40.1
The default gateway points to the DUT.
Occasionally, I need to change the IP address / default gateway to 104.4.20.2 and 104.4.20.1, respectively. (The netmask remains 255.255.255.0).
I need to make this change when I load a new configuration onto the DUT that changes its IP address. (This configuration loading is done over a second interface that is unrelated to the interface I'm discussing here.)
When I make the corresponding change to the Linux box's network configuration using the GUI, everything works fine. But I often work remotely by shelling in via ssh. So, all I have available in that case is a Bash shell.
I've used command "ifconfig" (to set the IP address and netmask) and command "route" (to install the default gateway forwarding entry) to reconfigure the interface, and I then used "iconfig" to bring the interface down and back up to try to get the changes to "take".
When I check the interface settings with "ifconfig", they looks right. When I check the forwarding table with "route", everything looks good (including the default gateway). Yet, when I try to ping the DUT, I get no reponse. If I configure the interface yet again using the GUI, I can then ping the DUT.
I am clearly doing something wrong. Could someone please kindly show me the Bash shell command line commands I need to issue to change the IP address and default gateway of interface "eth1"?
Thank you in advance!
If I've got you right, you need these two simple commands:
vim /etc/sysconfig/network-scripts/ifcfg-eth1 //modify the configuration
service network restart
Also you can write a primitive bash/perl/python wrapper for your routines...
This answer may be useful for you too.
Related
We have a PostgreSQL cluster with 2 instances, one of them primary and other one is primary. Both of them are running on Red Hat Enterprise Linux release 8.5 (Ootpa). In order unify connection string we use virtual IP.
We have problem with managing virtual IP. We are managing VIP manually.
On the standby node content of my /etc/sysconfig/network-scripts/ifcfg-eth0:1 :
NAME="eth0:1"
DEVICE="eth0:1"
ONBOOT=no
NETBOOT=no
BOOTPROTO=none
IPADDR=$My-VIP
NETMASK="255.255.255.240"
TYPE=Ethernet
PEERDNS=no
When I reboot this standby server it tries to start "eth0:1" interface even though "ONBOOT=no" parameter and that cause trouble because same VIP, "$My-VIP", is already taken by primary instance.
Is there any other configuration that I should check?
If you need extra information or logs please let me know I will provide it as soon as possible.
Thank you in advance!
According to news that I got from my ex colleagues it is because of base interface, "eth0". After reboot eth0 starts all interfaces that depends on it. Only way to get rid of this commenting IPADDR out for eth0:1.
I am using yocto rocko for my board
I was setting static ip using rc.local at startup .But after some time ip gets changed.
So i found that following file is culprit
/var/lib/connman/ethernet_*_cable/settings
In the file below line is causing issues :
IPV4.method=dhcp
I changed dhcp to manual and everything is working fine.
How to change in yocto build or kernel or filesystem such that when i boot a new card its value is manual by default
Regards
If you want to keep doing it manually on startup you can use connmanctl. I use these commands:
connmanctl config ethernet_*_cable --ipv4 dhcp
connmanctl config ethernet_*_cable --ipv4 manual <ipaddress> <netmask> <gateway>
The * in ethernet_*_cable is the mac address without :'s.
I guess you could patch connman to go with static as default, but wouldn't that bring up all boards with the same IP, and not work if the adresses/routing on your network does not play well with the your static setup? IMHO it makes sense to leave it at DHCP so it can work everywhere, and then reconfigure in a script based on the logic of your choice.
I have a list of hostnames for mixed Linux distros (some Solaris, some RedHat, some Ubuntu), I need to get the IP and MAC for any Ethernet devices on each distro.
I don't have root access to any of these servers, so I wrote a bash script on one that remotely runs on the others and returns IP and MAC parsed from output of ifconfig. Because this script uses an expect file to pass in my password, it takes a long time to execute and is not very elegant.
There has to be a better way to do this. I know of a few tools that can do it for me but unfortunately I can't install any additional packages as I don't have permissions to do so.
The output of arp -a gives exactly what I want, but the problem with this is some of these entries seem to have multiple IPs and hostnames binded to the same MAC address. So I get entries like:
HOSTNAME-1 (IP-1) at SAME_MAC_ADDR [ether] on eth0
HOSTNAME-2 (IP-2) at SAME_MAC_ADDR [ether] on eth0
? (IP-2) at SAME_MAC_ADDR [ether] on eth0
Is there a way to firstly get all IPs and MAC addresses from the list of hostnames I have? I'm guessing arp is what I need here?
Secondly, is there a means to get all additional hostnames or IPs associated with each MAC address if there are duplicates?
The arp command will show the list of MAC address and associated IP addresses of hosts known to the one you are connecting to.
ifconfig is the right tool to use (or "ip a" in some distros). Why don't you try to put a cron job in every machine to store the result of "ip a" or "ifconfig" into a tempfile and instead or executing the command in every remote host, you just donwload this file and parse in your local server?
If not, they only way to get accurate information of network adapters in a *IX box is to get into the host and ask for this info.
I used Promox to create a virtual machine and added a new network interface. The virtual machine is running Ubuntu 12.04. When I did the ifconfig I have two interface: eth0 and eth1.
Now I modified the 70-persistent-net.rules in /etc/udev/rules.d and want to change the name of network interface, i.e. change eth1 to net_c
But when I restarted the machine, the system seems ignored this file and didn't do the rename configuration
Can anyone tell me what is the problem?
If you want to override rules with you own personal rule in /etc/udev/rules.d, you must have a number higher than the rules in /lib/udev/rules.d that you want to override.
In /lib/udev/rules.d, persistent net are in "75-persistent-net-generator.rules", so name your rules with a number higher than 75 :)
I'm trying to set up a distributed load testing environment using JMeter. I need to set up the remote clients using something portable like a Linux Live CD, but whenever I attempt to launch jmeter-server in Linux, I receive the following error...
Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:49018](local),objID:[3b0d3d42:12985b7a49b:-7fff, -8459389540436649718]]]
Server failed to start: java.rmi.RemoteException: Cannot start. testbox01.qa.nwr.lan is a loopback address.
After extensive googling, the only remedy I can find is to edit the /etc/hosts file so the hostname maps to something other than the 127.0.0.1 loopback address. I've tried this using Ubuntu, Fedora and CentOS, and apparently they all default to setting the hostname to 127.0.0.l.
The way I see it, I have four options...
1) Customize the /etc/hosts file for every remote test box I set up, which involves upwards of 20-50 dynamically DHCP-assigned IP addresses.
2) Figure out a way to force Linux itself to assign the hostname to its DHCP IP address by default. This is certainly the more graceful solution, but I have no idea how to do this. Anyone know?
3) Find and use a Linux distro available as a Live CD that doesn't map its hostname to 127.0.0.1 by default. Anyone know one?
4) Dive into JMeter's code and start yanking wires, but if it comes to this, I'd just as soon use another open source tool with a slimmer feature set, but whose distributed architecture doesn't suffer from this issue.
If anyone has any advice, I'd be grateful. Thanks!
In latest version, you can run your script with:
./jmeter-server -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
Replace xxx.xxx.xxx.xxx with this server's IP address, i.e., the IP address that the controlling jmeter machine will use to connect to this server.
Looks like Glen was right on the money with his comment.
Not sure is this helps but I found a bug which seems to contain a patch for this issue.
https://bugs.launchpad.net/ubuntu/+source/jakarta-jmeter/+bug/589042
Thanks again, Glen!
(If you decide to make it into an actual answer, I'll be sure to accept it!)
Change your hostname from localhost to your right ip address.
Check your hostname
hostname
Check your internet ip address
ifconfig
Add this line to /etc/hosts
your_ip_address your_hostname
Comment hostname which assigned localhost in /etc/hosts
I was able to get it to start after setting this environment variable:
export RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
Also have downloaded jmeter 2.8 from here: http://archive.apache.org/dist/jmeter/binaries/
Ubuntu apt-get version is 2.3.4
You can edit jmeter.server file to add:
RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
This solved mine problem.
You can try to check this page for more details.
Add RMI_HOST_DEF=-Djava.rmi.server.hostname=XXX.XXX.XXX.XXX
Add ipaddress hostname to /etc/hosts file
on my system ,/etc/hosts mentioned 127.0.0.1 hostname.
I removed 127.0.0.1 and added public Ip address