Virtual IP not getting pinged: wrong settings?
I am unclear why you're mucking about with route commands on the local system in any case. If you have an address configured on one of your local interfaces, you don't need to specify an explicit route; your system will already know how to contact it.
So for example, if you already have eth0
configured as above, you should be able to do this:
ifconfig eth0:0 100.10.10.2 netmask 255.255.255.0
And now your local system will be all set.
For other systems on your network to contact your system at that ip address, one of three things will need to be true. Either:
- they need to have an interface on the same ip network, or
- they need to have an explicit route to that ip network, or
- their default gateway needs to have a route to that ip network
So if you have another system with the "real" address is 192.168.1.3, then you would either do this:
ifconfig eth0:0 100.10.10.3 netmask 255.255.255.0
Or this:
route add -net 100.10.10.0/24 dev eth0
Related videos on Youtube
joshua
Updated on September 18, 2022Comments
-
joshua over 1 year
The initial output of the texfile is this. NO ARRAYLIST OR COMPARATOR IS ALLOWED:
Steve Jobs 9 f 91 Bill Gates 6 m 90 James Gosling 3 m 100 James Gosling 3 f 100 Dennis Ritchie 5 m 94 Steve Jobs 9 m 95 Dennis Ritchie 5 f 100 Jeff Dean 7 m 100 Bill Gates 6 f 96 Jeff Dean 7 f 100 Sergey Brin 27 f 97 Sergey Brin 22 m 98
The collateExams method collates/sorts exam objects starting with the first 'm' (midterm) of the first object and immediately followed by the same person's 'f'(final). Only a SINGLE loop construct is allowed. The output from collateExams() should be the one below but my code is not working, i.e. collateExams method is not working. Could smb help me with that? The output from collateExams() should be
Bill Gates 6 m 90 Bill Gates 6 f 96 James Gosling 3 m 100 James Gosling 3 f 100 Dennis Ritchie 5 m 94 Dennis Ritchie 5 f 100 Steve Jobs 9 m 95 Steve Jobs 9 f 91 Jeff Dean 7 m 100 Jeff Dean 7 f 100 Sergey Brin 22 m 98 Sergey Brin 27 f 97
Im getting NullExceptions at
r[2*position[exams[i].getID()]+1] = new Exam(r[i].getFirstName(), r[i].getLastName(), r[i].getID(), r[i].getExamType(), r[i].getScore()); import java.io.*; import java.util.*; class P2 { public static void main(String [] args) throws FileNotFoundException { Scanner data = new Scanner(new File("Exam.txt")); Exam[] readObjects = readAllExams(data); Exam[] collateObjects = collateExams(readObjects); System.out.println("1) Initially the list of exams of students is: "); System.out.println(); for(int i = 0; i < readObjects.length; i++) { System.out.println(readObjects[i]); } System.out.println(); System.out.println("Sorted list: "); for (int i = 0; i < collateObjects.length; i++) { System.out.println(collateObjects[i]); } } public static Exam[] readAllExams(Scanner s) throws ArrayIndexOutOfBoundsException { String firstName = ""; String lastName = ""; int ID = 0; String examType = ""; char examTypeCasted; int score = 0; int index = 0; Exam[] object = new Exam[s.nextInt()]; while(s.hasNext()) { //Returns firtsName and lastName firstName = s.next(); lastName = s.next(); //Returns ID number if(s.hasNextInt()) { ID = s.nextInt(); } else s.next(); //Returns examType which is 'M' or 'F' examType = s.next(); examTypeCasted = examType.charAt(0); if(s.hasNextInt()) { score = s.nextInt(); } //Exam[] object = new Exam[s.nextInt()]; object[index] = new Exam(firstName, lastName, ID, examTypeCasted, score); //System.out.println(); index++; } readExam(s); return object; } public static Exam readExam(Scanner s) { String firstName = ""; String lastName = ""; int ID = 0; String examType = ""; char examTypeCasted = 0; int score = 0; while (s.hasNext()) { //Returns firtsName and lastName firstName = s.next(); lastName = s.next(); //Returns ID number if(s.hasNextInt()) { ID = s.nextInt(); } //Returns examType which is 'M' or 'F' examType = s.next(); examTypeCasted = examType.charAt(0); if(s.hasNextInt()) { score = s.nextInt(); } } Exam temp = new Exam(firstName, lastName, ID, examTypeCasted, score); return temp; } public static Exam[] collateExams(Exam[] exams) { Exam[] r = new Exam[exams.length]; int [] position = new int[exams.length]; int index = 0; for (int i = 0; (i < exams.length) && (i < position.length); i++) { position[i] = -1; if(exams[i].getExamType()=='m') { if(position[exams[i].getID()]==-1) { r[index*2] = new Exam(r[i].getFirstName(), r[i].getLastName(), r[i].getID(), r[i].getExamType(), r[i].getScore()); position[exams[i].getID()] = 2*index; } else r[2*position[exams[i].getID()] - 1] = new Exam(r[i].getFirstName(), r[i].getLastName(), r[i].getID(), r[i].getExamType(), r[i].getScore()); } else { if(position[exams[i].getID()]==-1) { r[index*2+1] = new Exam(r[i].getFirstName(), r[i].getLastName(), r[i].getID(), r[i].getExamType(), r[i].getScore()); position[exams[i].getID()] = 2*index+1; } else r[2*position[exams[i].getID()]+1] = new Exam(r[i].getFirstName(), r[i].getLastName(), r[i].getID(), r[i].getExamType(), r[i].getScore()); } index++; } return r; } }
-
Admin almost 13 yearsYou're missing the fact that this isn't a programming question: stackoverflow.com/faq
-
sarnold almost 13 yearsBefore anyone can do any debugging, they'll need to see the output of
ip route show
andip addr show
. -
Admin almost 13 yearsI added the the route table and config info. the commands you said, were not working on my linux mint ( weird) but I guess this should give the same info you wanted.
-
Admin almost 13 yearsSorry to reply in the answer box, but it wasn't letting me comment. the ifconfig eth0:0 100.10.10.2 netmask 255.255.255.0 would set me up another interface. I don't want that. If someone connects to the "fake" IP I am redirecting to my machine, I have a script running on it ( as mentioned in first post). I want anyone who connects to it ( ssh) and uses the script would find the "fake" IP address as a separate machine. That is why I was playing around with the route command. I mean, if I want to run this script on 100 "fake" IPs, setting up interface for each of them would not be the ideal solu
-
Michael about 9 yearsJoshua, go look at your other post on this topic, I have added some cleaned up code that may get you to a better spot.
-
joshua about 9 yearsThanks @Michael, but only SINGLE loop construct is allowed!
-
Michael about 9 yearsThe post I replied to said nothing about that. So, you are only allowed a single loop construct, for the sorting only I assume? Are maps allowed? Any other restrictions?
-
joshua about 9 years@Michael, sorry for the previous post for not specifying specs.. and yes, only one loop and only inside one method, no maps, no arraylists, no comparators.
-
David Ehrmann about 9 yearsWhat's wrong with
ArrayList
andComparator
? -
joshua about 9 yearsIm not allowed to use them
-
Michael about 9 yearsIt sounds like this is a homework assignment so he has limits. Also sounds like a complete kluge solution :)
-
joshua about 9 years@Michael, it's a project. I'm having trouble with the collateExams method
-